Home » Tag Archives: Design Patterns (page 5)

Tag Archives: Design Patterns

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 »

Command Design Pattern Applied

java-logo

Hi there! Today i’m gonna share with you a really great programming design pattern. It has a lot of usages and it is one of my favorites. The programming degin pattern command has a huge variety of use cases. In this post we will see how to implement something from the real world. We will implement an electronic car key ...

Read More »

Applying decorator pattern to decorate views on Android

android-logo

Hi there! Today i’m gonna show how to apply the design pattern decorator to android’s views making use of its dependency injection’s concept. I thought it was a nice, clear and simple way to decorate views and that’s my motivator to share it with you. I’m assuming you know the decorator pattern already and are looking for real examples involving ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns