Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is Model ?

 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kinjal Sonpal
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kinjal Sonpal
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,

Thanks for your reply it really helped me.

thanks
Anurag
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic