> In Struts, although you aren't FORCED to, what you GENERALLY do is create > three different Action classes like addItemAction, removeItemAction and > totalPriceAction, and each is called in response to a form submission. > > But isn't it kind of odd that your object model isn't following what you > probably think in your head is the right way, i.e., one class with multiple > related methods? Proper encapsulation and all that jazz, right?
Frank, you could view web application development as event programming just like any other application. There are several layers that have various responsibilities. The call eventually gets to your model where you can use the appropriate OO principles and design strategies. I wouldn't consider the Struts portion the object model, but more of an web presentation layer which utilizes the MVC design pattern in order to communicate with the model and populate and display the appropriate view. I think of an Action as a web event, which can then delegate to a business event which does the actual work (or more appropriately delegates to others...typical management stuff :) ). The business event eventually reports back to the web event which can then report back to the web controller. IMHO, Struts follows solid and proven design patterns. In fact, one could argue that it is very OO, in that it promotes loose coupling with each component being very cohesive. I will admit, it gives you plenty of rope to hang yourself.... My 2 cents. robert > -----Original Message----- > From: Frank Zammetti [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 17, 2004 3:29 PM > To: [EMAIL PROTECTED] > Subject: Theoretical debate > > > Last night I was Googling for something and I stumbled across the Crysalis > framework. I was actualyl intrigued by the underlying premise of it and I > wanted to see what others thought about it. > > In a nutshell and in my own words, Crysalis > (http://chrysalis.sourceforge.net/) has the underlying idea that when you > develop in most MVC frameworks, Struts chief among them, you are actually > doing something unnatural and in a way at odds with basic OOP design. > > Think about a shopping cart example... If you were going to write that in > straight Java, not for the web or anything, how would you model it? Most > likely you would have a ShoppingCart class with a number of methods in it, > things like addItem(), removeItem(), totalPrice(), etc. > > In Struts, although you aren't FORCED to, what you GENERALLY do is create > three different Action classes like addItemAction, removeItemAction and > totalPriceAction, and each is called in response to a form submission. > > But isn't it kind of odd that your object model isn't following what you > probably think in your head is the right way, i.e., one class with multiple > related methods? Proper encapsulation and all that jazz, right? > > Well, Crysalis does just that. It's controller elements are regular Java > classes with multiple methods. What you wind up with is something that > resembles Remote Procedure Calls instead of numerous servlets as > controllers. > > In other words, you would create the ShoppingCart object just as I described > above, with all three methods. Then, when you submit a form, the action is > something along the lines of "ShoppingCart.addItem.cmd". ShoppingCart is > the class to execute, addItem the method and cmd is a suffix to direct the > request, just like extensions in your Struts apps map requests to > ActionServlet. > > The elements of the submitted form are treated as the parameters of the > method being called, making it rather elegant. > > I haven't gotten into any real detail on Crysalis, but I was interested in > getting other peoples' thoughts on the underlying principal (which I *THINK* > I've stated properly!). It was rather interesting to me because I'd never > reall considered looking at it that way, and certainly it's not the way you > typically approach a Struts-based application. It was also interesting to > me because I've for about four years now been preaching here at work that we > should write our applications as a collection of services that are executed > to form a coherent larger application, which is very much along the lines of > this (so I guess I actually HAVE looked at it this way in a sense, but not > exactly). > > Any thoughts? > > Frank > > _________________________________________________________________ > Watch the online reality show Mixed Messages with a friend and enter to win > a trip to NY > http://www.msnmessenger-download.click-url.com/go/onm00200497ave/direct/01/ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]