MVC Seminar Presantation

41
Model View Controller Design Pattern Guided By: Submitted By : Dr. Avinash Panwar Abhishek Yadav Shashwat S Mehta Sourabh Jain

description

As a part of the course work we were supposed to prepare a seminar on any topic of Interest, So we tried to demystify MVC as a Design pattern.

Transcript of MVC Seminar Presantation

Page 1: MVC Seminar Presantation

Model View Controller

Design Pattern

Guided By: Submitted By :

Dr. Avinash Panwar Abhishek Yadav Shashwat S Mehta Sourabh Jain

Page 2: MVC Seminar Presantation

WHY MVC ?

WHAT’s MVC ?

HOW MVC ?

Page 3: MVC Seminar Presantation

3

Overview:

1. Design Patterns 2. Why MVC 3. What is MVC 4. Alternative Patterns 5. Implementation Frameworks 6. Benefits and Disadvantages

Page 4: MVC Seminar Presantation

Problem Without Separation of concerns a developer has to rely and wait for the feeds of others to complete his tasks. Productivity --

Solution With separation of concerns by MVC, he can build applications faster, Unit test them easily without any involvement of other developers. Productivity ++

4

Page 5: MVC Seminar Presantation

MVC Pattern? Architecture? Framework?

5

Page 6: MVC Seminar Presantation

Pattern: “ Each pattern is a three-part rule, which expresses a relation between a certain context (design context), a certain system of forces which occurs repeatedly in that context (recurring design problem), and a certain software configuration which allows these forces to resolve themselves (solution). “

6

Page 7: MVC Seminar Presantation

Architectural Pattern: Fundamental structural organization for software systems. Architectural patterns are high-level strategies that concerns large-scale components, the global properties and mechanisms of a system. “At the highest level, there are the architecture patterns that define the overall shape and structure of software applications. Down a level is the architecture that is specifically related to the purpose of the software application. Yet another level down resides the architecture of the modules and their interconnections. This is the domain of design patterns, packages, components, and classes.”

7

Page 8: MVC Seminar Presantation

8

Framework: A software framework is a universal, reusable software platform used to develop applications, products and solutions.

Page 9: MVC Seminar Presantation

A Generic MVC Framework

9

Page 10: MVC Seminar Presantation

Model

• represents an application’s data and contains the logic for accessing and manipulating that data

• groups related data and operations for providing a specific service

• services accessed by the controller for querying or effecting a change in the model state.

• The model notifies the view when a state change occurs in the model.

• The Model layer represents the part of your application that implements the business logic

10

Page 11: MVC Seminar Presantation

View

• responsible for rendering the state of the model

• forwards user input to the controller

• View renders a presentation of modeled data

• can be used to deliver a wide variety of formats depending on your needs

11

Page 12: MVC Seminar Presantation

Controller

• responsible for intercepting and translating user input into actions to be performed by the model

• responsible for selecting the next view based on user input and the outcome of model operations

• handles requests from users

• can be seen as managers taking care that all needed resources for completing a task are delegated to the correct workers

12

Page 13: MVC Seminar Presantation

Example

13

Page 14: MVC Seminar Presantation

Alternatives

14

Page 15: MVC Seminar Presantation

THE MODEL-VIEW-PRESENTER

(MVP) PATTERN

15

Page 16: MVC Seminar Presantation

The Taligent Model-View-Presenter Pattern

16

Page 17: MVC Seminar Presantation

Components • Model refers to the data and business functionality of the application

• Selections are components which specify what portion of the data within

the Model is to be operated upon

• Commands are components which define the operations which can be performed on the data

• View is the visual representation of the Model and is comprised of the screens and widgets used within an application

• Interactors are components which address how user events are mapped onto operations performed on the Model

• Presenter is a component which orchestrates the overall interaction of the other components within the application

17

Page 18: MVC Seminar Presantation

The Dolphin Smalltalk Model-View-Presenter Pattern

18

Page 19: MVC Seminar Presantation

Components

• The Model refers to the data and business functionality of the

application.

• The View is the visual representation of the Model and is comprised of the screens and widgets used within an application.

• The Presenter is a component which contains the presentation logic which interacts with the Model.

19

Page 20: MVC Seminar Presantation

The Supervising Controller Pattern

20

Page 21: MVC Seminar Presantation

Components

• The View is the visual components used within an application such

as screens and widgets.

• The Controller is a component which processes user events and the complex presentation logic within an application.

21

Page 22: MVC Seminar Presantation

The Passive View Pattern

22

Page 23: MVC Seminar Presantation

Components

• The View is the visual components used within an application such

as screens and widgets

• The Controller is a component which processes user events and the presentation logic within an application

23

Page 24: MVC Seminar Presantation

The

Presentation-Abstraction-Control

(PAC)

Pattern

24

Page 25: MVC Seminar Presantation

25

Page 26: MVC Seminar Presantation

Components

• The Presentation is the visual representation of a particular abstraction within the application

