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".
158 questions
1
vote
1
answer
60
views
Handling HTTP requests in existing Web Api
I am working in a Web Api project that has the following project structure:
Root
Controllers
Orchestrators
Managers
Services
etc
The ...
3
votes
2
answers
228
views
Laravel Event Filtering Controller
So I am currently writing a function in laravel that handles URL parameter filters.
How the code works: So we have the following two URL parameters:
timeframe and <...
1
vote
2
answers
211
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.
...
1
vote
1
answer
115
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 ...
2
votes
2
answers
227
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 ...
1
vote
2
answers
140
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.
...
1
vote
1
answer
470
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 ...
2
votes
1
answer
115
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 ...
1
vote
1
answer
61
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?
...
1
vote
1
answer
93
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.
...
3
votes
0
answers
65
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 ...
2
votes
1
answer
39
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 ...
4
votes
0
answers
172
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 ...
2
votes
0
answers
72
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). ...
4
votes
1
answer
347
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 ...
2
votes
1
answer
319
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 ...
4
votes
1
answer
210
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?
...
2
votes
2
answers
116
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 ...
1
vote
0
answers
695
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 ...
2
votes
1
answer
83
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 ...
1
vote
1
answer
393
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 ...
6
votes
3
answers
21k
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 ...
3
votes
2
answers
184
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 ...
3
votes
2
answers
1k
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.
...
2
votes
0
answers
62
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.
...
2
votes
1
answer
115
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, ...
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 ...
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 ...
2
votes
1
answer
168
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. ...
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 ...
6
votes
1
answer
137
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 ...
3
votes
2
answers
572
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 ...
5
votes
2
answers
363
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 ...
3
votes
1
answer
9k
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 ,...
4
votes
0
answers
133
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 ...
3
votes
2
answers
60
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 ...
4
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 ...
4
votes
0
answers
854
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://...
2
votes
2
answers
270
views
Laravel lumen : Post API method
Question is quite simple, I am using dingo package, Currently below is my code for an API call.
...
3
votes
1
answer
98
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 ...
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 ...
2
votes
1
answer
112
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 ...
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 ...
0
votes
2
answers
113
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
...
1
vote
1
answer
896
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:
...
5
votes
1
answer
101
views
Defining routes and controllers relationship for given pages
I'm building a CMS app with the help of a custom framework. The back-office is composed of the following pages:
post list
page list
user list
post edit
page edit
user edit
Actually, my routes are ...
0
votes
1
answer
382
views
Communication to Child Controller
This is a simple AngularJs application with two nested controllers. We need to pass data from the parent to the child Controller.
The first thing you find when googling for a solution would be this, ...
2
votes
1
answer
519
views
MVC controller and action that handles favorite items in a session-based list
I've written a Controller and a corresponding Action for a Symfony 2.8 project, that does the following:
handles a list of favorite items of a user
the ids of the favorites are stored in the session
...
2
votes
1
answer
2k
views
Implementing delegate methods in an UIView class
This is my UIView class:
...
3
votes
1
answer
187
views
Rails 5 controller to get information about Steam users
I've done a bit of modifications and finally got it working, and did a lot of reading about @ vs @@ vs just declaring and I came ...