Mind map
Design Pattern
Map content
Design Pattern
Flyweight
- Why to use?
- Reduce memory usage by sharing as much data as possible
- When to use?
- The flyweight object’s state is made up of an invariant component shared with other similar objects (intrinsic) and a variant component which can be manipulated by the client code (extrinsic)
- How to implement?
- To define an interface
- To create the concrete classes
- To create a factory class that will return build the flyweight object
- It’s very important that the flyweight objects are immutable: any operation on the state must be performed by the factory.
- The client will use the interface and the factory class to build the flyweight
- Why to use?
Proxy
- Why to use?
- Surrogate or placeholder a real object expensive to create
- When to use?
- Lazy initialization (virtual proxy). This is when you have a heavyweight service object that wastes system resources by being always up, even though you only need it from time to time.
- Access control (protection proxy). This is when you want only specific clients to be able to use the service object; for instance, when your objects are crucial parts of an operating system and clients are various launched applications (including malicious ones).
- Local execution of a remote service (remote proxy). This is when the service object is located on a remote server.
- Logging requests (logging proxy). This is when you want to keep a history of requests to the service object.
- Caching request results (caching proxy). This is when you need to cache results of client requests and manage the life cycle of this cache, especially if results are quite large.
- How to implement?
- Implements the same interface of the real object
- Wrappes the real object
- Why to use?
Information
- Description
- Mind Map on Design Pattern, created by Jonnatas Silva on 15/12/2018.
- Created by
- Jonnatas Silva
- Views
- 1
- Rating