Spring: Design Patterns

Introduction

Design patterns are designed with good Object Oriented Programming in mind. It represents the best practices adopted to solve the common problems. It describes the solution for the problem and application or implementation of it. As well as how to use the solution.

Why Design Patterns

There are several reasons and advantages of design patterns for which, as a developer, you should consider using design patterns.

  • Provides common answers to common problems
  • No need to solve same problem again & again. And could be reused in multiple projects.
  • Provides proven and testified implementations, that have been built upon by experienced developers, to be leveraged for free.
  • Industry wide the design patterns has been adopted as they help in building a better system

What’s there for Developers

Design Patterns provide a common answer to a common problem. They are trusted and well tested patterns that helps identifying the solution and solving a problem easily. And in turn helps to get to the market faster.

By using design patterns developers can write more flexible, reusable and maintainable code. It also increases the readability of the code which makes fixing the issue and debugging the code easier.

Gang of Four

Writing about design patterns and I won’t mention about the Gang of Four! Well, that is simply not possible. You now maybe wondering what or who are the gang of four. Well, they are four software engineers  Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides who wrote a book explaining the design patterns named Design Patterns: Elements of Reusable Object-Oriented Software.

This book changed the way how we look about programming our code. It explained the benefits of having patterns to solve the problems. This book introduced 3 different types of patterns. Now, let’s read about the different types of patterns.

Groups of Patterns

The design patterns are broadly classified into groups. They are:

Creational

They are called creational because they create objects. Some of the most commonly used creational patterns are:

  • Abstract Factory
  • Factory
  • Singleton
  • Prototype
  • Builder

Behavioral

They are called behavioral because they focus on the inter-object communication within the application runtime. Some of the most commonly used behavioral patterns are:

  • Command
  • Interpreter
  • Mediator
  • Observer
  • Iterator
  • Chain of Responsibility
  • Visitor
  • Memento
  • State
  • Strategy
  • Template

Structural

The structural patterns focuses on the object composition and interfaces. Some of the commonly used structural patterns are:

  • Composite
  • Adapter
  • Bridge
  • Decorator
  • Flyweight
  • Facade
  • Proxy
Java Design Patterns
Previous Post

No more post

Java Design Patterns
Next Post

No more post