Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>What is the point of having one view per controller? </p> </blockquote> <p>Again:</p> <ol> <li>You are not loading more code than is necessary per request. Would you load a library, package, dll, that you didn't require? Of course not. So don't create a massive controller file where only a small portion of the code will be executed per request. Also, smaller files are easier to maintain imo, just like smaller methods and modular code. </li> <li>there is a clear 1:1 link between controller and view (especially if they share the same name). This is a convention. It's clear and consistent. If I am looking at a view template, I know exactly the controller that loads it based only on the file name. There is no thinking involved. No decisions. No compromises. </li> </ol> <blockquote> <p>What need is there for a separation of concerns when everything is just pair matched?</p> </blockquote> <p>What need is there for a separation of concerns? If you want to group related pages (controllers/views), lump them in directories.</p> <blockquote> <p>I'd be more inclined to write a controller that controls several views that are related in some way. For instance, the aforementioned add/view/edit of a user. You'd want to keep similar functionality together rather than searching through many files for the code you want. It's also handy to have all the methods defined (for a particular object) in one place. Makes maintenance MUCH easier.</p> </blockquote> <p>I'm going to respectfully disagree. If I have a single view that is responsible for adding/viewing/editing a user, then with the 1:1 convention I know exactly the controller responsible. On the other hand, using your suggestion of grouping similar functionality, if I have a manager controller and a user controller, which one contains the add/view/edit for a manager? User or manager? Now you have to think, or search.</p> <blockquote> <p>I worked on a project using a PHP framework that created a separate file per 'action'. Named like 'object(action)' and it became a NIGHTMARE to maintain. </p> </blockquote> <p>I'm not suggesting that.</p> <blockquote> <p>I've been using Django for a little while now which keeps all the models in one file, all the views (controllers) in one file, and the templates (views) separately. [Django isn't MVC but for these purposes let's pretend it is]. This allows you to group together common code in one place and maintenance becomes much easier.</p> </blockquote> <p>I'm feeling whoosy now. I don't know Django, and I'm assuming the single files are optional, but there is no way I'd maintain a file with tens of thousands of lines.</p> <blockquote> <p>My only advice is - don't try to organise your project based on some ideal of MVC. Organise your project how it makes sense to you and your domain. </p> </blockquote> <p>No, no, no. That is very dangerous advice. Design patterns, coding conventions, and frameworks were designed for a purpose - best practices and consistency. Only a guru should step outside conventions and only if he/she works alone. Even within the confines of a framework, I constantly strive for greater consistency so that I don't have to think when writing or maintaining the code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload