Design Pattern

A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.

When working with design patterns, it is important to know not just how but also when to use them. A design pattern should occur naturally as a part of a design and shouldn’t drive the design, but guide it. Overuse of any pattern is harmful, especially in a situation where you’re biased, desperately trying to fit a pattern into the design.  It is prudent to look at the domain and problem context first and then use patterns to help in the design process.

 Creational Pattern

Creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.

Creational design patterns are further categorized into Object-creational patterns and Class-creational patterns. Where, Object-creational patterns deal with Object creation and Class-creational deal with Class-instantiation.

I will discuss below Creational Pattern in by blog:

  1. Singleton pattern: restrict instantiation of a class to one object
  2. Factory method pattern: centralize creation of an object of a specific type choosing one of several implementations
  3. Abstract factory pattern: centralize decision of what factory to instantiate

Structural Pattern

A structural design pattern “serves as a blueprint for how different classes and objects are combined to form larger structures”. Unlike creation patterns, which are mostly different ways to fulfill the same fundamental purpose, each structural pattern has a different purpose. What unifies structural patterns? They all involve connections between objects.

In some sense, structural patterns are similar to the simpler concept of data structures. However, structural design patterns also specify the methods that connect objects, not merely the references between them. Furthermore, data structures are fairly static entities. They only describe how data is arranged in the structure. A structural design pattern also describes how data moves through the pattern.

Structural class patterns use inheritance to combine the interfaces or implementations of multiple classes. Structural class patterns are relatively rare.
Structural object patterns use object composition to combine the implementations of multiple objects. They can combine the interfaces of all the composed objects into one unified interface or they can provide a completely new interface.

I will discuss below Structural Pattern in by blog:

  1. Decorator Pattern
  2. Adapter Pattern
  3. Bridge Pattern

Behavioural Pattern

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.

While creational patterns decouple a client from the objects it instantiates, behavioral patterns dictate the object interaction. Knowledge of the behavioral pattern vocabulary will help designers come up with appropriate solutions for object interactions, minimizing or eliminating these issues. One basic thing to understand is that there are two kinds of patterns:

  • Class: Describes compile-time relationship between classes via inheritance
  • Object: Describes the runtime relationship between classes via composition

Generally, object patterns allow more flexibility in design.

I will discuss below Structural Pattern in by blog:

Please share your feedback/query.

Java Design Pattern Presentation : Java Design Pattern


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: