Home » Tag Archives: Design Patterns (page 6)

Tag Archives: Design Patterns

Template method design pattern in Java

java-logo

Template method pattern is a behavioral design pattern which provide base method for algorithm,called template method which defers some of its steps to subclasses So algorithm structure is same but some of its steps can be redefined by subclasses according to context. Template means Preset format like HTML templates which has fixed preset format.Similarly in template method pattern,we have a ...

Read More »

Observer design pattern in Java

java-logo

As the name suggests it is used for observing some objects.Observer watch for any change in state or property of subject.Suppose you are interested in particular object and want to get notified when its state changes then you observe that object and when any state or property change happens to that object,it get notified to you. As described by GoF: ...

Read More »

The ins and outs of immutability

java-logo

So in my first post I talked a little bit about the builder pattern and I mentioned a really powerful but yet overlooked concept: immutability. What is an immutable class? It’s simply a class whose instances can’t be modified. Every value for the class’ attributes is set on their declaration or in its constructor and they keep those values for ...

Read More »

The builder pattern in practice

java-logo

I’m not going to dive into much details about the pattern because there’s already tons of posts and books that explain it in fine detail. Instead, I’m going to tell you why and when you should consider using it. However, it is worth mentioning that this pattern is a bit different to the one presented in the Gang of Four ...

Read More »

Iterator Pattern and Java

java-logo

Hello all, in this post we’ll be checking on the Iterator Pattern. A design pattern that I know many of you have already used, but maybe you didn’t realize it was pattern or didn’t know its great value. According to the book Head First Design: The Iterator Pattern provides a way to access the elements of an aggregate object sequentially ...

Read More »

Loan pattern in Java (a.k.a lender lendee pattern)

java-logo

This post is about implementing loan pattern in Java. Use Case Implement separation between the code that holds resource from that of accessing it such that the accessing code doesn’t need to manage the resources. The use case mentioned holds true when we write code to read/write to a file or querying SQL / NOSQL dbs. There are certainly API’s ...

Read More »

Fluent Object Creation

java-logo

Many posts have been written on this subject (overwhelmingly many) but I just wanted to contribute my two-cents and write a short post about how I use the Fluent Object Creation pattern or object builders in Java to instantiate Value Objects. Value Objects are abstractions that are defined by their state (value) rather than their address in memory. Examples of ...

Read More »

Using Builder Pattern in JUnit tests

junit-logo

This is not intended to be a heavily technical post. The goal of this post is to give you some guidelines to make your JUnit testing life more easy, to enable you to write complex scenarios for tests in minutes with the bonus of having extremely readable tests.                 There are two major ...

Read More »

Decorate with decorator design pattern

java-logo

Decorator pattern is one of the widely used structural patterns. This pattern dynamically changes the functionality of an object at runtime without impacting the existing functionality of the objects. In short this pattern adds additional functionalities to the object by wrapping it. Problem statement: Imagine a scenario where we have a pizza which is already baked with tomato and cheese. ...

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