Code Pumpkin

Category Archives: Design Patterns

Subscribe

Object Pool Design Pattern

July 29, 2017
Posted by Pumpkin

Object pool design pattern is one of the Creational Design Pattern. In very simple term, this design pattern means To Reuse the objects which are very costly to create. Object pooling is creating objects of the class at the time of creation and put them into one common pool. Now whenever application needs object of that class […]

What is the use of private constructor in java?

In Java, we can use any access modifier (i.e. public, protected or private) with constructor.  So, what are the uses of making constructor private? First thing that strikes your mind is Singleton Design Pattern which is also one of the most asked Core Java Interview Question to the 3-4 yr exp Java developers.  Apart from creating singleton class, private constructor […]

Mediator Design Pattern

June 11, 2017
Posted by Pumpkin

Mediator Design Pattern is one of the Behavioral Design Pattern. With the Mediator Design Pattern, communication between objects is encapsulated with a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator. This reduces the dependencies between communicating objects, thereby lowering the coupling. Definition GoF Definition: Define an object that encapsulates […]

Observer Design Pattern

June 7, 2017
Posted by Pumpkin

Observer Design Pattern is one of the Behavioral Design Pattern. Observer design pattern is useful when you are interested in the state of an object and want to get notified whenever there is any change.  Definition GoF Definition : The Observer Design Pattern defines a one-to-many dependency between objects so that when one object changes state, all […]

Builder Design Pattern

April 27, 2017
Posted by Pumpkin

Builder design pattern is a creational design pattern like Factory Pattern and Abstract Factory Pattern. For better understanding of  any  design pattern, You should know the problems faced by programmers before that design pattern was introduced. What are the traditional ways of creating an object of a class? We can provide either constructor or a static factory method to get the object  of […]

How to create Immutable Class in Java

Immutable class is a class which once created, it's contents can not be changed. Immutable objects are the objects whose state can not be changed once constructed.  In Java, String  and all the wrapper classes e.g. Boolean, Integer, Long, etc are immutable classes. We can create our own immutable class as well. Joshua Bloch's Effective Java has a very good explanation about why you […]

Producer Consumer Design Pattern

April 5, 2017
Posted by Pumpkin

Producer Consumer Problem is a classical concurrency problem. In fact it is one of the concurrency design pattern.  It is also known as the bounded-buffer problem. The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue. The producer's job is to generate data and put it into […]

Producer Consumer Design Pattern using BlockingQueue

April 5, 2017
Posted by Pumpkin

Producer Consumer Problem is a classical concurrency problem. In fact it is one of the concurrency design pattern.   This article is continuation of my post Producer Consumer Design Pattern in which I have explained basic idea, real life example, uses and benefits of Producer Consumer Design Pattern.   Producer Consumer Design Patter can be implemented using […]

Producer Consumer Design Pattern using wait() and notify()

April 3, 2017
Posted by Pumpkin

Producer Consumer Problem is a classical concurrency problem. In fact it is one of the concurrency design pattern.   This article is continuation of my post Producer Consumer Design Pattern in which I have explained basic idea, real life example, uses and benefits of Producer Consumer Design Pattern.   Producer Consumer Design Patter can either be implemented […]

Singleton Design Pattern

In Design Pattern article we have seen different types of design pattern available. In this article we will take one of the simplest design pattern from the Creational Design Pattern. Singleton Design Pattern is part of the creational design pattern. In Singleton design pattern restricts the instantiation of a class and ensures that only one instance of the class […]

Previous Posts

Total Post : 80
Subscribe
Contribute Your Articles

Interview Experiences

Related Books

Like Us On Facebook

Alexa Page Rank