--> Solve common problems like.
-
How to properly create a class.
-
How to instantiate an object.
-
How to interact b/w objects.
-
How to write loosely coupled code.
-
How to write reusable code.
-
Well defined solution to a common problem.
-
Industry standard Approach.
-
Template, not a solution.
-
Language independent.
-
Robust code.
-
Code re-usability.
-
High maintainability.
-
Reduce total cost of Ownership.
-
Loosely coupled application.
Creational:
1. Singleton
2. Factory
3. Abstract Factory
4. Builder
5. Prototype
Structural:
6. Adapter
7. Composite
8. Proxy
9. fly weight
10. Facade
11. Bridge
12. Decorator
Behavioural:
13. Template Method
14. Mediator
15. Chain of Responsibility
16. Observers
17. Strategy
18. Command
19. State
20. Visitor
21. Iterator
22. Interpreter
23. Memento
- Keep it simple.
- Excess of everything is bad.
- Focus on loosely coupled code.
- Design first, Code later.
There are three major issues with Factory and Abstract Factory design patterns when the Object contains a lot of attributes.
- Too Many arguments to pass from client program to the Factory class that can be error prone because most of the time, the type of arguments are same and from client side its hard to maintain the order of the argument.
- Some of the parameters might be optional but in Factory pattern, we are forced to send all the parameters and optional parameters need to send as NULL.
- If the object is heavy and its creation is complex, then all that complexity will be part of Factory classes that is confusing.