Design Patterns In Java

Design Pattern Tutorial Series

Behavioural Design Patterns

The observer pattern provides one object with a common and loosely couple method of informing multiple different objects about changes in its properties.

👍 Rule Of Thumb

Use the observer pattern when one objects state affects multiple other objects.

The strategy pattern provides objects with the ability to change their behavior (aka. strategy).

👍 Rule Of Thumb

Use the strategy pattern when objects can be associated with one instance of multiple varying objects with a common

The visitor design pattern allows you to add new methods to other classes without creating major changes.

👍 Rule Of Thumb

Use the visitor pattern when you have multiple objects, which you want to add variations of the same algorithm to.

The command design pattern uses an object to represent a method

👍 Rule Of Thumb

Use the command pattern when you have a method in one part of your system, which you want to invoke from another part, without also having to pass all necessary arguement.

Creational Design Patterns

The builder design pattern helps separating the construction of complex objects from the context where they are needed.

👍 Rule Of Thumb

Use the builder pattern when you have several variations of the same object, which needs to be created repeatedly.

The factory pattern provides guidelines for how to flexibly and conveniently create different objects with the same method, by only changing the argument of the method.

👍 Rule Of Thumb

Use the factory pattern whenever you want one method to return multiple possible classes which have a common super class.

The singleton design pattern intends to creates a class which only exists in a single instance. This allows for consistent and convenient retrieval of data.

👍 Rule Of Thumb

Use the singleton design pattern whenever you have an object which needs to be present multiple places in the project, but only logically should exist as a single instance.

Structural Design Patterns

The composite design pattern is intended for structuring data classes with a relationship to each other.

👍 Rule Of Thumb

Use the composite pattern whenever you encounter a data structure which requires a parent-child-relationship, but also enables parent-parent-references.

The adapter design pattern allows the behavior of the object to be converted into a desired form.

👍 Rule Of Thumb

Use the adapter pattern whenever you want to align the functionality of multiple different variations of the same type of object.

The facade pattern is based on the concept of simplifying activities. It allows us to wrap complex procedures in a facade class and afterwards utilize these procedures by one simple method call.

👍 Rule Of Thumb

Use the facade pattern whenever you have a complex procedure which you need to repeat multiple times.

The decorator pattern exploits composition of classes instead of inheritance to gain flexibility at runtime and avoid class explosions.

👍 Rule Of Thumb

Use the decorator pattern whenever you need an obejct structure based on core one or more core elements and optinal additional elements. For example: A pizza (core) with toppings (additional).

Recommended Reading

Article

  • Theoretical walkthrough – Source Making – Blog
  • Practical walkthrough – Tutorialspoint – Blog
  • Practical walkthrough – Springframework Guru – Blog

Tools

  • Camtasia – Used for illustrations – Camtasia

Books

Video Tutorial 

  • Theoretical  (based on “Head-First: Design Patterns”) – Christopher Okhravi – YouTube
  • Practical – Derek Banas – YouTube
  •  

About

Hi, I'm the Author

My name is Daniel H. Jacobsen and I’m a dedicated and highly motivated software developer with a masters engineering degree within the field of ICT. 

I have through many years of constantly learning and adapting to new challenges, gained a well-rounded understanding of what it takes to stay up to date with new technologies, tools and utilities. 

The purpose of this blog is to share both my learnings and knowledge with other likeminded developers as well as illustrating how these topics can be taught in a different and alternative manner.

If you like the idea of that, I would encourage you to sign up for the newsletter.

Cheers! 🍺

Didn't Find What You Were Looking For?

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Scroll to Top
INTEGU - Cookie-consent

INTEGU uses cookies to personalize your experience and provide traceability for affiliate links. By using the website, you agree to these terms and conditions. To learn more see the privacy policy page.