Design Patterns Ric Holt & Sarah Nadi U Waterloo, March 2010.

Slides:



Advertisements
Similar presentations
JDBC Session 4 Tonight: Design Patterns 1.Introduction To Design Patterns 2.The Factory Pattern 3.The Facade Pattern Thursday & Next Tuesday: Data Access.
Advertisements

 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
Chapter 8, Object Design Introduction to Design Patterns
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
Adapters Presented By Zachary Dea. Definition A pattern found in class diagrams in which you are able to reuse an ‘adaptee’ class by providing a class,
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Façade Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Chapter 22 Object-Oriented Design
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
Design Patterns.
ADAPTER PATTERN BY Sravanthi Karumanchi. Structure Pattern Structure patterns are concerned with how classes and objects are composed to form large structures.
Implementing Design Patterns Using Java St. Louis Java Special Interest Group Eric M. Burke Object Computing, Inc. Presented on July 9, 1998 (updated July.
Case Studies on Design Patterns Design Refinements Examples.
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
SOFTWARE DESIGN AND ARCHITECTURE
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
© Spiros Mancoridis 27/09/ Software Design Topics in Object-Oriented Design Patterns Material drawn from [Gamma95] and [Coplien95] Revised and augmented.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Design Patterns
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
Structural Design Patterns
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Title Carolina First Steering Committee October 9, 2010 Online Voting System Design Yinpeng Li and Tian Cao May 3, 2011.
CSC 480 Software Engineering Design With Patterns.
OO Methodology Elaboration Iteration 2 - Design Patterns -
FacadeDesign Pattern Provide a unified interface to a set of interfaces in a subsystem. Defines a high level interface that makes the subsystem easier.
Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
More Design Patterns From: Shalloway & Trott, Design Patterns Explained, 2 nd ed.
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Adapter and Façade Patterns By Wode Ni and Leonard Bacon-Shone.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Design Patterns: MORE Examples
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
GoF Patterns (GoF) popo.
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Introduction to Design Patterns
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Design Patterns
Advanced Programming Behnam Hatami Fall 2017.
Object Oriented Design Patterns - Structural Patterns
Structural Patterns: Adapter and Bridge
10. Façade Pattern SE2811 Software Component Design
Presented by Igor Ivković
Presentation transcript:

Design Patterns Ric Holt & Sarah Nadi U Waterloo, March 2010

What is a Design Pattern A Design Pattern systematically names, explains, and implements an important recurring design. These define well-engineered design solutions that practitioners can apply when crafting their applications. 2

Why Design Patterns? Good designers do not solve every problem from first principles. They reuse solutions. Practitioners do not do a good job of recording experience in software design for others to use. Patterns help solve this problem. 3

Four Example Patterns 1.MVC (Model View Controller) 2.Adapter 3.Facade 4.Factory 4

1. MVC Pattern (Model View Controller) There is a model (subject) which can be thought of as the application There are one or more views of the object (by observers) There is a controller that mediates between the model and the view(s). 5

Example MVC a b c a b c [Mancoridis picture] Views Controller Model abc a = 50% b = 30% c = 20% 6

Example MVC a b c a b c [Mancoridis picture] Views Controller Model abc a = 50% b = 30% c = 20% See Interact 7

Multiple View Problem Need to keep all the views consistent If user (or one of users) changes a view, all other views should be updated 8

Information Hiding: Insulating Model from Presentation The model is the “back end” or “business logic”, or “application” To minimize complexity, the model should know as little as possible about –How users interact with system –How many users are there –Any other models 9

Implementing MVC There are many choices –Where is list of views (observers) kept? –How is notification of change transmitted? –How manage web interface? –Should a view ask for (or should it be told of) details about changes? 10

What Kind of Pattern is MVC? Design pattern proper? –Use it for structuring modest configurations Architectural pattern? –Use it for overall structure of a software system, defining interactions among services, browsers etc. 11

2. Adapter Pattern You have an existing client (application) that uses an old interface to an existing support package. You are given a new interface to a new support package You need to produce an adapter so that: –The client can use the new interface instead of the old one (without changing the client) 12

Illustration of Adapter Pattern Client Old package Old interface Client Adapter Old interface New package New interface 13

Implementing Adapter Pattern Using Object Composition Client Old Interface Request() New Interface SpecificRequest() Adapter Request() SpecificRequest() adaptee inherit 14

Advantages of Adapter Pattern Can change behavior of existing software without changing its source code Can be used for legacy software Do not need access to old source code 15

3. Facade Pattern A facade provides a single simplified interface to a larger part of the system (a subsystem) The facade makes this subsystem more readable and easier to understand Having facades minimizes communication and dependencies between subsystems 16

Structure of the Facade Pattern 17 Subsystem Classes Facade [Mancoridis picture]

Adapter vs. Facade An Adapter is used when the wrapper must respect a particular interface and must support a polymorphic behavior. On the other hand, a facade is used when one wants an easier or simpler interface to work with 18

4. Factory Pattern A creational pattern dealing with creating objects without knowing their concrete class It defines an interface for creating an object, but let the subclasses decide which class to instantiate Useful when concrete class of object should be decided at runtime according to parameters 19

How does it work 20 Product ProductA ProductB ProductFactory createProduct(in param) : Product Produces different subclasses of Product according to parameters inherits