Model - View - Controller

Model - View - Controller

Design Patterns Model View Controller Christian Ratliff [email protected] Senior Technology Architect Core Libraries Group, DeLorme 28 November 2001 History A framework pattern for reusable applications. Depends on the Observer pattern. First developed by Xerox PARC for Smalltalk-80. Used by the Application Kit system in NeXTstep. Used by the Cocoa APIs for Apples OS X. Recommended structural framework pattern in

J2EE. I have used this pattern for nearly ten years. Copyright 2001 DeLorme 28 November 2001 Observer Pattern Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Used to decouple the subject from the observer, since the subject needs little information to notify the observer. Can result in excessive notifications.

Copyright 2001 DeLorme 28 November 2001 Observer Class Diagram Observable +addObserver(Observer) +deleteObserver(Observer) +notifyObservers(Object) #hasChanged() : boolean #setChanged() BankAccount +widthdraw(double) : long +deposit(double) : long +getBalance() : double Copyright 2001 DeLorme 28 November 2001 Observer

+update(Observable, Object) AccountView +update(Observable, Object) SummaryView +update(Observable, Object) Transactions Happen! Controller BankAccount AccountView deposit()

setChanged() notifyObservers() update() getBalance() update() getBalance() Copyright 2001 DeLorme 28 November 2001 SummaryView Observer Rocks! The Observer pattern allowed the BankAccount class to notify multiple views without minimal information. Observers can register themselves with

their Subjects. No strings attached! Transactions would cause this design to collapse under spurious notifications! Copyright 2001 DeLorme 28 November 2001 Architecture Diagram Model business logic Get State View model representation Copyright 2001 DeLorme

28 November 2001 Updat e Event User Action s Set Chang e View State Controller user interaction

Advantages Separation between the data layer and the interface is the key: The view is easily replaced or expanded. Model data changes are reflected in all interfaces because all views are Observers. Better scalability since UI and application logic are separated. Distribution over a network is greatly simplified. Copyright 2001 DeLorme 28 November 2001

Problems Problems of translation: Business logic bleeds into the Controller. Observer pattern is non-obvious for EJBs. See EJBObserver by Greg Comeau. Problems of the pattern: Excessive coupling between the Model and View and the Model and Controller. Frozen interfaces are hard to manage! Copyright 2001 DeLorme 28 November 2001

Recently Viewed Presentations

  • Local Government Basics Understanding Californias System of Local

    Local Government Basics Understanding Californias System of Local

    Local Government Basics Understanding California's System of Local Government Who We Are: Institute for Local Government 501(c)(3) affiliate of two major associations of local government agencies Promote good government at the local level Government that enjoys the public's trust and...
  • FASTENER  ANCHORS  SAFETY SUPPLIES - TOOLS TORONTO BRANCH:

    FASTENER ANCHORS SAFETY SUPPLIES - TOOLS TORONTO BRANCH:

    3m disposable and reusable masks (half and full) in stock plus filters. we . stock several different construction . signs. let us help to keep you safe on the job… sale: ontario regulation first aid . kits. four options for...
  • YOUR HEALTH TRIANGLE - Sault Schools

    YOUR HEALTH TRIANGLE - Sault Schools

    evaluating your results. what is the strongest side of your triangle? what is the weakest side of your triangle? write a few sentences about one thing that you can work on to better yourself.
  • Interpreting Research Results - Oakland University

    Interpreting Research Results - Oakland University

    Interpreting Empirical Research Results A Tutorial Agenda What is Research? What is a Theory? Reading Research Papers Research Criteria Sampling Considerations Caveat Emptor What is Research? Directed Purposive Collection of Data To shed light on A theory Hypothetico-Deductive Method Reading...
  • Electric Energy and Circuits Chapter 15 Potential Difference

    Electric Energy and Circuits Chapter 15 Potential Difference

    is non-linear (non-ohmic). Do Sample Problem on Page 713. Do Practice Problems on Page 714 #s 21 - 26. Series and Parallel CircuitsSection 15.4. ... It is equal to the devices rate of consumption (J/s or W) multiplied by the...
  • Diapositiva 1 - UCM

    Diapositiva 1 - UCM

    Hoy (10 de febrero de 1876) he pasado varias horas en su casa. Como mujer, es deliciosa. Es bella, y cuando habla, su cara se ilumina con una expresión de bondad femenina y de inteligencia superior; es imposible no caer...
  • Physical Properties of Water - Penn State York

    Physical Properties of Water - Penn State York

    Physical Properties of Water Heat Energy and Water Density Structure of Seawater Optical (Light) Properties Sound in Seawater Heat Energy and Water Heat is energy produced by molecular vibration (number of molecules and how rapidly they vibrate). The calorie is...
  • שקופית 1 - meyda.education.gov.il

    שקופית 1 - meyda.education.gov.il

    שימוש בתמונות ממודל (Moodle) אם אתה משתמש ב- TeamUpדרך מודל (Moodle) או דרך מערכת ניהול למידה (LMS) אחרת, הלומדים יכולים להופיע עם תמונות שנמצאות באותה מערכת.