1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp. 163-173) PH Ch 2 through Fundamentals (pp. 11-16) Presentation by Julie Betlach 5/28/2009.

Slides:



Advertisements
Similar presentations
1 Structural Design Patterns - Neeraj Ray. 2 Structural Patterns - Overview n Adapter n Bridge n Composite n Decorator.
Advertisements

ANU COMP2110 Software Design in 2003 Lecture 16Slide 1 Lecture 16: Introduction to design patterns 1What are they? 2Where do they come from? 3Why study.
CS590L - Lecture 6 1 CS590L Distributed Component Architecture References: - E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns: Elements of.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Composite Design Pattern (1) –A structural design pattern.
Fall 2009ACS-3913 Ron McFadyen Composite Pattern Problem: How do we treat a composition structure of objects the same way as a non-composite object? Arises.
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
Design Patterns In OPM Presented by: Galia Shlezinger Instructors: Prop. Dov Dori, Dr. Iris Berger.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Design Patterns CS is not simply about programming
Design Patterns Daniel McClain. Background What are they?  Way of recording solutions to recurring design problems History  “A Pattern Language: Towns,
Introduction to Design Patterns (1). “ In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software.
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.
Ralph Johnson - University of Illinois1 Patterns: What They Are, and How to Write Them Ralph Johnson University of Illinois at Urbana-Champaign
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
Software Design and Documentation Individual Presentation: Composite Pattern 9/11/03.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Design Patterns Ref : Chapter 15 Bennett et al. useful groups of collaborating classes that provide a solution to commonly occuring problems. provide.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Pattern Myths1 Ten Design Pattern Myths Jim Fawcett condensed from Pattern Hatching, John Vlissides, Addison-Wesley, 1998.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
4.4 Naming And Directory Services Lakshmi Narayana Gupta Kollepara 09/20/2009 CSC-8320.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Composite Design Pattern. Motivation – Dynamic Structure.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Composit Pattern.
1 GoF Template Method (pp ) GoF Strategy (pp ) PH Single User Protection (pp ) Presentation by Julie Betlach 6/08/2009.
Introduction to Design Patterns (1). Definition: “ In software engineering, a design pattern is a general reusable solution to a commonly occurring problem.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Advanced topics in software engineering CSC532 Term Paper Design Patterns Harpreet Singh Submitted By:-
Design Patterns in Java Chapter 1 Introduction Summary prepared by Kirk Scott 1.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Refactoring1 Improving the structure of existing code.
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.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
CSE 403, Spring 2008, Alverson Software Design “There are two ways of constructing a software design: one way is to make it so simple that there are obviously.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
Composite and Related Patterns Kirk Scott. The pitohui, a poisonous bird of New Guinea.
Structural Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
Composite Pattern ( ) Pattern Hatching Chpt 1-2 Presentation by Joe Barzilai 1/30/2006.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Design Reuse Earlier we have covered the re-usable Architectural Styles as design patterns for High-Level Design. At mid-level and low-level, design patterns.
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III.
Design Patterns Introduction “Patterns are discovered, not invented” Richard Helm.
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
Refactoring1 Improving the structure of existing code.
A proposal to support the extreme programming development methodology from the quality assurance point of view Authors: Calin Jebelean –
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Design Patterns: MORE Examples
The Object-Oriented Thought Process Chapter 15
Chapter 5:Design Patterns
Software Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns Introduction
Presentation by Julie Betlach 7/02/2009
Design Patterns A Case Study: Designing a Document Editor
Jim Fawcett CSE776 – Design Patterns Summer 2003
DESIGN PATTERNS : Introduction
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
Composite Design Pattern By Aravind Reddy Patlola.
Software Design Lecture : 36.
Presentation transcript:

1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp ) PH Ch 2 through Fundamentals (pp ) Presentation by Julie Betlach 5/28/2009

