What Is A Design Pattern English Language Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Describe Creational patterns, Behavioral Patterns, and Structured patterns, then discuss in more details one pattern from each mentioned categories.

Design pattern, what it is?

Each "pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice. So,design pattern in general is a common solution to a regularly happening problem insidethe context of software design. If a problem appeared continuously, an effective solution to that problem is defined as a pattern. In other words, the design patterns are independentlanguagestrategies and tactics concerns about solving" a common issues and object oriented design problems that perhaps users face.To building a desing, there are several things you have to be acquired, for instance, you should have an experience about the names of some common keys and solutions. Learning design patterns is one of most interesting object and feature that facilitate the interconnections among the peoplesuccessfully.

Generally, pattern has four crucialfeatures which are:

1. The pattern name: pattern name is a handle. It allows us to identify a design problems, solutions, and consequences in a one sentences or several words. Naming a design pattern directlygive an advantage to our design vocabulary. In addition, it permits us to design our pattern in a higher level ofabstraction.

2. The problem: it describes when to implement the pattern. It determines the problemand contexts. It also describesa particular design problem.For example, if you want to represent an algorithm as objects howcould you do that?In addition, itdescribes classesand objects structures.Occasionally, problems will contain a listof conditions which it is essentialto be met before implement the pattern.

3. The solution: describes the elements that make up the design, relationships, responsibilities, and collaborations.

4. The consequences: consequences are the outcomes of implementing the pattern.Listing consequences explicitly will help usto understand and evaluate them.

In Design Patterns,all patternsare identified by names, motivationsand their applicability to the context or not. It is necessary tounderstand the applicability of a design pattern. Otherwise, your problems will not be solved. MSDN define the design pattern a short description for a set of interacting classes which provide a mechanism for a solution to a common problem in a particular context.

"A design pattern systematically names, motivates, and explains a general design that addresses a recurring design problem in object-oriented systems. It describes the problem, the solution, when to apply the solution, and its consequences. It also gives implementation hints and examples. The solution is a general arrangement of objects and classes that solve the problem. The solution is customized and implemented to solve the problem in a particular context". -" by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides".

In the summery, design pattern could be A:

• Standard "solution to a common context problem.

• A technique for making code more flexible by reduce coupling among program components

• Shorthand for describing program design

Example: Subclassing (inheritance)

• Problem: Repetition in implementations

- Similar abstractions have similar members (fields,methods)

• Solution: Inherit default members from asuperclass

- Select an implementation via run-time "dispatching

• Disadvantages:

- Code for a class is spread out and thus lessunderstandable

- Run-time dispatching introduces overhead

When should (not) we use it?

Design Patterns are beneficialand has good effect if it is happened in following situations:

If the software application is changeable or it is mutablethrough the time.

If the application consists source code and that code has containedcreatedobject.

If have occurred a problem in designing or implementation stage, the design patterns consider that address as a problem

Solutions to problems that is repeated with variant variables. However, if the problem occurs only one time in the context, there is no need to use pattern.

If the solutions required many steps.

When not to use Design Patterns?

It will not be a wise to use it in those situations.

If the software is immutable designed and will not be changed or modifiedthrough the time.

If the requirements of the source code are unique.

The Gang of Four (GOF) Patterns

Erich Gamma, Richard Helm, Ralph Johnson and John Vlissideshave invented design patterns that we use nowadays.Theyhave invented about 23 patterns.Those 23 patters are usually known as " Gang of Four patterns" or "the GOF patterns".  These patterns generally are classified in three main categories. It is indicated below.



And Behavioral

Each of these categories hasand contains of sub-patterns.  Here are some short brief explanation about them state below.

Creational Patterns"

The Creational Patterns deals with a way that considered as the best way for creating an object or an instance of a class. Primarily, creational patterns concern about the process of how to create object or in other words, construction of new objects. They simplify the object creation process and provide a flexible and sufficient approach towards the process of object creation.  There are five sub-patterns which fall under creational pattern. They are stated below":

Abstract Factory





Factory Pattern: using a factory pattern is "efficientwhenthereis a super class and several of sub-classes, and depends on the data provided; we need to return the object of one of the sub-classes.

Abstract Factory Pattern:the abstract factory pattern defines an interface for creating instances of several related abstract classes without specifying their concerate subclasses. An example of Abstract Factory pattern is Java.Awt.Toolki class, which used to create native peers for GUI compnenets".

