• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Model of MVC

 
Renata fonseca
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to understand the actual meaning of "Model" of MVC.
I know that it encapsulates the Business Logic, but what is exactly "Business Logic"?
- Some authors say that it encapsulates the data...
- Other people say that encapsulate code to interact with a database...
- Others say that encapsulates data and functions...

What is the true?
 
boyet silverio
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on the '-'s
those are right as long as they pertain to the "business" of the client whom you are making a program for.
As for "business logic", this could refer to the way one implements a "business rule" in a program. For example if we have the following business rule:
"A customer order worth more than 5,000 dollars will be applied a discount of 15% on the total price"
And implemented in code in the following sample:

the logic behind the sample code is the "business logic".
As for "model", the sample Order class could represent a data "model". It encapsulates data such as customer, date of purchase, total amount, etc.. It could also interact with the database when saving or extracting these items - with the help of another class or not. It encapsulates business function e.g. getDiscount...
For an MVC framework, business logic e.g. represented by code that computes the discount inside a view component would not be proper as in the following

Instead an OrderBean "loaded" and received from another component via a controller can be used e.g.

Or, for those who find java code inside web pages as evil , they create custom tag to use e.g.

Of course, there are better implementations out there ... and examples...
hope this helps.
[ May 25, 2003: Message edited by: boyet silverio ]
 
Jason Qiu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Velocity and Structs are excellent implemention of MVC for Java servlets.
They are also very popular applications for Servlets development now.
Check them on http://jakarta.apache.org
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic