2022 Developer Survey is open! Take survey.

Questions tagged [controller]

In MVC architecture (Model-View-Controller), the object responsible for passing and receiving data to and from views, acting as a bridge between the "Model" and the "View".

Filter by
Sorted by
Tagged with
1 vote
2 answers
142 views

Update person name in database

Can someone review this implemented solution and provide commentary the code is working well but will need refactor and improve this code. ...
user avatar
1 vote
1 answer
49 views

Rails controller to handle offers and payments for rental housing

I've been adding stuff a bit "blindly" to my controller and currently everything is working as it should, but the controller is gotten very messy. I'm using the gem ...
user avatar
  • 11
1 vote
2 answers
182 views

'Lean controller'/'Business logic on service' and filtering, sorting, pagination methods on controllers

I'm currently reading about "Lean controllers"/"Business logic on services" and trying to refactor some legacy code. However I am struggling to apply what is taught in the ...
user avatar
1 vote
2 answers
95 views

Making the controller clean and readable in (Ruby on Rails)

I have this rails controller which works fine but a lot of business logic is confined in the controller which I believe is not a good practice. ...
user avatar
1 vote
1 answer
171 views

An efficient way to order content in controller [Spring Boot]

My code works as intended. CategoryController class has getAllCategories method, which tells ContentOrderMap class to map differently ordered categories to their respective OrderType enum. The ...
user avatar
2 votes
1 answer
81 views

Controller in Laravel with parsing, creation and relationships

The following code represents the store method of a resource controller. A user can create an training offer on my website and can pass various information like ...
user avatar
  • 325
1 vote
0 answers
35 views

Typescript Express - Controller in Controller via dependency Injection or logic in routes

I'm trying to give one Controller one operation. However, some Controllers exists of 2 or more operations. I'm not sure whats the best way to structure this part of the app. For example, I have 2 ...
user avatar
  • 111
1 vote
1 answer
46 views

Passing argument to a constructor and using it only in some class methods

I've created some controller for handling clicked links statistics. Does this class meet Single Responsibility Principle? ...
user avatar
1 vote
1 answer
62 views

Decoupling of validation and data access in ASP.NET

I've been asigned to a project no dev has touched in a long time. It's an ASP.NET MVC 4 application. It appeared to be well coded, but had no testing and the database migration folder is not present. ...
user avatar
  • 165
3 votes
0 answers
59 views

Controller class for an input dialog

I am learning OOP, concretely Java, by developing a real life business application for aimed for repair shops. I have followed MVC pattern design for GUI elements of my application. I was wondering do ...
user avatar
2 votes
1 answer
35 views

Laravel controller methods for registering businesses and stylists

I use the Laravel API and want make messy code cleaner. I have a form for registering business and businessOwner. And stylist who is working under this business registering from same function. And ...
user avatar
  • 21
4 votes
0 answers
118 views

Swift iOS app for showing motivational quotes, with multiple screens

I'm one month into self-learning Swift, and I would like some advice to improve my coding skills. I have listed 2 situations that I think I need to improve. I'd like some feedback focusing on my use ...
user avatar
  • 61
2 votes
0 answers
58 views

Retrieve file and other input fields from JavaScript to send to ASP.NET Core

I am currently developing an e-commerce website where users can upload their photos to customise their products. The use case begins when the user selects a product from our website (e.g. shirt). ...
user avatar
  • 131
4 votes
1 answer
333 views

Codeigniter 3 micro-blogging application

I am working on a basic blog application in Codeigniter 3.1.8 and Bootstrap 4. The application allows Registration (as an author), Login, adding Categories and Posts. I have created an installation ...
user avatar
2 votes
1 answer
238 views

Table View Controller class in Swift

My TableView consists of four cells (for blacklisting categories) with a boolean property (indicated with a checkmark) and another cell with a UISwitch embedded in ...
user avatar
1 vote
0 answers
54 views

updatePositions() Laravel controller method

I have been trying to implement good 'OOP' and coding standards, but I always end up with bloated controllers. How could I clean this controller method? ...
user avatar
4 votes
1 answer
187 views

