1 / 30

Template Method - UML

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

lark
Download Presentation

Template Method - UML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Template Method - UML

  2. Alarm Clock Radio

  3. Alarm Clock Radio • Not Template • No Inheritance • Aggregation is the wrong way

  4. Alarm Clock

  5. Alarm Clock Radio • Not a Template • Multiple Inheritance

  6. Car Builder

  7. Car Builder • Template Pattern • Proper Inheritance • Primitive Operations Overloaded (BuildSkeleton, InstallEngine, InstallDoor) • BuildCar is the Template Method Template Method Primitive Operations Inheritance

  8. Person

  9. 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

  10. Command Pattern – UML

  11. Stocks

  12. 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

  13. Bridge UML

  14. 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

  15. Questions

  16. 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

  17. Survey - Questions

  18. Survey – Questions • Bridge Pattern • Abstraction – Question • Refined Abstractions – MC, Essay, TF • Implementors – Input, Output • Concrete Implementors – ConsoleInput, AudioInput, VideoInput, ConsoleOutput, AudioOutput, VideoOutput

  19. Furniture

  20. Furniture • Bridge Pattern • Abstraction – Furniture • Refined Abstractions – Sofa, Chair, SofaBed, RecliningChair • Implementors– Material, ExternalMaterial, InternalMaterial • Concrete Implementors – Wood, Metal, Leather, Cloth

  21. Survey – Questions - Bridge

  22. Survey – Questions • Bridge Pattern • Abstraction – Question • Refined Abstractions – MC, TF, Essay • Implementors – IO • Concrete Implementors – ConsoleIO, AudioIO, VideoIO

  23. Shapes

  24. Shapes • Not a Bridge Pattern • This is simply aggregation of a color into a Shape

  25. Shapes

  26. Shapes • Bridge Pattern • Abstraction – Shape • Refined Abstractions – Triangle, Square, Pentagon • Implementor– DrawingProgram • Concrete Implementors – AutoCad, Anvil

  27. Furniture

  28. 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.

  29. Animals

  30. Animals • Not a Bridge, really a strategy • The problem is that the right side (strategy) doesn't  compose parts of the left side. 

More Related