Loading in 2 Seconds...
Loading in 2 Seconds...
Pure Fabrication and “Gang of Four” Design Patterns . Larman, chapters 25 and 26 CSE432 Object-Oriented Software Engineering Glenn D. Blank, Lehigh University. Pure Fabrication Another GRASP design pattern.
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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Larman, chapters 25 and 26
Object-Oriented Software Engineering
Glenn D. Blank, Lehigh University
Problem: you must assign a responsibility to a class, but assigning it to a class that already represents a problem domain entity would ruin its low coupling and/or high cohesion.
Solution: Assign a highly cohesive set of responsibilities to “made up,” fabricated class—it does not need to represent a problem domain concept—in order to support high cohesion, low coupling & reuse.
Invent a new class that is solely responsible for saving objects.
Design Patterns book catalogs 23 different patterns
Assemble objects to realize new functionality
Exploit flexibility of object composition at run-time
Not possible with static class composition
Proxy acts as convenient surrogate or placeholder for another object.
Remote Proxy: local representative for object in a different address space
Virtual Proxy: represent large object that should be loaded on demand
Protected Proxy: protect access to the original object
Converts interface of a class into one that clients expect
Links abstraction with many possible implementations
Represents part-whole hierarchies as tree structures
Attach additional responsibilities to object dynamically
Simplifies the interface for a subsystem
Shares many fine-grained objects efficiently
Provides a surrogate or placeholder for another object to control access to it
Problem: How to resolve incompatible interfaces or provide a stable interface to similar components with different interfaces?
Solution: Convert original interface component into another one through an intermediate adapter.
Use interfaces and polymorphism to add indirection to varying APIs
static Singleton* getInstance();
protected: //Why are the following protected?
Singleton& operator= (const Singleton&);
private: static Singleton* instance;
Singleton *p2 = p1->getInstance();
Which ones do you think you have seen somewhere?
Problem: How to design a family of algorithms or policies that are essentially the same but vary in details?
Solution: "Define a family of algorithms, encapsulate each one, and make them interchangeable." [Gamma, p315]