Foundational Gangs-Of-Four Design Patterns in Java

Foundational (GOF) design patterns

Gang-Of-Four also called as foundation patterns are the 23 basic design patterns that provides solution to common recurring problems in software design. They categorized into three major categories, based on behaviour and characteristics.

  1. Creational patterns
  2. Structural patterns
  3. Behavioral Patterns
  4. Creational patterns

1. Creational design patterns

Creational patterns governs object-creation mechanisms that enable greater levels of reuse in evolving systems.

Abstract Factory Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Builder Separates the construction of a complex object from its representation so that the same construction process can create different representations.
Factory Method Provides a way to use an instance as an object factory. The factory can return an instance of one of several possible classes in a class hierarchy, depending on the data provided to it.
Prototype Prototype is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. In a simpler term, using prototype pattern, we will create new instances through cloning existing instances.
Singleton Singleton pattern ensures at most one instance of a particular class is ever created in your application.

2. Structural design patterns

Structural design patterns are design patterns that helps to identify a simple way to realize relationships between entities.

Adapter Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.
Bridge Decouple an abstraction from its implementation so that the two can vary independently.
Composite Compose objects into tree structure to represent part-whole hierarchies.Composite lets client treat individual objects and compositions of objects uniformly.
Decorator Allows for the dynamic wrapping of objects in order to modify their existing responsibilities and behaviors.
Facade Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.
Flyweight Facilitates the reuse of many fine grained objects, making the utilization of large numbers of objects more efficient.
Proxy Allows for object level access control by acting as a pass through entity or a placeholder object.

3. Behavioral design patterns

Behavioral design patterns identifies the common communication patterns between objects.

Chain of Responsibility Gives more than one object an opportunity to handle a request by linking receiving objects together.
Command Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.
Interpreter Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
Iterator Provides a way to access the elements of an aggregate object without exposing its underlying representation.
Mediator Allows loose coupling by encapsulating the way disparate sets of objects interact and communicate with each other. Allows for the actions of each object set to vary independently of one another.
Memento Captures and externalizes an object’s internal state so that it can be restored later, all without violating encapsulation.
Observer Observer design pattern defines one-to-many dependency between objects in which one object changes state, all its dependents are notified.
State Allows an object to alter its behavior when its internal state changes. The object will appear to change its class.
Strategy Defines a set of encapsulated algorithms that can be swapped to carry out a specific behavior.
Template Method Defines the steps for an algorithm and allows subclass to provide implementation for one or more steps.
Visitor Allows for one or more operation to be applied to a set of objects at runtime, decoupling the operations from the object structure.

Nilanchala

A blogger, a bit of tech freak and a software developer. He is a thought leader in the fusion of design and mobile technologies. He is the author of Xamarin Mobile Application Development for Android Book (goo.gl/qUZ0XV3), DZone MVB and founder of stacktips.com.

Related Articles

Join The Discussion

Please note: We reserve the right to delete comments that contains snarky remarks, offensive or off-topic. To know more read our comments policy.