200 likes | 215 Views
Chapter 21 Design Patterns Reviewed from the New Perspective of Object-Oriented Design. Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University. Outline. A Summary of Object-Oriented Principles
E N D
Chapter 21Design Patterns Reviewedfrom the New Perspective of Object-Oriented Design Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
A Summary ofObject-Oriented Principles • Objects are things with well-defined responsibilities. • Objects are responsible for themselves. • Encapsulation means any kind of hiding • Data hiding • Class hiding • Implementation hiding • Abstract out variations in behavior and data with commonality/variability analysis. • Design to interfaces. Design Patterns Reviewed
A Summary ofObject-Oriented Principles • Think of inheritance as a method of conceptualizing variation, not for making special cases of existing objects. • Keep variations in a class decoupled from other variations in the class. • Strive for loose coupling. • Strive for high cohesion. • Be absolutely meticulous in applying the once and only once rule Design Patterns Reviewed
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
How Design PatternsEncapsulate Implementations • Most patterns described by GoF • Give ways to hide specific implementations • Allow for easily adding new implementations Design Patterns Reviewed
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
Commonality/Variability Analysis and Design Patterns • An example • Draw a square with drawing program one • Draw a circle with drawing program two • Draw a rectangle with drawing program one • Tow commonalities • Drawing programs • Shapes to draw • Patterns • Provide the backdrop in analysis and design • Give a common vocabulary for discussion • Incorporate best-practice approaches into your code Design Patterns Reviewed
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
Decomposing a Problem Domain into Responsibilities • In the Bridge pattern • Problem domain composed of two different types of entities • Abstractions • Implementations • Decompose the problem domain • Objects • Which objects are needed • Responsibilities • How these objects are instantiated Design Patterns Reviewed
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
Relationships Within a Pattern • Alexander • At this final stage, the patterns are no longer important. • Shalloway • The patterns have taught your to be receptive to what is real. • Relationships and forces described by the patterns • It is not the patterns themselves that are important Design Patterns Reviewed
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
Patterns and Contextual Design • Patterns are microcosmic examples of contextual design • Designing to an interface is designing within a context Design Patterns Reviewed
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
Field Notes • What implementations does this pattern hide? • Allow for changing them • What commonalities are present in this pattern? • Identify them • What are the responsibilities of the objects in this pattern? • Easier to do my decomposition by responsibility Design Patterns Reviewed
Field Notes • What are the relationships between these objects? • More information about the forces • How may the pattern itself be a microcosmic example of designing by context • A better understanding of why the pattern is good design Design Patterns Reviewed
Outline • A Summary of Object-Oriented Principles • How Design Patterns Encapsulate Implementations • Commonality/Variability Analysis and Design Patterns • Decomposing a Problem Domain into Responsibilities • Relationships Within a Pattern • Patterns and Contextual Design • Field Notes • Summary Design Patterns Reviewed
Summary • Look at patterns by seeing • What they encapsulate • How they use commonality/variability analysis • How they decompose a problem domain into responsibilities • How they specify relationships between objects • How they illustrate contextual design Design Patterns Reviewed