Both of the Factory pattern and Abstract Factory have the same intent.  Howeverthey are operateddifferently.  If you noticed that, both of Abstract Factory and the Factory pattern deal with the construction objects butthe difference is that the Abstract Factory pattern uses objects to manage object construction, while the Factory pattern use inheritance to do the same function.

The Builder Pattern:the builder pattern builds different complex objects from the same set of component parts. For instance, the lecturer of the class might feed a long list of names and addresses into the builder. The builder might build an PHP page from that list, ASP page, or a JSP page, depending on what type of Builder it was.

The Prototype Pattern: prototype pattern create new objects by copying a prototype object. By changing the object that's copied, you change the object that's created. This pattern is useful if you need several different copies of a relatively complex objects, all of which have the same initial state.

The Singleton Pattern:The Singleton design pattern is useful when there should only be one instance of a given class. It uses static, class methods and private

constructors to strictly control creation of new instances of the class.

Structural Patterns

A structural design pattern serves as a blueprint for how different classes and objects are combined to form larger structures. This module explores structural patterns, patterns that use composition to merge objects and classes into larger structures. A good toolbox of structural patterns allows solving many thorny problems you are likely to facing. They show you how to glue different pieces of a system together in a flexible and extensible fashion. Structural patterns help you guarantee that when one of the parts changes, the entire structure doesn't need to change. They also show you how to recast pieces that don't fit.

One advantage of Structural Patterns is that it provides the flexibility to state how objects and classes can collaborate together. Structural Patterns have several of sub-patters. Those sub-patterns are listed below:














The Adapter Pattern: it is a sample pattern that provides a wrapper for a class or object that uses different interfaces, much like an electrical adapter which can convert three prong to two prong plugs. It is very useful when you are working with classes from a class library that you can not change.

The Facade Pattern:it demonstrates a single class which in turnit represents a high level of the class.Also it makes it much easier to use.  "As an instance, Facade design pattern confirms that we can have a class that can act as a layer amongst the User Interface Layer and the Business Service Layer.  Thus, it acts as an agent that it simplifies the communication between the User Interface Layer and the Business Service Layer in a typical application design.  

The Composite Pattern: describes a tree-like structure in which individual parts have the same interface as the whole pattern.For instance,structure of simple and composite objects, so that the clients can treat the specific objects and their compositions in a uniform manner. The Bridge Pattern: decouples the interface from the implementation without using inheritance. So that, each of them can work independently from each other.    The Decorator Pattern: adds responsibilities to individual objects by wrapping them in a class that exposes their orginal interface, but includes some new methods and functionality as well. The Flyweight Pattern: it is very useful in efficient sharing.  The Proxy Pattern: it is similar to the adapter pattern which surrogate objects stands in among the client classes and the specific objects.In another meaning, it acts as a layer among the clientapplication" and object.

Behavioral Patterns

Behavioral Patterns describes the ways objects and classes interact and divide responsibilities among themselves. A behavioral pattern abstracts an action you want to take from the object or class that takes the action. By changing the object or class, you can change the algorithm used, the objects affected, or the behavior, while still retaining the same basic interface for client classes. For simplicity, behavioral pattern explains how objects interact. It describes how different objects and classes send messages to each other to make things happen and how the steps of a task are divided among different objects.

A good advantage of behavioral patterns is that it allows us to solve many thorny problems that we are likely to encounter when designing object-oriented systems. These include enumerating lists, responding to changes of state in an object, serializing and deserializing objects without penetrating data encapsulation, and more.

Another advantage of behavioral patterns is that you have the ability to describe a structure for inter-object communication between objects in your system.  This pattern usuallyis used to monitor the messages that are transmitted when the objects talking to each other in a system.  The following are the sub patterns under Behavioral Patterns. The following are the sub-patterns of behavioral pattern.

Chain of Responsibility









Template Method

The Chain of Responsibility Pattern"describes a system in which different objects each receive an opportunity to handle a request. The request propagates up the chain until some objects handles it. The Command Pattern encapsulates a command demand as an object.  The Interpreter Pattern is a way to include language elements in a program. It defines a grammatical representation for a language and an interpreter to interpret the grammar. One example of it is Java itself which is an interpreted language. It converts the code that is written in English to a byte code format. In result, to make possible for all the operating systems to understand it. This quality of it makes it platform independent. The Iterator Patterndescribes an abstract means of passing through each of elements in a collection, whether the collection is a set, array, list, or something else. It separates the enumeration of the collection from the way the collection is sorted".

