Anúncio

Design patterns

21 de Dec de 2011
Anúncio

Mais conteúdo relacionado

Anúncio

Último(20)

Design patterns

  1. DESIGN PATTERNS -- Mudabbir Warsi
  2. The Pattern Life Cycle Real World Projects Pattern Mining Author Version Preliminary Document -ation Pattern Polishing Reusable Version Pattern Reuse Incident Occurs of a pattern Discover Patterns Document Document Analyse / Rule of Three Feedback Modification PHASE 1: MINING Author World PHASE 2: POLISHING Pattern Community World PHASE 3: REUSE Pattern User World
  3. Pattern Hatching 4. A Miracle Occurs 7. Test the Solution 6. Instantiate the Pattern 5. Evaluate Solution 1. Familiarize yourself with Patterns 2. Characterize nature of u r problem 3. Apply Matching
  4. Inside Model-View-Controller 1. The User did something 2. Change your state 3. Change your display 4. I have changed 5. I need your state information VIEW Gives you a presentation of the model. It gets the state and data to be displayed from the model CONTROLLER Takes user input and figures out what it means to the model MODEL The model holds all the data, state and application logic. It provides an interface to manipulate and retrieve its state.
  5. A Closer Look 1. The User did something 2. Change your state 3. Change your display 4. I have changed 5. I need your state information STRATEGY The view and controller implement the STRATEGY pattern: The view is an object that is configured with a strategy. The controller provides the strategy. Using the strategy pattern keeps the view decoupled from the model. OBSERVER The model implements the OBSERVER to keep interested objects updated when the state change occurs. Using the observer patterns keeps the model decoupled with the view n controller COMPOSITE The view implements the COMPOSITE pattern: The display consists of nested set of windows, panels, buttons, text boxes etc. When the controller tells the view to update, it only has to tell the top view component and the COMPOSITE takes care of the rest.
  6. Observer I’d like to register as an observer My State has changed Observable Observers All these Observers will be notified whenever state changes in the Model Any object that’s interested in the state change of the Model registers with the Model as an Observer. INTENT: Define a one – many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
  7. Strategy The user did something We can swap in another behavior for the View by changing the Controller The Controller is the Strategy for the View – it’s the object that knows how to handle the user action. The View delegates to the Controller to handle the user actions The View only worries about the presentation, the Controller worries about translating user inputs to actions on the Model INTENT: Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithms vary independently from the client that uses it.
  8. EXPERT COMMENTS Today there are more patterns than in the GOF book: Learn them as well. Go for simplicity and don’t become over-excited. If you can come up with a simpler solution without applying a pattern, then go for it. Shoot for practical extensibility. Don’t provide hypothetical generality; be extensible in ways that matter. Patterns are Tools not Rules- They need to be tweaked and adapted to your problem. John Vlissides Richard Helm Ralph Johnson Eric Gamma
  9. Q & A
Anúncio