User controller for a .net core WebAPI dating app

I have this user controller that follows the repository pattern. It works perfect, but is it easy to understand? Is this good quality work? ...
user avatar
  • 41
2 votes
2 answers
103 views

Validation and business logic for a form for milling jobs [closed]

I have the following BLL (Business Logic Layer) class. It is the first class I have created that takes away all responsibility from the UI (where this class is instantiated/created/called) in terms of ...
user avatar
1 vote
0 answers
640 views

React Native app screen for booking appointments

I've been building a two-sided (both clients and service providers would use the app) appointment booking app. This is a screen from which a service provider can confirm their profile after having ...
user avatar
1 vote
0 answers
570 views

Symfony controller to register and activate users

I've been in an interview some time ago. They objected my Symfony API code with following line: Too much code in controller actions. Can be moved to services to keep the business logic apart ...
user avatar
  • 121
1 vote
0 answers
114 views

Laravel Controller function to return view based on user permission

I have one route that switches the routes based on the permission the user has. Here is a little example: ...
user avatar
2 votes
1 answer
79 views

Rails thin controller method to change account plan and fire slack message via a service object

I'm a beginner with Rails and am trying to figure out how to keep my controllers clean and thin, and how to work with service objects. I am building an internal tool to manage our SaaS customers, and ...
user avatar
  • 146
1 vote
1 answer
319 views

JavaFX controller for a poker game

I am making a poker application in JavaFX. When I try to display the cards on the screen it is working perfectly fine. Yet I have a method with a lot of duplicated code in it. I have tried to ...
user avatar
6 votes
3 answers
16k views

ASP.NET REST controller with try-catch error handling

Yesterday someone guided me through this article and I'm wondering whether I should use try-catch implementation or not? I have the following code below which is actually a RESTful service and I have ...
user avatar
3 votes
2 answers
168 views

Rails controller for a vocabulary quiz

I'm new to refactoring and I have just refactored an old Rails project that had bloated controller methods. I spun off the bloated methods into its own separate controller following this logic, since ...
user avatar
  • 131
3 votes
2 answers
670 views

Creating user accounts

I have a method which allows to create user account. It contains some conditions to control empty fields, wrong format of email, weak password, etc. ...
user avatar
2 votes
0 answers
54 views

Controller to execute AJAX requests for a client

