Home » Tag Archives: Design Patterns (page 4)

Tag Archives: Design Patterns

Adapter 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 »

Introduction to Design Patterns

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 »

Java Design Patterns Tutorial

java-logo

Course Overview A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise. The idea was introduced by the architect Christopher Alexander in the field of architecture and has been adapted for various other disciplines, including computer science. A design pattern is a general reusable ...

Read More »

Java 8 Lambda Expression for Design Patterns – Command Design Pattern

java-logo

In this blog I would illustrate implementing the command pattern in functional programming style using Java 8 Lambda expressions. The intent of command pattern is to encapsulate a request as an object, thereby parameterizing clients with different requests, queue or log requests, and support corresponding operations. The command pattern is a way of writing generic code that sequences and executes ...

Read More »

Strategy Pattern in Java 8

java-logo

These are two examples on how to implement a Strategy pattern design using Java 8 functional style together with Cyclops pattern matching and Hamcrest libraries. PrintDependingOnInput method is a strategy that will System.println some message based on the log passed. AddPrefix is another strategy that will add a prefix to a message based on the message content. package com.marco.patternmatching; import ...

Read More »

Design Patterns in the 21st Century: The Chain of Responsibility Pattern

software-development-2-logo

Here’s a thing you might not see a lot. @Test public void hungryHungryPatrons() { KitchenStaff alice = new PieChef(); KitchenStaff bob = new DollopDistributor(); KitchenStaff carol = new CutleryAdder(); KitchenStaff dan = new Server(); alice.setNext(bob); bob.setNext(carol); carol.setNext(dan); Patron patron = new Patron(); alice.prepare(new Pie()).forPatron(patron); assertThat(patron, hasPie()); } It might look odd, but the idea is fairly common. For example, the ...

Read More »

Design Patterns in the 21st Century: The Adapter Pattern

java-logo

This is part three of my talk, Design Patterns in the 21st Century. The Adapter pattern bridges worlds. In one world, we have an interface for a concept; in another world, we have a different interface. These two interfaces serve different purposes, but sometimes we need to transfer things across. In a well-written universe, we can use adapters to make ...

Read More »

Design Patterns in the 21st Century: The Abstract Factory Pattern

java-logo

This is part two of my talk, Design Patterns in the 21st Century. This pattern is used everywhere in Java code, especially in more “enterprisey” code bases. It involves an interface and an implementation. The interface looks something like this: public interface Bakery { Pastry bakePastry(Topping topping); Cake bakeCake(); } And the implementation: public class DanishBakery implements Bakery { @Override ...

Read More »

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 »

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