Presentation is loading. Please wait.

Presentation is loading. Please wait.

DESIGN PATTERN PRESENTATION AND DISCUSSION RAJAT ARYA EFECS * OIM Model-View Controller.

Similar presentations


Presentation on theme: "DESIGN PATTERN PRESENTATION AND DISCUSSION RAJAT ARYA EFECS * OIM Model-View Controller."— Presentation transcript:

1 DESIGN PATTERN PRESENTATION AND DISCUSSION RAJAT ARYA EFECS * OIM Model-View Controller

2 Agenda Definition  what is this fancy thing called MVC? History / Origins  where does it come from? Functional Description  how does MVC actually work? Goal / Benefits  why is it important? Example Scenarios  where could MVC be used? Sample MVC Implementation Review  lets see this thing actually working Modern Implementations  where does it exist right now? Questions? Reference Materials

3 MVC Definition The Model-View Controller Paradigm is a triad of classes used to build modular applications. MVC consists of three components (objects): Model – application object (data) View – user interface (presentation) Controller – defines how user interface reacts to user action

4 History First Appeared Formally in: “A cookbook for using the model-view controller user interface paradigm in Smalltalk-8” by Glenn E. Krasner and Stephen T. Pope Journal of Object-Oriented Programming, 1(3):26-49 August/September 1988

5 Functional Description Intro – Observer Pattern MVC utilizes two applications of the Observer Pattern Observer Pattern (aka Publish-Subscribe) Attach / Detach / Notify Decouples Subjects from Observers, subjects do not know about observers directly

6 MVC Functional Description MVC Definition: Specific application of the Observer Design Pattern Model is application object (data) View is the user interface (presentation) – observes Model Controller defines way user interface reacts to input – observes View Observer Pattern Used Twice (Controller observes View and View observes Model) View Controller Model

7 MVC Functional Description (2) Controller maintains knowledge of both View and Model, View has knowledge of Model Controller observes changes in View (1), informs Model (2) View observes changes in Model (3) and updates (3) (2) (1) Controller View Model

8 Goal / Benefits Modularity  decoupling components  allows each component to be versioned independently  worked on by individuals on team (UI person, DB person, etc) Flexibility  multiple Views for one Model (web frontend, desktop frontend, mobile frontend, etc)  replace one component (replace data storage from flat file to database) Maintainability  only change one component where bug exists, less risk in late changes Testability  each component communicates through contract so each component can be unit-tested independently

9 Example Scenarios Spreadsheet application (classic)  same data (model) spreadsheet can have multiple charts (views)  updating spreadsheet should result in updated charts  example of multiple views, single controller, single model Scaling an application  view is desktop or web, model is a flat-file database  updating the database to clustered set of SQL servers  only model needs to take changes for architecture, controller connects to new model and doesn’t know that the model is now backed by several DBs instead of one file Multiple user interfaces to application  web interface, mobile phone interface, point-of-sale interface, desktop interface  multiple views, multiple controllers, single model

10 Sample Implementation Review Small WPF Application written in C# to illustrate how MVC. me if you would like a copy of the source code.

11 Modern Implementations GUI Frameworks for desktop applications  Application Kit – part of Cocoa for OS X desktop apps  GTK+ - part of GTK libraries, used in lots of apps  Microsoft Foundation Classes (MFC) – Document/View Architecture  Java Swing  Windows Presentation Framework (WPF)  TK Toolkit – part of Tcl/Tk Implementations of MVC in web-based frameworks  ASP.NET MVC Framework (.NET)  ProMesh.NET (.NET)  Grails (Java)  Struts (Java)  Spring (Java)  PureMVC (JavaScript)  Ruby on Rails (Ruby)  Zend Framework (PHP)  Django (Python)  Pylons (Python)

12 QUESTIONS? Fin.

13 Reference Links Design Patterns: Elements of Reusable Object-Oriented Software  If you get nothing else from this talk, please go look this up – it is the most important book I’ve read regarding object-oriented programming: Professional/dp/ /ref=pd_bbs_sr_1?ie=UTF8&s=books&qid= &sr=8-1 Professional/dp/ /ref=pd_bbs_sr_1?ie=UTF8&s=books&qid= &sr=8-1 MVC     Observer Pattern   


Download ppt "DESIGN PATTERN PRESENTATION AND DISCUSSION RAJAT ARYA EFECS * OIM Model-View Controller."

Similar presentations


Ads by Google