Questions tagged [controller]

The controller tag is used with questions involving the controller component of the Model View Controller (MVC) design pattern. The controller component accepts input, usually from a user interface, and issues various change and modification requests to the model component and/or the view component controlling the data of the model and how the data is presented. In some cases controller and view are combined into a single component.

Filter by
Sorted by
Tagged with
0
votes
2answers
119 views

How to avoid duplicate code in two similar MVC controllers

I have two panels, one for the admins and the other for partners. And there are two OrderController with Admin\OrderController and Partner\OrderController namespaces. They both look very similar. ...
0
votes
0answers
45 views

Where do JavaFX FXML controllers belong in an ECB architictural design pattern?

I am wondering where does the fxml controller belong in the Entity-Control-Boundary model? When designing a JavaFX application with the help of Scene Builder, Scene Builder generates an fxml file ...
0
votes
0answers
34 views

Provide user access on credit card transaction

I have a database where users have access to a model (called institution), which is designated to them by the admin. In Node.js (using strapi which is a headless cms) I wrote the logic to restrict ...
0
votes
1answer
52 views

What's the best approach to write chronology entries on certain actions in ASP.NET Core MVC?

I'm working on a software product that entails users opening up a case and taking actions to process the case, changing the status, creating tasks, etc. I'd like to provide a history of the actions ...
0
votes
1answer
200 views

How to design thread safe class when separating business logic from POCOs

I like to separate business logic out of POCOs into controllers. If an object must be thread safe, where do I put the lock code? In the POCO itself? Or in a controller? Might make sense because ...
2
votes
0answers
86 views

Packages, a controller class, and coupling vs cohesion

So I'm building my first application, in Python, and some issues have cropped up because of the lack of interfaces (I.e. explicit type declaration) My design involves several homebrew packages, and I'...
0
votes
1answer
577 views

Controller and API DTO Architecture and class organization in .net core with microservices

We are developing a system with coarse microservice architecture. We have an API that uses controllers and back-end logic with Entity-Framework repository, and several types of clients that use this ...
0
votes
1answer
649 views

Is it possible to add Service layer in MVC pattern?

I'm working on javaFX project using Hibernate and H2 database,I'm trying follow the concept of MVC design pattern ,so I have created 3 packages : models :contains POJO classes 2.1 views.fxml:...
1
vote
1answer
168 views

What alternative name to give to controllers?

There are several posts and other contents in the internet that claims against naming classes ending with "er" (like manager, controller, helper...). I personally agree with that, but what ...
2
votes
1answer
157 views

Spring Restful API - Controller strategy

We are developing a new REST Api for our Spring MVC legacy enterprise web application (before this it was communicationg with Adobe Flex frontends). As a general rule we stated that we were creating ...
4
votes
1answer
146 views

Should a Controller have a Model object as an attribute?

For context, this project is a personal budget program I am working on while I try to learn to use MVC patterns effectively. There is a SessionController that passes user commands to a ...
0
votes
1answer
2k views

When to have more than one controller class?

Would it be correct to assume that in general, I would need as many controller classes as classes that can be accessed/modified by a user? For example, If a logged-in user can add/modify to a class ...
1
vote
2answers
380 views

MVC: how to design interface for database

I'm a newbie on web development and I've heard about MVC. If I'm right, it's the Controller that take charge of fetching data from DB. So I have a question: In the pattern MVC, how many objects to ...
1
vote
0answers
127 views

Inversion of control in controller by a mediator

A user has to perform a somewhat complex task on my website (submitting a rating). For the sake of example, let's consider it's a rating for a movie, done through a controller. There are several ...
0
votes
2answers
277 views

Abstraction from database - handling ID types

I am using MongoDB in a project, where relationships between collections are created via referencing a unique document ID of a special BSON ObjectID type. So I can have a School document like this: {...
5
votes
1answer
18k views

Controller calling multiple services

I have a few layers in my WebApplication: Presentation, Service, DAO, Domain. Services call DAO objects which reads data from a Database/File whatever. I have a Controller that needs to fetch data ...
5
votes
3answers
1k views

Is Model a better place to set HTTP status code?

In MVC usually the controller sets whatever needs to be sent back to the client/View, including HTTP status code, e.g.: class Controller { public function get(Request req, Response resp) { ...
3
votes
1answer
110 views

where to put methods that manipulate objects

I have a controller method as follow: public class RoomsController { @RequestMapping(method = RequestMethod.GET, path="/v1/rooms/{name}") public ResponseEntity<?> getRoomInformation(@...
2
votes
2answers
2k views

Should controller layer create model objects or they should be created by service layer?

I have a small application with classic layers Controller-Service-Dao. Controller actually is REST resource, which deals with JSON data. And the questions are: 1. where is the best place to create ...
1
vote
0answers
33 views

Does RaceDataFacade violate the single responsibility principle?

I have heard, that each class should always just be responsible for a single purpose, otherwise you should rethink your design. So here are the concerned classes: WebSocketController: provides ...
1
vote
1answer
38 views

MVC Set or Read View Components

I often see the follwing example when reading about MVC (example is in Java, but question adapts to all OOP languages): class View{ JTextField tfName; public String getTfNameText(){ ...
2
votes
2answers
3k views

writing a controller file in Python

I need some advice on my idea to write a controller file in Python, and not like the C in MVC type controller but a more simpler idea. Just a Python script that controls the operation of some other ...
0
votes
2answers
534 views

In AngularJS - should $resource be used from controller or service?

All the documentation, examples and tutorials I've found on $resource were using it directly in the controller. So far I'm just using $http from services and those services are further used in the ...
0
votes
1answer
224 views

PHP MVC concept large controller

I have custom MVC framework in PHP and my controller file has about 5000 lines. The question is, is it a big concept flaw? It is structured code with kiss method and quite maintainable. Are there ...