patterns
play

Patterns 2020/4/12 Structural Design Patterns Creational - PowerPoint PPT Presentation

Poly- mor- phism Abstra ction Class OOP Inheri -tance En- capsu- lation Structural Design Kuan-Ting Lai Patterns 2020/4/12 Structural Design Patterns Creational Structural Behavioral Design Patterns Design Patterns Design


  1. Poly- mor- phism Abstra ction Class OOP Inheri -tance En- capsu- lation Structural Design Kuan-Ting Lai Patterns 2020/4/12

  2. Structural Design Patterns Creational Structural Behavioral Design Patterns Design Patterns Design Patterns Initialize objects Compose Communication or create new objects to get between objects classes new functions

  3. Structural Design Patterns • Adapter • Bridge • Composite • Decorator • Façade • Flyweight • Proxy

  4. Adapter Pattern

  5. Adapter • Adapter works as a bridge between two incompatible interfaces • Object adaptor • Class adaptor

  6. Inheritance vs. Composition

  7. Object Adaptor • Client Interface describes a protocol that other classes must follow • Adapter is a class that implements the client interface and composite a service object

  8. Class Adaptor • Inherit from both client and service class

  9. Example: MediaPlayer https://www.tutorialspoint.com/design_pattern/adapter_pattern.htm

  10. Bridge Pattern • Split a large class into two separate hierarchies: abstraction and implementation

  11. Bridge Example: Colorful Shapes

  12. Separating Shape and Color • The Bridge pattern attempts to solve this problem by switching from inheritance to composition

  13. Using Composition to Implement New Function

  14. Composite Pattern • Compose objects into a tree structure

  15. Document Structure • Recursive composition of text and graphics

  16. Composite Pattern

  17. Composite Structure • Component interface describes operations that are common to both simple and complex elements of the tree • Leaf is a basic element without sub-elements • Container (aka composite ) is an element that has sub-elements

  18. Decorator • Attach new behaviors to objects by placing these objects

  19. Embellishing the User Interface (Decorator) • Decorator Pattern: support embellishment by transparent enclosure

  20. FACADE

  21. FACADE • Define a new interface for existing many objects

  22. FLYWEIGHT • Fit more objects into RAM by sharing common parts of state between multiple objects

  23. Example: Game Displaying

  24. Proxy

  25. Proxy Structure • Lazy initialization • Access control • Local execution of a remote service • Logging requests • Caching results • Garbage collection

  26. Example: Internet Proxy https://www.javatpoint.com/proxy-pattern

  27. References • Alexander Shvets, “Dive into Design Patterns,” 2018 • https://www.tutorialspoint.com/design_pattern/index.htm • https://www.javatpoint.com/design-patterns-in-java • https://www.startertutorials.com/patterns/select-design- pattern.html

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend