340 likes | 556 Views
Template Method - UML. Alarm Clock Radio. Alarm Clock Radio Not Template No Inheritance Aggregation is the wrong way . Alarm Clock. Alarm Clock Radio Not a Template Multiple Inheritance. Car Builder. Car Builder Template Pattern Proper Inheritance
E N D
Alarm Clock Radio • Not Template • No Inheritance • Aggregation is the wrong way
Alarm Clock Radio • Not a Template • Multiple Inheritance
Car Builder • Template Pattern • Proper Inheritance • Primitive Operations Overloaded (BuildSkeleton, InstallEngine, InstallDoor) • BuildCar is the Template Method Template Method Primitive Operations Inheritance
Person • Template Pattern • Proper Inheritance • Primitive Operations Overloaded (washUp, eatBreakfast) • feedDog & getReadyToLeaveHouse are the Template methods • Dress is a hook Template Method Hook Primitive Operations Inheritance
Stocks • Command Pattern • Note Typo in Day section • Client – Agent • Callback Interface – placeOrder • Callback 1 & 2 – SellStockOrder& BuyStockOrder • Receiver – StockTrade v Callback Interface Client Receiver v Callback Interface
Bridge UML • Definition: Decouple an abstraction from its implementation so that the two can vary independently • Used to prevent a combinatorial explosion of classes. • If a change to one class causes multiple classes to be created, then you probably aren’t bridging properly • Just because to class hierarchies have aggregation between them doesn’t mean it’s a bridge
Questions Abstract Factory Version – Not a Bridge Observe how MC, TF, and Essay appear over and overObserve how Console, Audio, and Video appear over and over
Survey – Questions • Bridge Pattern • Abstraction – Question • Refined Abstractions – MC, Essay, TF • Implementors – Input, Output • Concrete Implementors – ConsoleInput, AudioInput, VideoInput, ConsoleOutput, AudioOutput, VideoOutput
Furniture • Bridge Pattern • Abstraction – Furniture • Refined Abstractions – Sofa, Chair, SofaBed, RecliningChair • Implementors– Material, ExternalMaterial, InternalMaterial • Concrete Implementors – Wood, Metal, Leather, Cloth
Survey – Questions • Bridge Pattern • Abstraction – Question • Refined Abstractions – MC, TF, Essay • Implementors – IO • Concrete Implementors – ConsoleIO, AudioIO, VideoIO
Shapes • Not a Bridge Pattern • This is simply aggregation of a color into a Shape
Shapes • Bridge Pattern • Abstraction – Shape • Refined Abstractions – Triangle, Square, Pentagon • Implementor– DrawingProgram • Concrete Implementors – AutoCad, Anvil
Furniture • Not a Bridge pattern, Simple aggregation • both sofa and chair consist of legs, arms, and seat. If it is a bridge, then the left side should be legs, arm, seat, and the right side should be logs, fabric, etc that implements the legs and arms.
Animals • Not a Bridge, really a strategy • The problem is that the right side (strategy) doesn't compose parts of the left side.