How big should your controllers be in asp.net-mvc

I see a new feature of areas in asp.net-mvc 2. It made me think. why do I need it? I read a few use cases, and I learned how big and how wide my controllers should be?

Should I try to have many small controllers? one big controller?

how do people define the sweet spot for the number of controllers? I think my maybe too big (which, first of all, caused questions, because maybe my controller name should be a scope and have several smaller controllers)

+4
source share
1 answer

I like to think of controllers in terms of the domain areas for which they are responsible. Thus, you can always combine and separate them to find a balance.

For example, you might have one giant controller for a domain user. Or you can break it down into areas such as User / Settings, User / Profile, User / Orders, User / Statistics, etc. When they grow, you split them further, like User / OrderingStatistics, User / VisitStatistics, User / ItemGroupStatistics, etc.

+7
source

Source: https://habr.com/ru/post/1310649/


All Articles