| Author |
MVC without Struts: A doubt
|
Yash Sharma
Ranch Hand
Joined: Jan 30, 2003
Posts: 61
|
|
I have been busy dealing with a MVC framework of my own. I have defined an abstract Action class, based on which I create concrete Action classes (for eg: CreateUserAction). Model here is some user defined class or bean. I wonder why we need to have a bean to put my business logic in, can't I put it inside my concrete action classes itself. For instance, instead of doing a model.createUser() I could perhaps write the logic in the perform method itself. Does it dilute the MVC model, if I do so? I had read that writing an if-else contructs to redirect request based on the "action" requested makes ugly code and hence the concept of keeping a map of all action classes and loading them dynamically. But I fail to see how the controller servlet can avoid writing such constructs in order to write code to handle redirects based on responses. Example, for a simple login authentication: If I have a dozen actions in my application which return result as strings. Assuming that for each database related operation of Add/Modify/Delete there will thus be 6 such results depending on their SUCCESS/FAILURE Iwill perhaps end up having 72 such if-else constructs. Is this observation correct or my approach of getting the results as String is wrong? Thanks for your time.
|
 |
 |
|
|
subject: MVC without Struts: A doubt
|
|
|