Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends on whether you will be testing your Controllers (, which you should be doing). Passing the repositories in by the constructor, and having them automatically injected by your IOC container, is combining convenience with straightforward testing. I would suggest putting all needed repositories in the constructor. </p> <p>If you seem to have a lot of different repositories in your constructors, it might be a sign that your controller is trying to do too many unrelated things. <em>Might</em>; sometimes using multiple repositories is legitimate.</p> <p><strong>Edit</strong> in response to comment:</p> <p>A lot of repositories in one controller constructor might be considered a <a href="http://en.wikipedia.org/wiki/Code_smell" rel="nofollow noreferrer">bad code smell</a>, but a bad smell is <em>not</em> something wrong; it is something to look at because there <em>might</em> be something wrong. If you determine that having these activities handled in the same controller makes for the highest <strong>overall</strong> simplicity in your solution, then do that, with as many repositories as you need in the constructor.</p> <p>I can use myself as an example as to why many repositories in a controller is a bad smell. I tend to get too cute, trying to do too many things on a page or controller. I always get suspicious when I see myself putting a lot of repositories in the constructor, because I sometimes do try to cram too much into a controller. That doesn't mean it's necessarily bad. Or, maybe the code smell <em>does</em> indicate a deeper problem, but it not one that is too horrible, you can fix it right now, and maybe you won't ever fix it: not the end of the world.</p> <p><em>Note</em>: It can help minimize repositories when you have one repository per <a href="https://stackoverflow.com/questions/1958621/whats-an-aggregate-root">Aggregate root</a>, rather than per Entity class.</p>
    singulars
    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. 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