Why MVC ?

  1. Business Logic (Model) is separate from controller.
    • Example : In Hotel the owner want to serve multiple cuisine , so need not to learn it own , it hire some body who is specialized in Some specific cuisine like Chinese Cuisine. That Chinese Cuisine is a Model , and owner is just make a call to the Chinese Cuisine Specialized it make the food and handed over to the Owner (Controller).
  2. View is separate from Controller
  3. View is separate from Model
  4. Conclusion : MVC Follows Separation of Concern Principal.
Framework vs Pattern
  • Pattern is the way you can architect your application.
  • Framework provides foundation (base) classes and libraries.
  • Leverage industry best practices.

To Build our Own MVC Framework

If you want to build 1000 of MVC Applications , you require MVC Framework.
MVC_framework2

Five Core Components:

  1. Actions The most basic unit of work that can be associated with a HTTP request coming from a user.
  2. Interceptors
    • They provide a way to supply pre-processing and post-processing around the action.
    • They have access to the action being executed, as well as all environmental variables and execution properties.
    • Interceptors are conceptually the same as servlet filters, can be layered and ordered.
  3. Value stack / OGNL. The value stack is exactly what it says it is - a stack of objects. OGNL stands for Object Graph Navigational Language, and provides the unified way to access objects within the value stack.
  4. Result types
    • Chain, Dispatcher, Freemarker, HttpHeader, Redirect, Redirect-Action, Stream, Velocity, XSLT.
    • If the attribute is not supplied, the default type "dispatcher" is used - this will render a JSP result.
  5. View technologies.
    • JSP
    • Velocity Templates
    • Free marker Templates
    • XSLT Transformations