c.Model View Controller (MVC)

This pattern was originally designed for thick client application but not much in use today and is of academic interest only 
Web version of MVC pattern is know as MVC2   
  1. Motivation 
    1. This pattern allows total decoupling of Model (Data), View (Presentation/UI) and Controller(Strategy or Logic) as a result any of them can be changed at run time.
  2. Summary 
    1. This pattern has three elements i.e. classes 
      1. MODEL represent a business domain object.
      2. VIEW renders the data provided by model into a form suitable for interaction.
      3. CONTROLLER receives user input and initiates a response by making calls on model objects.
      4. It can be viewed as MVC=MVVM+Controller (View +Data)

  3. How it Works
    1. Though MVC comes in different flavors, control flow is generally as follows:
      1. The user interacts with the user interface in some way (for example, by pressing a mouse button).
      2. The controller handles the input event from the user interface, often via a registered handler or callback, and converts the event into an appropriate user action, understandable for the model.
      3. The controller notifies the model of the user action, possibly resulting in a change in the model's state. (For example, the controller updates the user's shopping cart.)
      4. A view queries the model in order to generate an appropriate user interface (for example the view lists the shopping cart's contents). The view gets its own data from the model. In some implementations, the controller may issue a general instruction to the view to render itself. 
      5. In others, the view is automatically notified by the model of changes in state (Observer) that require a screen update.
      6. The user interface waits for further user interactions, which restarts the control flow cycle.
  4. Types of MVC Design
    1. Classic Version (MVC )
      1. Definition presented above is classic MVC or also called academic version. 
      2. This version is more suitable for client application where request response time is very less. .  
    2. Web MVC (MVC 2) 
      1. This model is a special case of Classic MVC in which View Do not directly observe model and wait of notification from controller.
      2. This model is more stable for Web Developmental platforms like ASP.Net
  5. When to use
    1. Use this pattern if your UI transition logic is very complex and need to handle at central point.
  6. Implementation 
    1. Usually you avoid using handcrafting and prefer MVC frameworks that provides out of the box implementation. 
  7. Related Patterns 
    1. MVC Pattern is it self consist of multiple pattern 
      1. Observer : In Classic MVC view also acts as observer and listen for change notification of model
      2. Strategy:Controller uses strategy pattern to decide which view to load.
      3. Composite pattern is used by View to implement complex UI
  8. Specific Considerations 
    1. MVC vs MVP
      1. In MVC Controller decide which view to load and when model will be notified for data chnages.
      2. In MVP there is controller is replaced by presenter that is specific to view and ac as either superviser of wrapper of model (data)
  9. References 
    1. http://msdn.microsoft.com/en-us/library/ms978748.aspx
    2. http://msdn.microsoft.com/en-us/library/ff647543.aspx
    3. http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference
Model View Controller (MVC).vsd
Ashwini Kumar Singh,
Oct 11, 2012, 12:41 AM