asp.net mvc - Keeping a controller thin (too many action methods) -


i'm working on first real asp.net mvc project , i've noticed controller i've been working in getting rather large. seemingly goes against best practice of keeping controllers thin.

i've done job keeping business logic out of controllers. use separate layer that. each action calls method in business layer , coordinates end result based on whether or not modelstate valid.

that said, controller has large number of action methods. intuitively, break controller down sub-controllers don't see easy way that. break controller down separate controllers loose hierarchy , feels bit dirty.

is necessary refactor controller large number of thin actions? if so, best way this?

first, when hear it's keep controller code minimum, refers keeping each action method thin possible (put logic instead business classes, not views , viewmodels.) seems you're doing this, great.

as having "too many" action methods, judgment call. sign of organization, you're having each action focus on 1 thing. also, maybe you're using actions use renderaction? and, nature of solution there many things relating controller's theme.

so, guess you're fine. however, make sure, on note paper break out controller 2 or 3 controllers, , sketch out how stories work moving action action. , if find workflow works more controllers, should break out. if you're going adding functionality later. sooner break out better.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -