Home » Tag Archives: Design Patterns (page 3)

Tag Archives: Design Patterns

Double Checked Locking on Singleton Class in Java

java-logo

Singleton class is quite common among Java developers, but it poses many challenges to junior developers. One of the key challenge they face is how to keep Singleton class as Singleton? i.e. how to prevent multiple instances of a Singleton due to whatever reasons. Double checked locking of Singleton is a way to ensure only one instance of Singleton class ...

Read More »

Java Singleton Design Pattern

java-logo

Its one of the simplest design pattern in Java. If any one asks me which design pattern you are good then I would proudly say Singleton. But when they ask in depth concept of singleton then I get stumped. Is it really singleton is that much difficult ? Really not but it has many scenarios that we need to understand ...

Read More »

Difference between State and Strategy Design Pattern in Java

java-logo

In order to make proper use of State and Strategy design Pattern in Core Java application, its important for a Java developer to clearly understand difference between them. Though both State and Strategy design patterns has similar structure, and both of them are based upon Open closed design principle, represents ‘O’ from SOLID design principles, they are totally different on ...

Read More »

Circuit Breaker Pattern in Apache Camel

apache-camel-logo

Camel is very often used in distributed environments for accessing remote resources. Remote services may fail for various reasons and periods. For services that are temporarily unavailable and recoverable after short period of time, a retry strategy may help. But some services can fail or hang for longer period of time making the calling application unresponsive and slow. A good ...

Read More »

The Builder pattern and the Spring framework

spring-interview-questions-answers

Introduction I like to make use of the builder pattern whenever an object has both mandatory and optional properties. But building objects is usually the Spring framework responsibility, so let’s see how you can employ it using both Java and XML-based Spring configurations. A Builder example Let’s start from the following Builder class.   public final class Configuration<T extends DataSource> ...

Read More »

Design Pattern: Immutable Embedded Builder

java-logo

Last week I wrote about what makes a pattern anti-pattern. This week I present a design pattern… or wait… perhaps this is an anti-pattern. Or is it? Let’ see! The builder pattern is a programming style when there is a class that build an instance of another. The original aim of the builder pattern is to separate the building process ...

Read More »

Design Patterns: Pattern or Anti-Pattern, that is the question

java-logo

I have recently encountered the wiki page Anti-pattern that has an exhaustive list of anti patterns. Some of them were obvious for me. Some of them made me think a bit, other a bit more. Then I started to look for the anti-pattern “singleton” on the page and I could not find it. (Text search stops at singlet…) Is singleton ...

Read More »

Three Reasons Why I Like the Builder Pattern

java-logo

There are three ways to create new objects in Java programming language: The telescoping constructor (anti)pattern The Javabeans pattern The builder pattern I prefer the builder pattern over the other two methods. Why? Joshua Bloch described the builder pattern and the benefits of using it in Effective Java. He did an excellent job and I will not repeat these benefits ...

Read More »

The Decorator Pattern

java-logo

The Decorator Pattern One design pattern that I don’t see being used very often is Decorator. I’m not sure why this pattern isn’t more popular, as it’s quite handy. The Decorator pattern allows one to add functionality to an object in a controlled manner. This works at runtime, even with statically typed languages! The decorator pattern is an alternative to subclassing. ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.