Home » Tag Archives: Design Patterns (page 3)

Tag Archives: Design Patterns

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 »

State Design Pattern in Java – Example Tutorial

java-logo

State pattern is one of the behavioral design pattern. State design pattern is used when an Object change it’s behavior based on it’s internal state. If we have to change the behavior of an object based on it’s state, we can have a state variable in the Object and use if-else condition block to perform different actions based on the ...

Read More »

Strategy Design Pattern in Java – Example Tutorial

java-logo

Strategy pattern is one of the behavioral design pattern. Strategy pattern is used when we have multiple algorithm for a specific task and client decides the actual implementation to be used at runtime. Strategy pattern is also known as Policy Pattern. We defines multiple algorithms and let client application pass the algorithm to be used as a parameter. One of ...

Read More »

Template Method Design Pattern in Java

java-logo

Template Method is a behavioral design pattern and it’s used to create a method stub and deferring some of the steps of implementation to the subclasses. Template method defines the steps to execute an algorithm and it can provide default implementation that might be common for all or some of the subclasses. Let’s understand this pattern with an example, suppose ...

Read More »

Visitor Design Pattern in Java – Example Tutorial

java-logo

Visitor Pattern is one of the behavioral design pattern. Visitor pattern is used when we have to perform an operation on a group of similar kind of Objects. With the help of visitor pattern, we can move the operational logic from the objects to another class. For example, think of a Shopping cart where we can add different type of ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close