I've created a .NET winforms MVC. The Controller and View are in the same EXE. Model is in a set of DLLs that get used by several groups. The MVC is very explicit. Model knows nothing of Controller and Controller knows nothing of View. I'm thinking to put the Controller in its own DLL so that it can be unit tested. Highly unlike someone will reuse the controller. Unit testing is the only reason I have for the move into a DLL.
Conceptually, should the controller always be in the same assembly as the View? What are reasons for/against keeping them together?
One should be of type Controller, and the other ApiController, then they can both exist with the same name.
A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.
In Spring MVC, we can create multiple controllers at a time. It is required to map each controller class with @Controller annotation.
It shouldn't! That's why it's designed in a modular way. In most web applications out there, we version and deploy all these assemblies (Web, BLL and DAL) together. So, separating a project into 3 projects does not add any values.
Separation of controllers and views are an abstract concept. There's no strict rule that you should physically keep them separate (just like tiers in a three-tier application). However there might be some advantages in either approach.
Separating assemblies has the following benefits:
However, it might be unfeasible for small projects. For very small projects you might want to ship a single executable and nothing else along it. Also, you might not want to create 3 separate projects.
Hey, you might not wanna unit test it at all ;) Ouch, my head is hurt, where did this big brick come from? :))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With