Software Design Patterns

C by schemacoma


It´s time to talk about Software Design Patterns.

They are solutions to common problems that developers face. Many software design patterns address common situations that developers need to implement in every application they build (e.g. object initialization). Take just about any programming problem and there are only a few good implementation approaches, but many bad approaches. Software design patterns capture the experience of experts in a form that others can reuse.

First of all, I will take few info of what we comment on a previous post of our blog:

Design Pattern:

Design patterns provide a standard terminology and are specific to particular scenario.

As per the design pattern reference book Design Patterns – Elements of Reusable Object-Oriented Software , there are 23 design patterns. These patterns can be classified in three categories: Creational, Structural and behavioral patterns. We’ll also discuss another category of design patterns: J2EE design patterns.

S.N. Pattern & Description
1 Creational Patterns
These design patterns provides way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case.
2 Structural Patterns
These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
3 Behavioral Patterns
These design patterns are specifically concerned with communication between objects.
4 J2EE Patterns
These design patterns are specifically concerned with the presentation tier. These patterns are identified by Sun Java Center.

Taking the info about Design patterns at Wikipedia we have the following table of Design patterns:

Creational patterns

Name Description
Abstract factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Builder Separate the construction of a complex object from its representation, allowing the same construction process to create various representations.
Factory method Define an interface for creating a single object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses (dependency injection[19]).
Lazy initialization Tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed. This pattern appears in the GoF catalog as “virtual proxy”, an implementation strategy for the Proxy pattern.
Multiton Ensure a class has only named instances, and provide a global point of access to them.
Object pool Avoid expensive acquisition and release of resources by recycling objects that are no longer in use. Can be considered a generalisation of connection pooland thread pool patterns.
Prototype Specify the kinds of objects to create using a prototypical instance, and create new objects from the ‘skeleton’ of an existing object, thus boosting performance and keeping memory footprints to a minimum.
Resource acquisition is initialization Ensure that resources are properly released by tying them to the lifespan of suitable objects.
Singleton Ensure a class has only one instance, and provide a global point of access to it.

Structural patterns

Name Description
Adapter or Wrapper or Translator Convert the interface of a class into another interface clients expect. An adapter lets classes work together that could not otherwise because of incompatible interfaces. The enterprise integration pattern equivalent is the translator.
Bridge Decouple an abstraction from its implementation allowing the two to vary independently.
Composite Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Decorator Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclassing for extending functionality.
Extension object Adding functionality to a hierarchy without changing the hierarchy.
Facade Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.
Flyweight Use sharing to support large numbers of similar objects efficiently.
Front controller The pattern relates to the design of Web applications. It provides a centralized entry point for handling requests.
Marker Empty interface to associate metadata with a class.
Module Group several related elements, such as classes, singletons, methods, globally used, into a single conceptual entity.
Proxy Provide a surrogate or placeholder for another object to control access to it.
Twin [23] Twin allows modeling of multiple inheritance in programming languages that do not support this feature.

Behavioral patterns

Name Description
Blackboard Artificial intelligence pattern for combining disparate sources of data (see blackboard system)
Chain of responsibility Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.
Command Encapsulate a request as an object, thereby allowing for the parameterization of clients with different requests, and the queuing or logging of requests. It also allows for the support of 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 Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
Mediator Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it allows their interaction to vary independently.
Memento Without violating encapsulation, capture and externalize an object’s internal state allowing the object to be restored to this state later.
Null object Avoid null references by providing a default object.
Observer or Publish/subscribe Define a one-to-many dependency between objects where a state change in one object results in all its dependents being notified and updated automatically.
Servant Define common functionality for a group of classes.
Specification Recombinable business logic in a Boolean fashion.
State Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
Strategy Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
Template method Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.
Visitor Represent an operation to be performed on the elements of an object structure. Visitor lets a new operation be defined without changing the classes of the elements on which it operates.

Concurrency patterns

Name Description
Active Object Decouples method execution from method invocation that reside in their own thread of control. The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for handling requests.
Balking Only execute an action on an object when the object is in a particular state.
Binding properties Combining multiple observers to force properties in different objects to be synchronized or coordinated in some way.
Blockchain Decentralized way to store data and agree on ways of processing it in a Merkle tree, optionally using Digital signature for any individual contributions.
Double-checked locking Reduce the overhead of acquiring a lock by first testing the locking criterion (the ‘lock hint’) in an unsafe manner; only if that succeeds does the actual locking logic proceed.
Can be unsafe when implemented in some language/hardware combinations. It can therefore sometimes be considered an anti-pattern.
Event-based asynchronous Addresses problems with the asynchronous pattern that occur in multithreaded programs.
Guarded suspension Manages operations that require both a lock to be acquired and a precondition to be satisfied before the operation can be executed.
Join Join-pattern provides a way to write concurrent, parallel and distributed programs by message passing. Compared to the use of threads and locks, this is a high-level programming model.
Lock One thread puts a “lock” on a resource, preventing other threads from accessing or modifying it.
Messaging design pattern (MDP) Allows the interchange of information (i.e. messages) between components and applications.
Monitor object An object whose methods are subject to mutual exclusion, thus preventing multiple objects from erroneously trying to use it at the same time.
Reactor A reactor object provides an asynchronous interface to resources that must be handled synchronously.
Read-write lock Allows concurrent read access to an object, but requires exclusive access for write operations.
Scheduler Explicitly control when threads may execute single-threaded code.
Thread pool A number of threads are created to perform a number of tasks, which are usually organized in a queue. Typically, there are many more tasks than threads. Can be considered a special case of the object pool pattern.

Thread-specific storage Static or “global” memory local to a thread.

Feel free to click on the links to acces Wikipedia Related articles abouteach of them. ere we are only discussing how they were created. Then maybe we´ll write a post with some of them.

Have you heard about “Object-Oriented Design Patterns book.” book written by GoF?

Well, all of the deal of Design patterns were created around 1994 by Gamma, Helm, Johnson, Vlissides (the Gang of Four (GoF)) whe we write the previous mentioned book.

In the early 1990s, the best source for information on software design patterns was definitely the GoF Object-Oriented Design Patterns book.

GoF defined four essential elements that are required for any software design pattern:

  1. The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two
  2. The problem describes the context and when to apply the pattern
  3. The solution describes the elements that make up the design, their relationships, responsibilities and collaborations. The pattern does not describe a concrete solution.
  4. The consequences are the result and trade-offs of applying the pattern

GoF felt that a problem to be solved by a software design pattern must be seen repeatedly in practice to prove the pattern is applicable beyond the system in which it is first identified.

Retrieved from:


In others posts we will share some Desig patterns and explain them in advance.


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