object-Oriented Software Engineering Practical Software development using uml and Java Chapter 6: sing Design Patterns www.oseng.com
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns
6.1 Introduction to patterns The recurring aspects of designs are called designpatterns. a pattern is the outline of a reusable solution to a general problem encountered in a particular context Many of them have been systematically documented for all software developers to use A good pattern should be as general as possible -Contain a solution that has been proven to effectively solve the problem in the indicated context Studying patterns is an effective way to learn from the experience of others www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 2 6.1 Introduction to Patterns The recurring aspects of designs are called design patterns. • A pattern is the outline of a reusable solution to a general problem encountered in a particular context • Many of them have been systematically documented for all software developersto use • A good pattern should —Be as general as possible —Contain a solution that has been proven to effectively solve the problemin the indicated context. Studying patterns is an effective way to learn from the experience of others
Pattern description Context: The general situation in which the pattern applies Proble a short sentence or two raising the main difficulty Forces The issues or concerns to consider when solving the problem Solution The recommended way to solve the problem in the given context ‘ to balance the forces Antipatterns: (Optional) Solutions that are inferior or do not work in this context Related patterns: (Optional) Patterns that are similar to this pattern References Who developed or inspired the pattern www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 3 Pattern description Context: • The general situation in which the pattern applies Problem: —A shortsentence or two raising the main difficulty. Forces: • The issues or concernsto consider when solving the problem Solution: • The recommended way to solve the problemin the given context. —‘to balance the forces’ Antipatterns:(Optional) • Solutionsthat are inferior or do not work in this context. Related patterns: (Optional) • Patternsthat are similar to this pattern. References: • Who developed or inspired the pattern
6.2 The Abstraction-Occurrence pattern · Context -Often in a domain model you find a set of related objects occurrences -The members of such a set share common information but also differ from each other in important ways · Problen what is the best way to represent such sets of occurrences in a class diagram · Forces You want to represent the members of each set of occurrences without duplicating the common information www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns 4
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 4 6.2 The Abstraction-Occurrence Pattern • Context: —Often in a domain model you find a set of related objects (occurrences). —The members of such a set share common information - but also differ from each other in important ways. • Problem: —What is the best way to represent such sets of occurrences in a class diagram? • Forces: —You want to represent the members of each set of occurrences without duplicating the common information
Abstraction-Occurrence Solution Abstraction》 Occurrence》 TVSeries Episode series Name number producer title story Synopsis Title Librarylter barCode Number author publicationDate libofCongress www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 5 Abstraction-Occurrence • Solution: TVSeries seriesName producer Episode number title storySynopsis * «Abstraction» «Occurrence» * Title name author LibraryItem barCodeNumber * isbn publicationDate libOfCongress