D ESIGN P ATTERNS Vasanth Raja Chittampally

Slides:



Advertisements
Similar presentations
Design Patterns CMPS Design Patterns Consider previous solutions to problems similar to any new problem ▫ must have some characteristics in common.
Advertisements

OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Composite Design Pattern (1) –A structural design pattern.
March Ron McFadyen1 Composite Used to compose objects into tree structures to represent part-whole hierarchies Composite lets clients treat.
Plab – Tirgul 12 Design Patterns
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.
UML – Class Diagrams.
The Composite Pattern. Owners (No Twins, Expos) Managers (No Twins, Expos) Congress (No Twins, Expos) Media (No Twins, Expos) Radio (No Twins, Expos)
03/12/2001 © Bennett, McRobb and Farmer 2002 Refining the Requirements Model Based on Chapter 8 of Bennett, McRobb and Farmer: Object Oriented Systems.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 2: Abstract classes and composite structures Topics: –Elaboration of.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Lecture a: Additional UML Models: Package, Activity, Deployment Lecture b: Generalization, Aggregation and Additional Domain Model Notation Copyright W.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
Introduction to software design patterns For CSE 3902 By: Matt Boggus.
1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp ) PH Ch 2 through Fundamentals (pp ) Presentation by Julie Betlach 5/28/2009.
 2008 Pearson Education, Inc. All rights reserved (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements.
Composite Design Pattern. Motivation – Dynamic Structure.
Refining the Requirements Model
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Composit Pattern.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
Created on 29/10/2008yahaya.wordpress.com1 Trees Another common nonlinear data structure is the tree. We have already seen an example of a tree when we.
Chapter 1 Program Development Asserting Java © Rick Mercer.
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
03/12/2001 © Bennett, McRobb and Farmer 2005 Refining the Requirements Model Based on Chapter 8 of Bennett, McRobb and Farmer: Object Oriented Systems.
03/12/2001 © Bennett, McRobb and Farmer 2002 Refining the Requirements Model Based on Chapter 8 of Bennett, McRobb and Farmer: Object Oriented Systems.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
ECE450S – Software Engineering II
Design Patterns Yonglei Tao. Design Patterns  A design pattern describes a recurring design problem, a solution, and the context in which that solution.
CSC 480 Software Engineering Design With Patterns.
Composite and Related Patterns Kirk Scott. The pitohui, a poisonous bird of New Guinea.
Composite Pattern ( ) Pattern Hatching Chpt 1-2 Presentation by Joe Barzilai 1/30/2006.
Patterns Roberto Damiani Mendes. Roteiro Definition; Definition; Architecture Patterns; Architecture Patterns; Design Patterns; Design Patterns; GRASP.
Design Patterns References: Xiaoping Jia, Object-Oriented Software Development Using Java;Douglas C.Schmidt, Design Pattern Case Studies with C++
Design Patterns Introduction
Patterns Composite Pattern. Patterns All designers use patterns. Patterns in solutions come from patterns in problems. "A pattern is a solution to a problem.
MedBiquitous XML Design Patterns Rachel Ellaway 1, Valerie Smothers 2, Joel Farrell 3, Daniel Rehak 1 Northern Ontario School of Medicine, 2 MedBiquitous,
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
Software Design Patterns in Test Automation
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
Software Modelling Class Diagram. Class Diagrams The main building block in object oriented modeling They are used both for general conceptual modeling.
Composite Pattern Himanshu Gupta Shashank Hegde CSE776 – Design Patterns Fall 2011 Good composition is like a suspension bridge - each line adds strength.
Design Patterns: Brief Examples
Object-Oriented Modeling
UML Class Diagrams (more notation)
CS 5010 Program Design Paradigms “Bootcamp” Lesson 5.1
Composite Design Pattern
Iterator and Composite Design Patterns
Jim Fawcett CSE776 – Design Patterns Summer 2003
Software Engineering Lecture #11.
Tree A tree is a data structure in which each node is comprised of some data as well as node pointers to child nodes
Beta Release Retrospective
CSC 480 Software Engineering
Introduction to Design Patterns
CSC 143 Java Trees.
More examples of invariants
Software Design Lecture : 35.
CSC 480 Software Engineering
Composite Design Pattern By Aravind Reddy Patlola.
Refining the Requirements Model
Software Design Lecture : 36.
Presentation transcript:

D ESIGN P ATTERNS Vasanth Raja Chittampally

W HAT IS A D ESIGN P ATTERN ? Christopher Alexander says, “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”. Briefly: Pattern is a solution to a problem in Context.

C OMPOSITE Compose objects into tree structures to represent “part-whole” hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly The Composite pattern describes how to use recursive composition so that clients don't have to make this distinction. In UML, composition is depicted as a filled diamond and a solid lineUML

A GGREGATION VS COMPOSITION Aggregation doesn’t impose the restriction that the “ Part ” object to be destroyed after the “ Whole ” is destroyed which is the case with composition The more general form, aggregation, is depicted as an unfilled diamond and a solid lineaggregation Composition Aggregation

E XAMPLE

E XAMPLE (2)

A PPLICABILITY Use the Composite pattern when (i) you want to represent part-whole hierarchies of objects. (ii) you want clients to be able to ignore the difference between compositions of objects and individual objects. Clients will treat all objects in the composite structure uniformly.

J AVA E XAMPLE Use Composition or aggregation when you can find “has-a” between objects To use composition in Java, you use instance variables of one object to hold references to other objects The has-a relationship doesn't mean that the containing object must have a constituent object at all times, but that the containing object may have a constituent object at some time

C OMPOSITION EXAMPLE public class A { private B b = new B(); public A() { } } class B { public B() { }

A GGREGATION EXAMPLE public class A { private B b; public A( B b ) { this.b = b; } } public class C { private B b = new B(); public C() { A a = new A( this.b ); } }

R ECURSIVE COMPOSITION Objects can be composited recursively with the use of recursive types or references. Consider a tree. Each node in a tree may be a branch or leaf; in other words, each node is a tree at the same time when it belongs to another tree.recursive typesreferences One implementation for the recursive composition is to let each object have references to others of the same type. In C, for example, a binary tree can be defined like: struct bintree { struct bintree *left, *right; // some data };

Q UERIES ???

Thank You Vasanth Raja Chittampally