I have been developing this structure or pattern (I don't really know how to call it). It's my first time doing something like this, and I'm a bit worried about the future, if it becomes unmanageable. ...
user avatar
  • 43
2 votes
1 answer
97 views

Exporting documents from PostgreSQL into a second database

This is my first try with a database. I read some articles/books and now i tried it myself and I want to know if I can write it better or what are my mistakes. All in all I am using try/catch/finally, ...
user avatar
4 votes
1 answer
2k views

Laravel voting system

I have written a voting class in Laravel. It uses the voting sites API to check if the user has voted today. A user is only allowed to vote once every day. All votes reset at midnight (i.e. 12:00 AM ...
user avatar
  • 49
1 vote
1 answer
1k views

Simple login with jsp

I made a simple login page with Java EE, jsp, servlet, tomcat and jdbc. It does following: login user register user after login it creates token for the session so ya can be directed from start page ...
user avatar
  • 123
2 votes
1 answer
157 views

Codeigniter Controller for work orders

I'm working on a project and one of my controllers is getting quite large and hard to maintain or add to. I'm having trouble deciding what belongs in the controller and what I can move to the model. ...
user avatar
1 vote
3 answers
1k views

Laravel controller to manage sent and received messages

I write small inboxing app in Laravel 5.5 for my wesite. In inbox app users can compose new message, read messages and delete messages. I have only one table in my database for inboxes. Structure of ...
user avatar
6 votes
1 answer
112 views

Logging Window system

(I originally asked this on Stack Overflow and was directed here) So I have 2 classes, one is a PyQT window widget, and the other class is a stack which holds a dictionary pointing to all of the ...
user avatar
1 vote
0 answers
128 views

Laravel Model and Controller code interacation

I am trying to understand if I placed the function in the correct place. If someone could review it and suggest what I am doing wrong or right it would be appreciated. Personally I think I placed the ...
user avatar
  • 121
3 votes
2 answers
494 views

Business logic inside MVC Cart Controller method

I have a controller method, invoked when a user adds the product he is viewing to the cart. The way I understand how MVC works, this can be considered a fat controller already, but I'm still not ...
user avatar
  • 155
1 vote
0 answers
211 views

A rails controller needs to validate certain values exist

I need to pass some values from a CMS to a rails view. I should check these values are defined in the CMS. These values are meant to be use in all pages, hence the use of ...
user avatar
  • 111
5 votes
2 answers
318 views

Request dispatcher for PHP JSON web service

Below you can find the constructor method and related fields of the main class of my REST API (note that the class contains more code than displayed) written in PHP 7.1. It does various things with ...
user avatar
  • 207
3 votes
1 answer
8k views

Is this the right approach for Controller-Service-Dao implementation?

I am a bit confused with Controller Service Dao implementation . I created a dummy User servlet along with Model controller dao and a service , though it will work ,...
user avatar
  • 43
4 votes
0 answers
126 views

Salesforce controller to implement a dynamic form

The code below is a controller for a Visualforce page (form). The controller determines if the form was previously created and saved or saved in progress in a previous action. If the form is new it ...
user avatar
3 votes
2 answers
49 views

Saves files and attachments regardless of errors in the model

I have a long form with dozens of fields, and users can upload photos and attachments in the form. It's super annoying when there is a simple field missing, the record doesn't save, and the user has ...
user avatar
  • 131
3 votes
1 answer
1k views

Laravel LoginController

I have a LoginController in Laravel, but I think it could use some improving, can anyone tell me where I am going wrong? It just seems overall a bit messy, but I can't think of a logical way to ...
user avatar
4 votes
0 answers
652 views

Update UI once all API calls are done

I'm learning Swift at the moment but I would like to produce well-organised code. The goal of my little app is to display the weather of my current location. I use : the API of Darksky : https://...
user avatar
2 votes
2 answers
262 views

Laravel lumen : Post API method

Question is quite simple, I am using dingo package, Currently below is my code for an API call. ...
user avatar
  • 123
3 votes
1 answer
93 views

Performing CRUD between 4 tables

This code works perfectly fine but I have repeated many lines of code in this controller. I need some suggestions on how to optimize this code and remove repetition, with focus on the ...
user avatar
4 votes
1 answer
3k views

Connect to MySQL and fetch a list of customers asynchronously using C#

I am connecting with a database and returning values from a Web API controller. For better performance, I am doing it completely asynchronously with a new task. Am I doing it the correct way? Am I ...
user avatar
  • 41
2 votes
1 answer
96 views

Setting value of controller controls for domain objects with Reflection

Is my use of Java Reflection an OK design? Each domain object contains an annotation to declare what controller would be initialized to edit/create the object: Each field of the domain object has ...
user avatar
  • 123
7 votes
2 answers
1k views

A controller on a .net core API

BACKGROUND I am working on a .Net Core API to drive a lyrics application. Users can sign up, submit artists & lyrics, and earn kudos / XP points in the process. Basically a community-driven ...
user avatar
  • 422
-1 votes
2 answers
99 views

Practicing Java servlets, MySQL and JSON - follow-up

(See the previous iteration.) What's new I have incorporated all the points of Dmytro Maslenko's answer. My code seems a little bit tidier. Code AddPersonController.java ...
user avatar
  • 25.3k
1 vote
1 answer
827 views

Practicing Java servlets, MySQL and JSON

(See the next iteration.) Introduction This is my attempt at a simplistic web application just for the sake of practice. I have three main servlets: ...
user avatar
  • 25.3k
1 vote
0 answers
131 views

Designing better api controller

Overview I am designing one api that will be integration with another system, however I stumbled upon one code which I know it can be improved but I don't know how to do it properly. Code ...
user avatar
  • 423