Saturday, 25 February 2017

Design Patterns in java

Design Patterns are very popular among software developers. A design pattern is a well described solution to a common software problem.

Sensible use of design patterns results in increased code maintainability, since in addition to being a good solution to a common problem, design patterns can be recognized by other developers, thus reducing the learning curve when dealing with a particular piece of code.
Some of the benefits of using design patterns are:

  • Design Patterns are already defined and provides industry standard approach to solve a recurring problem, so it saves time if we sensibly use the design pattern. There are many java design patterns that we can use in our java based projects.
  • Using design patterns promotes reusability that leads to more robust and highly maintainable code. It helps in reducing total cost of ownership (TCO) of the software product.
  • Since design patterns are already defined, it makes our code easy to understand and debug. It leads to faster development and new members of team understand it easily.

Types of design patterns include creational, structural, and behavioral design patterns.

Creation Design Pattern

Creational design patterns provide solution to instantiate a object in the best possible way for specific situations. These includes:
  • Singleton Pattern
  • Factory Pattern
  • Abstract Factory Pattern
  • Builder Pattern
  • Prototype Pattern

Structural Design Pattern

Structural patterns provide different ways to create a class structure, for example using inheritance and composition to create a large object from small objects. These includes:
  • Adapter Pattern
  • Composite Pattern
  • Proxy Pattern
  • Flyweight Pattern
  • Facade Pattern
  • Bridge Pattern
  • Decorator Pattern

Behavioral Design Pattern

Behavioral patterns provide solution for the better interaction between objects and how to provide lose coupling and flexibility to extend easily. These includes:
  • Template Method Pattern
  • Mediator Pattern
  • Chain of Responsibility Pattern
  • Observer Pattern
  • Strategy Pattern
  • Command Pattern
  • State Pattern
  • Visitor Pattern
  • Interpreter Pattern
  • Iterator Pattern
  • Memento Pattern


Follow the blogs for the example:


Singleton design pattern


Factory Method Pattern


Prototype Design Pattern






No comments:

Post a Comment