a pattern
play

A Pattern Pattern Taxonomy Creational Behavioral Structural - PDF document

Podcast Ch08-15 Title : Template Design Pattern Description : Generic class diagram; examples; template vs. inheritance Participants : Barry Kurtz (instructor); Brandon Winters, Sara Hyde, Cheng Vue, Dan Baehr (students) Textbook


  1. Podcast Ch08-15 ♦ Title : Template Design Pattern ♦ Description : Generic class diagram; examples; template vs. inheritance ♦ Participants : Barry Kurtz (instructor); Brandon Winters, Sara Hyde, Cheng Vue, Dan Baehr (students) ♦ Textbook : Object-Oriented Software Engineering: Using UML, Patterns and Java by Bernd Bruegge and Allen H. Dutoit Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 1 A Pattern Pattern Taxonomy Creational Behavioral Structural Pattern Pattern Pattern Singleton Composite Iterator Decorator Abstract Factory Visitor Adapter Builder Command Factory Bridge Observer Façade Prototype Template Proxy Strategy The Template Design Pattern - 1 1

  2. The Template Design Pattern - 2 • Can you think of any other applications that could benefit from the Template design pattern? Inheritance vs Templates • Both constructs provide reuse • templates for containers/types • but inheritance can be used for type reuse via polymorphism • why have both? Examples • (1) stacks of cat objects, float objects, dog objects • (2) cat objects for different breeds, each breed eats and sleeps in its own endearing way • In 1st case, operations on objects are same, only type of object changes • in 2nd case, behavior changes with each object 2

  3. templates or inheritance ? • templates should be used to generate a collection of classes when type of object does not affect behavior • inheritance should be used for a collection of classes when type of object does affect behavior 3

Recommend


More recommend