Does the traditional use of the controller in MVC lead to a violation of the Single Responsibility P
Posted
by Byron Sommardahl
on Stack Overflow
See other posts from Stack Overflow
or by Byron Sommardahl
Published on 2010-04-22T23:22:49Z
Indexed on
2010/04/22
23:33 UTC
Read the original article
Hit count: 349
mvc
|single-responsibility
Wikipedia describes the Single Responsibility Principle this way:
The Single Responsibility Principle states that every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.
The traditional use of the controller in MVC seems to lead a programmer towards a violation of this principle. Take a simple guest book controller and view. The controller might have two methods/actions: 1) Index() and 2) Submit(). The Index() displays the form. The Submit() processes it. Do these two methods represent two distinct responsibilities? If so, how does Single Responsibility come in to play?
© Stack Overflow or respective owner