1 4/97 Object-Oriented Design Workshop Week 6: Some Patterns for Implementing Associations, Part 1 David Van Camp Object Technology Consultant Software.

Slides:



Advertisements
Similar presentations
Pointers.
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
JDBC Session 4 Tonight: Design Patterns 1.Introduction To Design Patterns 2.The Factory Pattern 3.The Facade Pattern Thursday & Next Tuesday: Data Access.
Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Reza Gorgan Mohammadi AmirKabir University of Technology, Department of Computer Engineering & Information Technology Advanced design.
Observer Pattern Fall 2005 OOPD John Anthony. What is a Pattern? “Each pattern describes a problem which occurs over and over again in our environment,
Delegates & Events Observer and Strategy Patterns Game Design Experience Professor Jim Whitehead January 30, 2009 Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0.
Lists 4 Introduction to Lists 4 Linear Lists 4 Adding and Deleting in linear Lists 4 Linked Lists 4 Pointers in Linked Lists 4 Inserting into a Linked.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Guide To UNIX Using Linux Third Edition
ASP.NET Programming with C# and SQL Server First Edition
Reuse Activities Selecting Design Patterns and Components
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Client/Server Software Architectures Yonglei Tao.
The Design Discipline.
Programming Languages and Paradigms Object-Oriented Programming.
Design Patterns.
02 - Behavioral Design Patterns – 2 Moshe Fresko Bar-Ilan University תשס"ח 2008.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Reactor Design Patterns: Command and Observer.
Overloading Binary Operators Two ways to overload –As a member function of a class –As a friend function As member functions –General syntax Data Structures.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Software Design 1.1 Tapestry classes -> STL l What’s the difference between tvector and vector  Safety and the kitchen sink What happens with t[21] on.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Where Do Surrogates Fit into This Proxy Pattern Observer Pattern Visitor Pattern By Kurt Rehwinkel.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Factory Method Explained. Intent  Define an interface for creating an object, but let subclasses decide which class to instantiate.  Factory Method.
Relationships Relationships between objects and between classes.
Proxy, Observer, Symbolic Links Rebecca Chernoff.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Strategy Pattern.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
OO Methodology Elaboration Iteration 2 - Design Patterns -
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
Java EE Patterns Dan Bugariu.  What is Java EE ?  What is a Pattern ?
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
The Mediator Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
The State Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
From C++ to C# Part 5. Enums Similar to C++ Similar to C++ Read up section 1.10 of Spec. Read up section 1.10 of Spec.
About the Author A Lifetime of Software Development Started Writing Code at Age 11 Programming Summer Camp at Age 12 Writing Code Ever Since At Age 25,
March 1, 2004CS WPI1 CS 509 Design of Software Systems Lecture #6 Monday, March 1, 2004.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
CSSE 375 Organizing Data – Part 1 Shawn and Steve Q1.
Behavioural Patterns GoF pg Iterator GoF pg. 257 – 271 Memento GoF pg By: Dan Sibbernsen.
The Chain of Responsibility Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Unit 1 - Introducing Abstract Data Type (ADT) Part 1.
6.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Templates Linked Lists.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Patterns An Easier Way to Think About Common Software Designs This presentation is licensed under a Creative Commons License.
Linked List ADT used to store information in a list
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
GoF Patterns (GoF) popo.
MPCS – Advanced java Programming
By SmartBoard team Adapter pattern.
Parameter Passing Actual vs formal parameters
GoF Patterns Ch. 26.
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Presentation transcript:

1 4/97 Object-Oriented Design Workshop Week 6: Some Patterns for Implementing Associations, Part 1 David Van Camp Object Technology Consultant Software Architects P.O. Box 3104, Collegedale, TN Phone: (301)

2 4/97  Topics of this Workshop: –Relationship Attribute –Relationship Objects: Week 6: Some Patterns for Implementing Associations, Part 1 O-O Design Workshop  Attribute Object  Collection Object  Mutual Friends  Master and Slaves  Sender Argument  Null Object  Timed Relationship  Connected Group

3 Some Patterns for Implementing Associations  This presentation is based on the paper: –“Some Patterns for Relationships”, James Noble, MRI, School of MPCE, Macquarie University, Sydney.  Available on the web from:

4 The Relatonship Patterns Null Object Relationship Attribute Relationship Objects Attribute Object Collection Objects Mutual Friends Master & Slaves Connected Group Timed Relationship Patterns Discussed in Today’s Presentation Patterns to be Discussed Next Week

5 Relationship Attribute How can you add a simple relationship?  Declare a reference or pointer variable –May be single reference or an array –Simplest and often the only solution directly supported by most languages class myclass { anotherclass * relationship; void makerelationship ( void ) { relationship = new anotherclass; }

6 Relationship Object “How can you model a big, important or common relationship”  Make a Relationship Object: –The Relationship Object encapsulates an indirect relation between a multiple objects –More flexible than Relationship Attributes, but also more complex and harder to implement –Requires adding special implementation objects to a design and may reduce efficiency

7 Relationship Object  Many kinds of Relationship Objects are possible:  Attribute Object  Collection Object  Mutual Friends  Master and Slaves  Sender Argument  Null Object  Timed Relationship  Connected Group Client ref Relationship Object ref Related Object

8 Attribute Object “How do you model an important one-to-one relationship?”  Make an Attribute Object –Generally AttributeObject has a single Relationship Attribute and provides methods for accessing the related object –Decouples association between a client and its related object, thus providing a looser binding –Increases overhead & memory usage

9 Attribute Object  Examples: –Object Adapter in GOF Patterns Catalog (pg. 139) –GOF Observer can be used to link Attribute Objects for syncronized updates  Attribute Objects often form a Connected Group (discussed in Part 2) Client ref Attribute Object ref DoOperation Related Object DoService ref

10 Collecton Object “How do you model a one-to-many relationship?”  Make a Collection Object: –Usually encapsulates a linked list or queue –May be ordered or unordered –Usually used to implement uni-directional relationships –Most common form of Relationship Object

11 Collection Objects  Examples: –Many collection classes are provided in C++ by  RougeWave Tools.h  Standard Template Library (STL) –Arrays of Relationship Attributes may be used to form more limited collections Client ref Collection Object ref Related Object

12 Mutual Friends “How can you represent an important bidirectional relationship?”  Use Mutual Friends: –Represent relationships as a series of separate unidirectional relationships –Carefully keep all relationships syncronized –Simplist case uses two unidirectional Master and Slaves relationships for each related object –Bidirectional relationships may use a Collection Object for the relationship from the Client

13 Mutual Friends  Consequences –Increases coupling between objects, making design less flexible –Difficult to implement because of need for syncronization –Sender Argument can be used to increase flexibility and simplify overhead Client ref Collection Object Related Object

14 Master and Slaves “How can you manage a relationship?”  Create a Master which manages Slaves: –Master controls all access to and maintains Slave objects –Master often creates and destroys Slaves –Simpler to design and implement than cooperating relationships Client ref Master Object ref Slave Object

15 Sender Argument “How can an object identify itself to other participating objects?”  Pass a reference via a Sender Argument: –When the Sender calls a function in an other object, include a reference or pointer to the Sender as a function parameter:  someobject.doSomething (this); –The Reciever may use this for short-term localized processing, or store the reference for future access

16 Sender Argument  Consequences –Makes designs very flexible and enhanceable, particularly if Reciever does not maintain reference to Sender Sender Action Callback Reciever doSomething (Sender & target) ref ref.doSomething (*this);... target.Callback();...

17 Complex Relationships  Next Week in Part 2: –Null Object –Timed Relationship –Connected Group –A closer look a Relationship Attributes