aspose file tools*
The moose likes Struts and the fly likes What is Model ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "What is Model ?" Watch "What is Model ?" New topic
Author

What is Model ?

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi All,

I have a basic doubt what is model in MVC.

1. Is this just EJB and JavaBeans??

2. Or its combination of EJB+JavaBeans+Database ??

3. What is DTO(Data Transfer Object) or say Value Object ??


Please give me a answer which can clarify these questions.

thanks
Anurag


SCJP 1.2
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
I'll try to answer the question, though googleing on MVC would lead you to great explanations on Model of MVC.

In simplest of all forms, Model is nothing but the data that the application uses/process/stores in a persistent medium. The medium could be a simple text file, an RDBMS, or an LDAP server. I encountered this definition somewhere on the internet :

The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller)


From implementation point of view, I would have a typical DAO layer doing the work for me.

Also refer to J2EE Patterns Catalog for these patterns.

And this for a very simple explanation of MVC.
Basic MVC model

A VO/DTO would typically be a JavaBean having accessors for it's properties, which helps in transferring data across different layers of the application in a nice package.

These are my 2 cents. Gurus, please correct me if I'm wrong somewhere.

Thanks and regards,
Kinjal Sonpal
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Pretty well put, Kinjal.

The Model (or MVC for that matter) is a loose term. It means different things to different people. HTTP ruined the original definition because the Model is supposed to be able to update the view.

Say you're wanting to do a webapp that displays current sports scores. The server can't push new scores to the web browser. Most web pages with this have javascript to refresh the page every minute (or use applets). MVC is a fairly old term; old enough that it its founder(s) did not have webapps in mind yet.

I imagine this question came here because of Struts' boasting of MVC use. Struts DOES have some functionality that is common with MVC, but as for the Model, Struts has a square peg called ActionForms that people force into the round, "Model", hole. It might be more correct to say that Struts has VC architecture.


A good workman is known by his tools.
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Originally posted by Marc Peabody:
I imagine this question came here because of Struts' boasting of MVC use. Struts DOES have some functionality that is common with MVC, but as for the Model, Struts has a square peg called ActionForms that people force into the round, "Model", hole. It might be more correct to say that Struts has VC architecture.

Absolutely. In fact, the deprecation of the GenericDataSource from struts 1.1 release clearly gives us a lead. This is what the introductory page on struts home has to say about struts.

Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. For the Model, Struts can interact with any standard data access technology, ...

HTH.

Thanks and regards,
Kinjal Sonpal
[ May 29, 2004: Message edited by: Kinjal Sonpal ]
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
hi All,

Thanks for your reply it really helped me.

thanks
Anurag
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is Model ?