1 / 19

Object Oriented Design Patterns Continuous Assessment 2

Prototype + Factory. Object Oriented Design Patterns Continuous Assessment 2. Summary of Problems and Solutions. Prototype. Detailed Presentation of most interesting problem. Problem. Concrete StoreObject creation ( DrinkBrand and Coin ) logic are wrapped inside PropertyLoader .

kiora
Download Presentation

Object Oriented Design Patterns Continuous Assessment 2

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. Prototype + Factory Object Oriented Design Patterns Continuous Assessment 2

  2. Summary of Problems and Solutions

  3. Prototype Detailed Presentation of most interesting problem

  4. Problem • Concrete StoreObjectcreation (DrinkBrand and Coin) logic are wrapped inside PropertyLoader. • Inflexibility in creation logic. • Accommodating new kinds of StoreObjectsis difficult. • If the current file based database is changed to other persistent mechanisms, then the entire logic behind creation needs to be re-written.

  5. Caveats • While we are aware that problems exist among the following areas, those are not addressed in the current solution • Two different property loaders still exist. • StoreItem objects are still constructed from property loaders

  6. Analysis of problem • Creational and initialization logic for an object exists outside of the object. • This is a CREATIONAL problem

  7. Candidate Design Patterns • Prototype • Specify the kinds of objects to create using a prototypical instance and create new objects by copying this prototype. • Factory method • Define an interface for creating an object, but let subclasses decide which class to instantiate. • Abstract Factory • Provide an interface for creating families of related or dependent objects without specifying their concrete classes

  8. Abstract Factory applicability • The system should be independent of how its products are created, composed andrepresented • The system should be configured with one of multiple families of products • A family of related product objects is designed to be used together and you need to enforce this constraint ✔ ✗ ✗

  9. Factory method applicability • A class can’t anticipate the class of objects it must create • A class wants its subclasses to specify the object it creates • Classes delegate responsibility to one of several helper subclasses and you want to localize the knowledge of which helper class to delegate ✗ ✗ ✗

  10. Prototype applicability • The system should be independent of how its products are created, composed and represented • The classes to instantiate are specified at runtime • Avoid building a class hierarchy of factories that parallels the class hierarchy of products ✔ ✔ ✔

  11. Initialize CashStore

  12. Initialize DrinkStore

  13. Static View – Status quo

  14. Problems come in bunches - revisit • Concrete StoreObjectcreation (DrinkBrand and Coin) logic are wrapped inside PropertyLoader. • Inflexibility in creation logic. • Accommodating new kinds of StoreObjectsis difficult.

  15. Participant mapping

  16. New static view

  17. Modified Initialize Store - Cash

  18. Demo

More Related