D ESIGN P ATTERNS Weslei A. de T. Marinho. T ALK O UTLINE Pattern Definition GRASP Patterns GoF Patterns GoF Patterns Classification Creational Patterns.

Slides:



Advertisements
Similar presentations
GRASP: Designing Objects with Responsibilities
Advertisements

(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns CS is not simply about programming
Ralph Johnson - University of Illinois1 Patterns: What They Are, and How to Write Them Ralph Johnson University of Illinois at Urbana-Champaign
Fall 2009ACS-3913 Ron McFadyen1 idea was first put forth by Christopher Alexander (1977) in his work on architectural design principles a pattern is a.
(c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.
GRASP : Designing Objects with Responsibilities
Design Patterns and Responsibility Assignment CMPT 371 Fall 2004 J.W. Benham.
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
Fall 2009ACS-3913 Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Date: 1753 an interpretation.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
GRASP Design Patterns: Designing Objects with Responsibilities
Introduction to software design patterns For CSE 3902 By: Matt Boggus.
Design Patterns Trends and Case Study John Hurst June 2005.
Chapter 7 GRASP patterns Dr Seham Mostefai CAP 252.
Design Patterns.
GRASP Principles. How to Design Objects The hard step: moving from analysis to design How to do it? –Design principles (Larman: “patterns”) – an attempt.
Patterns 1 Patterns in OO - history 77 - Work of the architect Christopher Alexander 80s - Kent Beck playing with Smalltalk 91 - Gamma’s PhD thesis on.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Chapter 17. GRASP General Responsibility Assignment Software Patterns (Principles) OOD: after identifying requirements, create domain model, define responsiblities.
1 Chapter 17 GRASP Design Patterns: Designing Objects with Responsibilities.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Architecture GRASP Realization of use cases in interaction diagrams Design class diagram Design ( how )
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
D ESIGN P ATTERNS Breno Batista Machado Weslei A. de T. Marinho.
BTS430 Systems Analysis and Design using UML Design Patterns.
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
CS 325: Software Engineering February 12, 2015 Applying Responsibility-Assignment Patterns Design Patterns Situation-Specific Patterns Responsibility-Assignment.
Chapter 17 GRASP: Designing Objects with Responsibilities. 1CS6359 Fall 2011 John Cole.
Design Patterns. Patterns “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution.
Y2 eProjects Session 4 – Advanced Topics. Objectives  Dynamic Models  Design Patterns (Optional)  Software testing (for S4) ACCP i7.1\Sem3_4\eProject\T4.
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
GRASP: Designing Objects with Responsibilities
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
IntellAgile Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
ECE450S – Software Engineering II
CSC 480 Software Engineering Design With Patterns.
Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Patterns Roberto Damiani Mendes. Roteiro Definition; Definition; Architecture Patterns; Architecture Patterns; Design Patterns; Design Patterns; GRASP.
Advanced Object-Oriented Design Patterns and Architectures Part One COEN396A John Xiao
Design Patterns Introduction
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
References: Applying UML and patterns Craig Larman
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
General Principles in Assigning Responsibilities Responsibilities Responsibility-Driven Design CRC Cards GRASP.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
TK2023 Object-Oriented Software Engineering CHAPTER 13d GRASP Patterns: High Cohesion.
TK2023 Object-Oriented Software Engineering
GRASP – Designing Objects with Responsibilities
Design Patterns: MORE Examples
Software Design Patterns
Introduction to Design Patterns
Design Patterns Lecture part 2.
Design Patterns Introduction
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
Presented by Igor Ivković
GRASP : Designing Objects with Responsibilities
Informatics 122 Software Design II
Patterns.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Informatics 122 Software Design II
Chapter 8, Design Patterns Introduction
Presented by Igor Ivković
Presentation transcript:

D ESIGN P ATTERNS Weslei A. de T. Marinho

T ALK O UTLINE Pattern Definition GRASP Patterns GoF Patterns GoF Patterns Classification Creational Patterns Structural Patterns

W HAT IS A P ATTERN ? "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice“ (Christopher Alexander)

W HAT IS A P ATTERN ? “Pattern is a named and well-known problem/solution pair that can be applied in new contexts, with advice on how to apply it in novel situations and discussion of its trade-offs, implementations, variations, and so forth.” (Craig Larman)

W HY USE P ATTERNS ? A pattern addresses a recurring design problem that arises in specific design situations, and presents a solution to it. Patterns document existing, well-proven design experience. Patterns identify and specify abstractions that are above the level of single classes and instances, or of components. Patterns provide a common vocabulary and understanding for design principles Patterns are a means of documenting software architectures.

W HY USE P ATTERNS ? Patterns support the construction of software with defined properties. Patterns help you build complex and heterogeneous software architectures. Patterns help you to manage software complexity.

T YPES OF P ATTERNS GRASP Patterns Architectural Patterns Design Patterns Idioms … E.g.: Usability Patterns Anti-Patterns

B ASIC P ATTERN M ETAMODEL Problem Solution Consequence Pattern name *

G O F P ATTERN M ETAMODEL Pattern name classification Intent Motivation (ExampleScenario) Applicability (Problem) * * Structure (SolutionGraphicalDescription) * BehavioralStructure (Collaboration) StaticStructure ClassDiagram ObjectDiagram Participant * Issues * Implementation Issue Consequence SampleCode * ExampleDomain * * relPatterns A.K.A

GRASP P ATTERNS GRASP stands for General Responsibility Assignment Software Pattern Will be presented the following GRASP Patterns: – Information Expert – Creator – Low Coupling – High Cohesion

C REATOR Name:Creator Problem:Who creates an A? Solution: (this can be viewed as advice) Assign class B the responsibility to create an instance of class A if one of these is true (the more the better): B "contains" or compositely aggregates A. B records A. B closely uses A. B has the initializing data for A. B is a creator of A objects. If more than one option applies, usually prefer a class B which aggregates or contains class A.

C REATOR – W HO CREATES THE S QUARE ?

I NFORMATION E XPERT Name:Information Expert Problem:What is a basic principle by which to assign responsibilities to objects? Solution: (advice)Assign a responsibility to the class that has the information needed to fulfill it. Problem: Who knows about a Square object, given a key?

I NFORMATION E XPERT How to distribute the responsibilities for obtain the sale’s total?

L OW C OUPLING Name:Low Coupling Problem:How to reduce the impact of change? Solution: (advice)Assign responsibilities so that (unnecessary) coupling remains low. Use this principle to evaluate alternatives. Given following classes: What is better for a makePayment design? A: B: In practice, the level of coupling alone can't be considered in isolation from other principles such as Expert and High Cohesion. Nevertheless, it is one factor to consider in improving a design.

H IGH C OHESION Name:High Cohesion Problem:How to keep objects focused, understandable, and manageable, and as a side effect, support Low Coupling? Solution: (advice)Assign responsibilities so that cohesion remains high. Use this to evaluate alternatives.

H IGH C OHESION Low cohesion implies on code: Hard to comprehend Hard to reuse Hard to maintain Delicate; constantly affected by change In practice, the level of cohesion alone can't be considered in isolation from other responsibilities and other principles such as Expert and Low Coupling.

G O F P ATTERNS C LASSIFICATION Table 1: Design pattern space Purpose CreationalStructuralBehavioral Scope Class Factory MethodAdapterInterpreter Template Method Object Abstract FactoryAdapterChain of Responsibility BuilderBridgeCommand PrototypeCompositeIterator SingletonDecoratorMediator FacadeMemento ProxyFlyweight Observer State Strategy Visitor

A BSTRACT F ACTORY Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Also Knows As: Kit

A BSTRACT F ACTORY - M OTIVATION

A BSTRACT F ACTORY - S TRUCTURE

B UILDER Intent: Separate the construction of a complex object from its representation so that the same construction process can create different representations.

B UILDER

S IGLETON Intent: Ensure a class only has one instance, and provide a global point of access to it.

S INGLETON

A DAPTER

F ACADE Intent: Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

F ACADE

Don’t ask!!!

B IBLIOGRAPHY Freeman, E., Sierra, K., Bates, B Head First Design Patterns. O’Reilly Media, Inc. Gamma, E., Helm, R., Johnson, R., Vlissides, J Design Patterns Elements of Reusable Object-Oriented Software. Addison-Wesley Pub Co. Larman, C Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, Third Edition. Pearson Education, Inc. Schmidt, D., Stal, M., Rohnert, H., Buschmann, F PATTERN-ORIENTED SOFTWARE ARCHITECTURE VOLUME 1: A System of Patterns. John Wiley & Sons Ltd.