• The Abstraction is the business domain functionality within the application

• The Control is a component which maintains consistency between the abstractions within the system and their presentation to the user in addition to communicating with other Controls within the system

26

Page 27: MVC Seminar Presantation

MVC Implementations

27

Page 28: MVC Seminar Presantation

MVC Implementation in J2EE

Used for separating business layer functionality represented by JavaBeans or EJBs (the model) from the presentation layer functionality represented by JSPs (the view) using an intermediate servlet based controller.

28

Page 29: MVC Seminar Presantation

29

Page 30: MVC Seminar Presantation

30

Page 31: MVC Seminar Presantation

Model 1 and Model 2

In the design of Java Web applications, there are two commonly used design models, referred to as Model 1 and Model 2

31

Page 32: MVC Seminar Presantation

Model 1 Architecture

• a request is made to a JSP or servlet

• JSP or servlet handles all responsibilities for the request

• commonly used in smaller, simple task applications

• not conducive to large-scale application development

32

Page 33: MVC Seminar Presantation

Model 2 Architecture

• separates the display of content from the logic used to obtain and manipulate the content

• requests from the client browser are passed to the controller

• controller performs any logic necessary to obtain the correct content for display

• places the content in the request

• view then renders the content passed by the controller

33

Page 34: MVC Seminar Presantation

ASP.NET MVC features

• Separation of application tasks, testability, and test-driven development by default

• An extensible and pluggable framework

• powerful URL-mapping component lets you build applications that have comprehensible and searchable URLs

• Support for existing ASP.NET features

• MVC’s model works through URL routing to specific controller methods and any operation routes back to a specific method in the controller.

34

Page 35: MVC Seminar Presantation

GUI Frameworks

• XPages – for IBM Lotus Notes/Domino

• GTK+ provides models and views, while clients implement the controllers through signals

• Microsoft Foundation Class Library (MFC) – called the document/view architecture

• ASP.NET MVC Framework – reusing jQuery libraries and proprietary Microsoft Ajax libraries

• Microsoft Composite UI Application Block – part of the Microsoft Enterprise Library

• Oracle Application Development Framework – Oracle ADF

• Java Swing

• Adobe Flex

• Wavemaker – open source, browser-based development tool based on MVC

• Visual FoxExpress is a Visual FoxPro MVC framework

35

Page 36: MVC Seminar Presantation

Web Frameworks

• XForms has an integrated MVC architecture with an integral dependency graph, frees the programmer from specifically having to perform either push or pull operations.

• Ruby on Rails

• Django - A complete Python web application framework, prefers to call its MVC implementation MTV, for model-template-view.

• Zend Framework - An open-source PHP 5-based framework featuring a MVC layer and a broad-spectrum of loosely coupled components.

• Joomla - free and open source content management system (CMS) for publishing content on the World Wide Web and intranets and a MVC Web application framework that can also be used independently.

• CodeIgniter - simple, light, fast, open source MVC framework for building websites using PHP.

36

Page 37: MVC Seminar Presantation

• CakePHP - A web application framework modeled after the concepts of Ruby on Rails.

• ASP.NET MVC Framework

• Swing - uses a model-delegator pattern, where the view and controller are combined, but the model is separate

• Java Hibernate

• Spring MVC Framework

• Struts

• Java Server Faces (JSF)

• Web Dynpro for ABAP & Java

37

Page 38: MVC Seminar Presantation

Benefits

• Supports Test Driven Development

• Supports multiple views

• Accommodates change

38

Page 39: MVC Seminar Presantation

Disadvantages

• Complexity

• Cost of frequent updates

39

Page 40: MVC Seminar Presantation

References: 1. A Timeless Way of Hacking: R Gabriel, in Core J2EE Patterns, Pearson Education. 2. Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides in Design Patterns:

Elements of Reusable Object-Oriented Software,AddisonWesley Professional, November 10, 1994

3. Roger S Pressman in Software Engineering: A Practitioner's Approach (International Edition),McGraw-Hill, January 20, 2009

4. Understanding Model-View-Controller in CakePHP cookbook 2.x, Available: http://book.cakephp.org/2.0/en/cakephp-overview/understanding-model-view-controller.html

5. David Lloyd, Expresso Developer's Guide, What is MVC, Available: http://www.jcorporate.com/expresso/doc/edg/edg_WhatIsMVC.html

6. Wikipedia, Model View Controller, Available: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

7. Microsoft ASP.NET Team, ASP.NET MVC Overview, Available: http://www.asp.net/mvc/tutorials/overview/asp-net-mvc-overview

8. MSDN, Model View Controller, Available http://msdn.microsoft.com/en-us/library/ff649643.aspx

9. John T.Emmatty, Differences between MVC and MVP for Beginners, Available: http://www.codeproject.com/Articles/288928/Differences-between-MVC-and-MVP-for-Beginners

40

Page 41: MVC Seminar Presantation

Thank you !!