Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- On the slides: names of template fields in red are important, and in green only mildly so.
- The consequences attribute is largely misused:
- Every design decision has certain consequences on other solutions, further development etc. We have to provide the possibilities of blockages etc.
- There are 23 patterns devised by the gang of four.
- The singleton
- Ensures a class has a single instance.
- The singleton creates an access point for the instance as well!
- The singleton is responsible for managing the lifecycle of the class.
- Might also be responsible for subclasses as well.
- Can be transformed into a pool of objects - i.e. instead of one class create a set number of classes.
- The singleton is stateless - it does not have any data of its own or of the client.
- It is a sort of global variable - which we all know is bad. Side effects appear.
- A sort of a lighthouse.
- Multi-threaded singleton? 2PL locking with the synchronised statement in java. Class loadres.
- Singleton should not be used that much.
- Why not use the Context pattern instead?
- Pool of objects (not defined by the Gang of Four)
- Lifecycle of objects: create, reset, close
- Management of lifecycle: create objects, reset objects (remove data from other clients), check if the connection is open.
- High efficiency solution.
- Provides management of the objects for the client.
- Obsever (Listener)
- Performance leaks: observer steals control from the observed object!
- Limits coupling (or loosens).
- Adapter
- Adapts an interface into an another interface.
- Composite
- Tree specification, where both nodes and leaves are implement a shared interface.
- Proxy
- Similar to adapter, but we don't want to translate
- but instead we want an object that will pretend to be the real object.
- Proxy implements the SAME interface as the subject.
- The proxy can imitate cals to the subject and calls the subject only if this is strictly necessary.
- Can help security (authorization), performance (cache, write buffer).
- Command
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement