• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Model of MVC

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic