Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In general (outside of Rails), it is not a smell at all. In fact, I'd argue that having a pure 1:1 mapping between "models" and "controllers" is a smell. </p> <p><em>Note:</em> I am not a ROR dev. I have no experience in ROR or how it implements things. However, I do understand design patterns quite well, and understand application architecture. With that said:</p> <p>Instead of worrying about 1:1 mappings, step back and think about the structure of the application. </p> <p>What is the Controller supposed to be doing? Well, in general it is supposed to route user actions to the application. It is just a plumbing step.</p> <p>Then what is a Model (layer) supposed to be doing? In general, the Model is a layer that encompasses all of your business logic in the application. It will handle database interaction, access controls, business operations, etc. Therefore, the model is actually the vast majority of your application. </p> <p>The View on the other hand is your presentational layer. It should handle all rendering, pulling data from the model layer. </p> <p>Based on that understanding, your models, views and controllers should be able to vary independently to each other. In general, I'd expect to see a fairly 1:1 relationship between controllers and views. What I mean by that is that each controller that exists, I'd expect to see a view. But there can be views that exist where there's no user interaction. In those cases, you may need a controller (to render the view), or depending on your architecture, you many not need one.</p> <p>But the "model classes", which are a small part of the model layer (acting as proxies or adapters for the lower model functionality) may or may not be 1:1 with controllers or views. For example, you may have a view that pulls data from multiple models. You can have a controller which acts on multiple models. </p> <p>Now you could step back and say that if a controller needs to act upon multiple models, then create a new model which abstracts that operation. Sometimes that is the right thing to do. Sometimes it's not. It all boils down to the specific operations and relationships involved...</p> <p>At the end of the day, there's no "right" or "wrong" here. It really comes to a design decision that you need to make as you structure your application. I wouldn't worry too much about the "smell" component, as long as it makes sense in your application...</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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