A Pattern Pattern Taxonomy Creational Behavioral Structural - - PDF document

a pattern
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

1

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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

A Pattern Taxonomy

Pattern Structural Pattern Behavioral Pattern Creational Pattern Composite Decorator Adapter Bridge Façade Proxy Iterator Visitor Command Observer Template Strategy Singleton Abstract Factory Builder Factory Prototype

The Template Design Pattern - 1

slide-2
SLIDE 2

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
  • bjects
  • (2) cat objects for different breeds, each breed

eats and sleeps in its own endearing way

  • In 1st case, operations on objects are same,
  • nly type of object changes
  • in 2nd case, behavior changes with each object
slide-3
SLIDE 3

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