Composite Pattern – GoF pgs , PH pgs Introduction Pattern Hatching (PH) book –Intended to be a supplement to Design Patterns: Elements of Reusable Object-Oriented Software written by the Gang of Four (GoF): Gamma, Helm, Johnson, and Vlissides –Pattern Hatching book was written by Vlissides. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Top 10 Misconceptions (1) A pattern is a solution to a problem in a context. Why isn’t this true? –Patterns are applied to recurring problems (not one instance). –Patterns teach, so that the developer can tailor the solution to a variant of the problem. –Patterns have a name. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Top 10 Misconceptions (2) Patterns are just jargon, rules, programming tricks, data structures, etc. –The idea of patterns is old… experienced programmers used previous solutions on new problems. –What is new is naming them and writing them down. –One drawback (from personal experience) is to assume everyone knows the pattern. Design documentation should note the name of the design pattern used, but that shouldn’t be the extent of the documentation. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Top 10 Misconceptions (3) Seen one, seen them all. –Patterns are extremely diverse. –Don’t make assumptions about all patterns based on a few patterns. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Top 10 Misconceptions (4) Patterns need tool or methodological support to be effective. –Benefits of patterns (no tool or support needed!) Patterns capture expertise and make it accessible to non- experts. Pattern names form a vocabulary which helps developers communicate. Documenting the design with the patterns in use helps people understand the system more quickly. Patterns facilitate restructuring a system whether or not it was designed with patterns in mind. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Top 10 Misconceptions (5) Patterns guarantee reusable software, higher productivity, world peace, etc. –Patterns don’t guarantee anything. –Similar comments were made about object-oriented programming when it was introduced. (6) Patterns ‘generate’ whole architectures. –Need human creativity to know how to apply and tailor a pattern for your given problem. –Need to fill in the “white space” between the patterns. –Through teaching / discussion, patterns may support “generativity” – helping the reader solve problems that the pattern doesn’t address explicitly. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Top 10 Misconceptions (7) Patterns are for (object-oriented) design or implementation. –Patterns capture expertise, but are not limited to design and implementation. –Patterns can be found in analysis, maintenance, testing, documentation, organizational structure, etc. –Two books have been written on Analysis Patterns. –1996 conference had a submission for patterns in music composition. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Top 10 Misconceptions (8) There’s no evidence that patterns help anybody. –Improve teaching and communication. (9) The pattern community is a clique of elites. –Attendees of Pattern Languages of Programming (PLoP) conferences included analysts, designers, implementors, students, professionals, authors, even a non-computer scientist. (10) The pattern community is self-serving, even conspiratorial. –Common desire of leading pattern authors is to impart expertise, best practices, and competitive advantage to others. Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Introduction – Observations Reactions to Design Patterns –Electronic Hobbyist going back to school Terminology may be new Familiar underlying concepts –Freshman taking the same classes Material is totally new, so may be difficult to understand and appreciate Pattern Hatching Introduction – PH pgs 1-10

Composite Pattern – GoF pgs , PH pgs Composite Pattern - Intent / Applicability Intent –Compose objects into tree structures to represent part-whole hierarchies. –Clients can treat individual objects and compositions of objects uniformly. Applicability – Use Composite Pattern when… –You want to represent part-whole hierarchies of objects. –You want clients to be able to ignore the differences between compositions of objects and individual objects. Clients will treat all objects in the composite structure uniformly.

Composite Pattern – GoF pgs , PH pgs Directory / File Example – Object Structure / bin/user/tmp/ file1 file2 subdir/file3 file4 file5 Composite Leaf Directory = Composite File = Leaf

Composite Pattern – GoF pgs , PH pgs Directory / File Example – Classes One class for Files (Leaf nodes) One class for Directories (Composite nodes) –Collection of Directories and Files How do we make sure that Leaf nodes and Composite nodes can be handled uniformly? –Derive them from the same abstract base class Leaf Class: FileComposite Class: Directory

Composite Pattern – GoF pgs , PH pgs Directory / File Example – Structure Abstract Base Class: Node Leaf Class: FileComposite Class: Directory See page of Pattern Hatching Book for example code.

Composite Pattern – GoF pgs , PH pgs Directory / File Example – Operation Abstract Base Class: Node size() in bytes of entire directory and sub-directories Leaf Class: File size () of file Composite Class: Directory size () Sum of file sizes in this directory and its sub-directories long Directory::size () { long total = 0; Node* child; for (int i = 0; child = getChild(); ++i; { total += child->size(); } return total; }

Composite Pattern – GoF pgs , PH pgs Inventory Example – Problems to Consider Abstract Base Class: Inventory Item Leaf Class: Object Composite Class: Container Backpack Cloth BagJeweled Dagger RubyRingWine Bottle Do you really want all leaf Operations to be defined in Component class? Is Wine Bottle a Composite or does it have an operation for Fill(Liquid)? If Ruby is pried from Dagger, how will this be handled? Would you allow user to put other items in the wine bottle? How do you handle the relative size of items to be placed in a backpack?

Composite Pattern – GoF pgs , PH pgs Consequences Solves problem of how to code recursive hierarchical part-whole relationships. Client code is simplified. –Client code can treat primitive objects and composite objects uniformly. –Existing client code does not need changes if a new leaf or composite class is added (because client code deals with the abstract base class). Can make design overly general. –Can’t rely on type system to restrict the components of a composite. Need to use run-time checks.

Composite Pattern – GoF pgs , PH pgs Related Patterns Chain of Responsibility – Component-Parent Link Decorator – When used with composite will usually have a common parent class. So decorators will need to support the component interface with operations like: Add, Remove, GetChild. Flyweight – Lets you share components, but they can no longer reference their parents. Iterator – Can be used to traverse composites. Visitor – Localizes operations and behavior that would otherwise be distributed across composite and leaf classes.