The Mediator Patternis the most common and useful patterns. It allows many differnet objects of the same or different classes that need to communicate with each other to each communicate only with a single, central mediator. The Observer Patternallows an observer object to notice and react to changes in an observer and notifies each of them whenever it's relevant state changes. The strategy allows different algorithms to be incorporated into different classes. The algorithm can be changed dynamically at runtime and adjusted to fit the needs of a specific situation. The State Pattern is a design pattern that changes an object's behavior when the internal state of the object changes.The Template Method Pattern is a design pattern that is used to provide a template of an algorithm and defers some of the steps of the algorithm to the sub-classes.  The Visitor Pattern is one that is used to define a new operation to a class without changing.

Creational Patterns : Singleton Pattern

Singleton Patternis one of the most commonly used patterns. There are some instances in the application where we have to use just one instance of a particular class. Here is more clarification about singleton pattern:


This ensures that the class has only one instance. And then,it provides a global variable of access .


Sometimes we may need to have a single instance of a class to exist in the system. For instance, we want only one window manager. Or another example, say we need only one factory for a family products. We need to have that one instance easily accessible and we want to ensure that additional instances of the class ca not be created another time.


Once we have an idea of the pattern's intent and the problems it solves, we have to find out if it is applicable to our context or not. And if that solution solve our problem or not.



Static instance()

Singleton Operation()

Get singleton data()

Static uniqueInstance singleton data()g

Return uniqueInstance


There are two participants in singleton pattern, they are:

Singleton: which it defines an Instance operation that allow clients to access its unique instance. Instance is a class operation (static method). In addition, may be responsible for creating its own unique instance.

Client: it accesses a Singleton instance solely through the Singleton's Instance() method.


Singleton is a simple pattern that it doesn't say much about collaborations. Its collaborations look like this:

Clients use the getInstance() method to get a pointer or reference to the unique instance of the Singleton.

A client is any object or class outside the pattern.Only one knows about the public interface that the pattern and its classes present, rather than about its private implementation.


Some consequences of the Singleton pattern contain controlling access, permitting sub-classing, and enhancing the flexibility.

Controls access

The Singleton class can simply control who get accesses to its single instance and how will be done that. The getInstance() method can follow how many classes have "checked out" the instance. It also queue requests. It can check the state of the system before it is returning too.

Permits sub-classing

The Singleton class can be sub-classes. Subclasses can return an object that acts differently than originally intended. This allows client applications to configure at running-time by selecting a different subclass.

Enhances flexibility

The singleton patter creates a class with only static members. Since static members have only one value per class, the immediate effect would be similar.


The implementation of a singleton pattern must fulfill the single instance and global access principles. It needs a mechanism to access the singleton class member without creating a class object. If a new instance does not exist, the singleton pattern is implemented by creating a class with a method that creates a new instance of the class. If an instance is already exists, it will returns a reference to that specific object. To ensure that the object cannot be instantiated in different way, the constructor should be private.

Sample code :


public class Singleton {

static Singleton theInstance = new Singleton();

protected Singleton() {


public static Singleton getInstance() {





The theInstance field is declared as a static. That means its initializer (= new Singleton()) is executed the first time the class.

The Singleton() constructor , as it clears in above, is declared protected. So that subclasses can be created.

The constructor takes no arguments and in fact it doesn't do anything, so you might be leave it out.

Known use:

The solution of Bill Pugh

University of Maryland Computer Science researcher Bill Pugh has written about the code issues underlying the Singleton pattern when implemented in Java.[8] Pugh's efforts on the "Double-checked locking" idiom led to changes in the Java memory model in Java 5 and to what is generally regarded as the standard method to implement Singletons in Java.

Also, another known use of the Singleton pattern is found in the hidden parts of the Java class library.

The sun.audio.AudioDevice class exists, and is used in several ways.The Gang of Four lists several other known uses of Singleton patterns, including

Changeset current in SmallTalk-80, and the

Session and WidgetKit classes in the InterViews user interface toolkit.