• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Model 2 Controller/Action Design

 
Dave Montalvo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's an article at java.sun.com about the Model2 architecture and they have some code snippets outlining how it might be implemented. One section of this code is confusing me. Basically the idea is to have an abstract Action class that is extended by whatever specific actions you need.



but the article doesn't really talk about a Model class (see Action.java). Anyone have any ideas what protected Model model; is, or where it might come from, what it might contain?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The model objects are those that deal directly with the database, EJBs, filesystem, etc..
They should not need a servlet container or any of the javax.servlet.. classes to run.
Separating your code this way allows you to test your objects from the command line or with automated tools. It also allows you to reuse the model objects from non-servlet apps if you so desire.

Many developers, (myself included) like to see the model components running on the command line before touching a line of servlet or JSP code. Leaving the main method in your model classes is also useful for debugging later.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After a good explaination of Ben. I would like to add-up my few words.

We all know Model contains our business logic. So we can say a Model could be a business component. And whenever we talk about component we think to re-use it some elsewhere or with some other system, and etc.

Model component shouldn't be dependent on client. No matter it is a web/thin client; with JSF, AJAX etc., or a thick client. No matter we are using SOA or not. No matter it is a desktop or client/server application. Our Model component should work with all.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many developers, (myself included) like to see the model components running on the command line before touching a line of servlet or JSP code.


Fantastic! What great advice!
 
Tim Morrison
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While actually smalltalk started it all, Java makes it fine as silk. What I have seen in developers mostly is that they like to talk about data and business logic. From there, they move on workflow managment, and valiadtions in pages.
Ben has a pragmatic point. Incremental testing for a component developer, in this case EJB developer is usually, to test and re-test the business logic. command line is the immediate choice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic