Home » Tag Archives: Design Patterns

Tag Archives: Design Patterns

Resource leakages: command pattern to the rescue

java-interview-questions-answers

Over the years of performance monitoring with Plumbr I have faced hundreds of performance issues caused by resource leakages. In this post I would like to describe one of the simplest ways to approach resource clean-up and avoid the problem. Let me first describe the problem by using a movie player application as an example. The primary feature for such an ...

Read More »

Introducing The Delegate Pattern

spring-interview-questions-answers

Delegate: a person who is chosen or elected to vote or act for others – Merriam-Webster. Delegate pattern: In software engineering, the delegation pattern is a design pattern in object-oriented programming where an object, instead of performing one of its stated tasks, delegates that task to an associated helper object – Wikipedia. Make things as simple as possible, but not simpler – Albert ...

Read More »

The Best of Both Worlds

java-logo

Type-Safe Views using Abstract Document Pattern How do you organize your objects? In this article I will introduce a pattern for organizing so called noun-classes in your system in a untyped way and then expose typed views of your data using traits. This makes it possible to get the flexibility of an untyped language like JavaScript in a typed language ...

Read More »

Abstract Factory or Factory Method?

software-development-2-logo

Today I would like to tell you about Factory Method Pattern and Abstract Factory Pattern. The purpose of the article is to help you recognize places where one of them should be used. What will we talk about? Those patterns are one of the Creational Patterns and as the name suggest their main responsibility is creating the objects. However, we ...

Read More »

Java Dynamic Proxy

java-logo

Proxy is a design pattern. We create and use proxy objects when we want to add or modify some functionality of an already existing class. The proxy object is used instead of the original one. Usually the proxy objects have the same methods as the original one and in Java proxy classes usually extend the original class. The proxy has a ...

Read More »

Java 8 Lambda Expression for Design Patterns – Strategy Design Pattern

java-logo

The strategy pattern defines a family of algorithms encapsulated in a driver class usually known as Context and enables the algorithms to be interchangeable. It makes the algorithms easily interchangeable, and provides mechanism to choose the appropriate algorithm at a particular time. The algorithms (strategies) are chosen at runtime either by a Client or by the Context. The Context class ...

Read More »

Decorator Design Pattern using lambdas

java-logo

With the advent of lambdas in Java we now have a new tool to better design our code. Of course the first step is using streams, method references and other neat features introduced in Java 8. Going forward I think the next step is to revisit the well established Design Patterns and see them through the functional programming lenses. For ...

Read More »

Factory Pattern

java-logo

The factory pattern is a creational design pattern whose intent is to provide an interface for creating families of related or dependent objects without specifying their concrete classes. The creational logic is encapsulated within the factory which either provides a method for its creation or delegates the creation of the object to a subclass. The client is not aware of ...

Read More »

Java 8 Lambda Expression for Design Patterns – Decorator Design Pattern

java-logo

The Decorator pattern (also known as Wrapper) allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class. It can be considered as an alternative to subclassing. We know that subclassing adds behavior at compile time and the change affects all instances of the original class. On ...

Read More »

Visitor Design Pattern

java-logo

This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how those are implemented and utilized in Java. You will understand the reasons why patterns are so important and learn when and how to apply each one of them. Check it out here! ...

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