Core Java Design Pattern

Core java Design Pattern

Abstract:
“Pattern” as the name suggests, means series of events occurring in a definite order. The patterns can be found in Java and J2ee technologies also.
Many times, we find that there is a particular way of tackling a problem. This way is easy and has been used many times successfully by a number of people earlier also. This method becomes a pattern.

Patterns Defined: The patterns can be defined in many ways. You can find the definitions of patterns in many good books.“Design patterns are recurring solutions to design problems.”

Patterns: According to commonly known practices, there are 23 design patterns in Java.

Creational Patterns

All the creational patterns define the best possible way in which an object can be instantiated.
These describes the best way to CREATE object instances.
Now everyone knows the object instance in Java can be created using a new operator.Book book = new Book ();

So, what’s the great stuff? Well, that’s true. The new Operator creates the instance of an object, but this is hard-coding.
As I have said earlier, creating good software is difficult and so, hard coding is the last thing one should do. Also, at times the very nature of the object which is created can change according to the nature of the program.
In such scenarios, we can make use of patterns to give this a more general and flexible approach.

Structural Patterns

Structural Patterns describe how objects and classes can be combined to form larger structures. The difference between class patterns and object patterns is that class patterns describe abstraction with the help of inheritance and how it can be used to provide more useful program interface. Object patterns, on other hand, describe how objects can be associated and composed to form larger, more complex structures.

The chain of responsibility pattern is based on the same principle as written above. It decouples the sender of the request to the receiver.
The only link between sender and the receiver is the request which is sent. Based on the request data sent, the receiver is picked.
This is called âdata-drivenâ. In most of the behavioral patterns, the data-driven concepts are used to have a loose coupling.