- If a problem occurs over and over again, and that problem has been solved by experts and used effectively. Then that solution is described as a design pattern.
- The design patterns are language-independent strategies for solving common object-oriented design problems.
- If you want to be a professional Java developer, you should know at least some popular solutions to coding problems. Such solutions have been proved efficient and effective by the experienced developers.
- Learning design patterns speeds up your experience accumulation in OOA/OOD. Once you grasped them, you would be benefit from them for all your life and jump up yourselves to be a master of designing and developing.
Some of the useful definitions are as follows,
"Design patterns constitute a set of rules describing how to accomplish
certain tasks in the realm of software development."
"A pattern addresses a recurring design problem that arises in specific
design situations and presents a solution to it"
How many design patterns?
- The 23 design patterns by GOF are well known, and more are to be discovered on the way.
- A site says at least 250 existing patterns are used in OO world, including Spaghetti which refers to poor coding habits.
Patterns: According to commonly known practices, there are 23 design patterns in Java. These patterns are grouped under three heads:
1. Creational Patterns
2. Structural Patterns
3. Behavioral Patterns
1. Creational Patterns
All of the creational patterns' responsibility is to abstract the object creational process and deal with the best way to create instances of objects. This is important because your program should not depend on how objects are created and arranged.
There are five types of Creational Patterns.
1. Factory Pattern
2. Abstract Factory Pattern
3. Builder Pattern
4. Prototype Pattern
5. Singleton Pattern
2. Structural Patterns
Structural patterns describe how classes and objects can be combined to form larger structures. The difference between class patterns and object patterns is that class patterns describe how inheritance can be used to provide more useful program interfaces. Object patterns, on the other hand, describe how objects can be composed into larger structures using object composition, or the inclusion of objects within other objects.
There are seven types of Structural Patterns.
1. Adapter Pattern
2. Bridge Pattern
3. Composite Pattern
4. Decorator Pattern
5. Facade Pattern
6. Flyweight Pattern
7. Proxy Pattern
3. Behavioral Patterns
Behavioral patterns are those which are concerned with interactions between the objects. The interactions between the objects should be such that they are talking to each other and still are loosely coupled. The loose coupling is the key to n-tier architectures. In this, the implementation and the client should be loosely coupled in order to avoid hard-coding and dependencies.
There are eleven types of Behavioral Patterns.
1. Chain of Resposibility Pattern
2. Command Pattern
3. Interpreter Pattern
4. Iterator Pattern
5. Mediator Pattern
6. Momento Pattern
7. Observer Pattern
8. State Pattern
9. Strategy Pattern
10. Template Pattern
11. Visitor Pattern
Go to Factory pattern >>
No comments:
Post a Comment