1 / 20

Design Patterns

Design Patterns. Removing Pain From Design. Erik Peterson John Pharo. Ducks!. Interfaces. Interface Segregation Principle. What about other birds?. Adapter Pattern. Translates the interface of a class into one that clients expect. What the flock?.

kirsi
Download Presentation

Design Patterns

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. Design Patterns Removing Pain From Design Erik Peterson John Pharo

  2. Ducks!

  3. Interfaces Interface Segregation Principle

  4. What about other birds?

  5. Adapter Pattern Translates the interface of a class into one that clients expect

  6. What the flock? Now we need a way to count all of these birds…

  7. DecoratorPattern Allows additional behavior to be added to a class dynamically

  8. How to build a duck • Now we have two types: • Quackable • Countable

  9. Factories Encapsulate object creation

  10. Abstract FactoryPattern Used to represent a group of factories that can create a common element

  11. About that flock… We need a way to go through the flock and check up on each bird, but how?

  12. IteratorPattern Encapsulates how to navigate an aggregate sequentially without exposing its internal structure

  13. Another way of changing behavior Different ducks behave in different ways Some might even migrate to different locales in the winter!

  14. Template MethodPattern Allows an inherited class to change the behavior on a base class by implementing an abstract (or virtual) method on the base

  15. Our ducks are hungry!

  16. CommandPattern Encapsulates requests, allowing the consumer to take in different types, as well as support redo/undo functionality

  17. CommandPattern Three types of objects are involved: Command – implements an interface for executing an operation, and links a receiver to an action Receiver – knows how to perform the actual action Invoker – tells command to carry out the request

  18. Feeding the Ducks The Command Pattern Way • Command – FoodProvider – takes in the receiver (a dispenser), which knows how to dispense food • Receiver – CornDispenser – does actual dispensing of food • Invoker – DuckFeeder – allows setting of the command, and calls execute on it

  19. Buy this book!

  20. Me: cerikpete@gmail.com http://erikbase.blogspot.com

More Related