Home » Tag Archives: Design Patterns

Tag Archives: Design Patterns

Functional Factory Pattern

java-design-patterns-logo_scaled

Do you want a REALLY quick way to make a Factory object? Then lambdas or other function-passing is what you need! Not only is it quick, it’s really simple. I bet, if you’re a pretty good with Lambdas, you have a pretty good idea on how to do this simply by having read the title. If you’re one of those, ...

Read More »

How The Decorator Pattern Saved My Day

java-design-patterns-logo_scaled

At work I am dealing with a huge Java code base, which was developed over the course of more than 15 years by many different developers. Not all things were done by the books but at the same time I usually don’t have the possibility to refactor every oddity I come across. Still, steps towards higher code quality can be ...

Read More »

The Serialization Proxy Pattern

java-design-patterns-logo_scaled

In my last post, I talked about serialization in general. This one is much more focused and presents a single detail: the Serialization Proxy Pattern. It is a good, often the best, way to deal with many of the issues with serialization. If there was only one thing a developer would want to know about the topic, I’d tell him ...

Read More »

The Decorator Pattern With Java 8

java-design-patterns-logo_scaled

In a recent post I described how the decorator pattern saved my day. I gave a small code snippet which contained the simplest way to create decorators but promised that there would be a nicer way with Java 8. Here it is:               Decorating With Java 8 HyperlinkListener listener = this::changeHtmlViewBackgroundColor; listener = DecoratingHyperlinkListener.from(listener) ...

Read More »

Transforming Collections with Decorators

java-design-patterns-logo_scaled

The Decorator Pattern Ever since first learning the programming design patterns, the decorator pattern has been my favorite. It seemed such a novel idea to me, and so much more interesting than the others. Don’t get me wrong, most of the others blew my mind too, but none so much as the decorator pattern. To this day, it’s still one ...

Read More »

REST Messages And Data Transfer Objects

software-development-2-logo

In Patterns of Enterprise Application Architecture, Martin Fowler defines a Data Transfer Object (DTO) as: An object that carries data between processes in order to reduce the number of method calls. Note that a Data Transfer Object is not the same as a Data Access Object (DAO), although they have some similarities. A Data Access Object is used to hide ...

Read More »

Understanding strategy pattern by designing game of chess

java-logo

Today we will try to understand Strategy Pattern with the help of an example. The example we will consider is The Game of Chess. The intention here is to explain strategy pattern and not to build a comprehensive Chess Game solution. Strategy Pattern : The Strategy pattern is known as a behavioural pattern – it’s used to manage algorithms, relationships ...

Read More »

Factory Without IF-ELSE

java-logo

Object Oriented Language has very powerful feature of Polymorphism, it is used to remove if/else or switch case in code. Code without condition is easy to read. There are some places where you have to put them and one of such example is Factory/ServiceProvider class. I am sure you have seen factory class with IF-ELSEIF which keeps on getting big. ...

Read More »

Clustered Idempotent Consumer Pattern with Infinispan

jboss-infinispan-logo

I’ve created a small project that shows how to use JBoss Infinispan with Apache Camel and the Idempotent Consumer Pattern to guarantee a message will not be processed twice in a clustered environment. Imagine you have an application that has to scale out easily by deploying it on multiple containers. But the application has to process each unique request only ...

Read More »

Pizza problem – builder vs decorator

java-logo

Problem Statement We need to build the software for a pizza company who wants to prepare different types of pizzas, e.g Chicken Pizza, Flat Bread, Pepperoni Pizza with Extra Cheese, put add on toppings on it. Lets try to see which design pattern suits this problem statement and under what scenario. Traditionally, for pizza problem, builder pattern is most commonly ...

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