State Design Pattern In Java

java-thumbnail

This tutorial explains the state design pattern with a simple example program. State design pattern is very similar to the Strategy pattern, the only difference is that state design pattern maintains the state of the context where as strategy pattern passes the context and execute the specific strategy. The state design pattern is very useful […]

Design Patterns in Java

java

In developing a system, it is expected that some requirements are guaranteed, for example, performance, robustness, understanding, ease of reuse, modification, and use.¬†The Design Patterns were created by the architect¬†Christopher Alexander¬†, in the 1970s. During this period the architect wrote two books: “Pattern Language” and “Timeless Way of Building“. These books were an example of […]

Lazy Initialization, Singleton Pattern and Double Checked locking

java-thumbnail

Lazy Initialization Lazy Initialization is a technique where one postpones the instantiation of a object until its first use. In other words the instance of a class is created when its required to be used for the first time. The idea behind this is to avoid unnecessary instance creation. But there are concerns related to […]

Design Patterns Interview Questions

1) What is a software design pattern? A design pattern is a solution to a general software problem within a particular context. Context : A recurring set of situations where the pattern applies. Problem : A system of forces (goals and constraints) that occur repeatedly in this context. Solution : A description of communicating objects […]

Decorator Design Pattern in Java

java-thumbnail

Intent of Decorator Design Pattern: Attach additional responsibilities to an object dynamically.Decorators provide a flexible alternative to subclassing for extending functionality.[GoF,p175] Client specified embellishment of a core object by recursively wrapping it. Wrapping a gift,putting it in a box and wrapping the box. also read: Design Pattern Interview Questions Factory Design Pattern State design pattern […]

Iterator Pattern

java-thumbnail

What is Iterator Pattern? Provide a way to access the elements of the aggregate object sequentially without exposing its underlying representation. Aggregate object is an object that contains other objects for the purpose of grouping those objects as a unit.It is also called a container or a collection.Examples are linkedList,Hashtable,ArrayList etc. also read: Design Pattern […]

Abstract Factory Pattern

java-thumbnail

What is Abstract Factory Pattern? Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Wikipedia says: A software design pattern, the Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme. also read: Design Pattern Interview Questions Factory Design Pattern […]

Template Design Pattern

java-thumbnail

What is Template Design Pattern? An abstract class defines various methods and has one non-overridden method which calls the various methods. also read: Design Pattern Interview Questions Factory Design Pattern State design pattern Wikipedia Says: A template method defines the program skeleton of an aligorithm.The aligorithm itself is made abstract,and the subclasses override the abstract […]

Chain Of Responsibility Pattern In Java

java-thumbnail

Chain Of Responsibility Pattern Overview: A method called in one class will move up a class hierarchy until a method is found that can properly handle the call.It consists of a source of command objects and a series of processing objects.Each processing object contains a set of logic that describes the types of command objects […]

Using the Prototype pattern to clone objects

java-thumbnail

Prototype pattern is one of the creational patterns that concentrate on duplicating objects if needed. Assuming that we are in process of creating a template. Most of the times, we copy an existing template, do some changes in it and then will use it. Technically, we make a copy of the source, make some changes […]