We may earn an affiliate commission when you visit our partners.
Course image
Dmitri Nesteruk

Course Overview

This course provides a comprehensive overview of Design Patterns in Java from a practical perspective. This course in particular covers patterns with the use of:

  • The latest versions of the Java programming language

  • Use of modern programming approaches: dependency injection, reactive programming and more

  • Use of modern developer tools such as IntelliJ IDEA

  • Discussions of pattern variations and alternative approaches

Read more

Course Overview

This course provides a comprehensive overview of Design Patterns in Java from a practical perspective. This course in particular covers patterns with the use of:

  • The latest versions of the Java programming language

  • Use of modern programming approaches: dependency injection, reactive programming and more

  • Use of modern developer tools such as IntelliJ IDEA

  • Discussions of pattern variations and alternative approaches

This course provides an overview of all the Gang of Four (GoF) design patterns as outlined in their seminal book, together with modern-day variations, adjustments, discussions of intrinsic use of patterns in the language.

What are Design Patterns?

Design Patterns are reusable solutions to common programming problems. They were popularized with the 1994 book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, John Vlissides, Ralph Johnson and Richard Helm (who are commonly known as a Gang of Four, hence the GoF acronym).

The original book was written using C++ and Smalltalk as examples, but since then, design patterns have been adapted to every programming language imaginable: C#, Java, PHP and even programming languages that aren't strictly object-oriented, such as JavaScript.

The appeal of design patterns is immortal: we see them in libraries, some of them are intrinsic in programming languages, and you probably use them on a daily basis even if you don't realize they are there.

What Patterns Does This Course Cover?

This course covers all the GoF design patterns. In fact, here's the full list of what is covered:

  • SOLID Design Principles: Single Responsibility Principle, Open-Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion Principle

  • Creational Design Patterns: Builder, Factories (Factory Method and Abstract Factory), Prototype and Singleton

  • Structrural Design Patterns: Adapter, Bridge, Composite, Decorator, Façade, Flyweight and Proxy

  • Behavioral Design Patterns: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Null Object, Observer, State, Strategy, Template Method and Visitor

Who Is the Course For?

This course is for Java developers who want to see not just textbook examples of design patterns, but also the different variations and tricks that can be applied to implement design patterns in a modern way. For example, the use of recursive generics helps us build fluent interfaces even when inheritance is involved.

Presentation Style

This course is presented as a (very large) series of live demonstrations being done in IntelliJ IDEA and presented using the Kinetica rendering engine. Kinetica removes the visual clutter of the IDE, making you focus on code, which is rendered perfectly, whether you are watching the course on a big screen or a mobile phone.

Most demos are single-file, so you can download the file attached to the lesson and run it in IntelliJ, Eclipse or another IDE of your choice.

This course does not use UML class diagrams; all of demos are live coding. I use IntelliJ and various Maven packages where necessary.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Recognize and apply design patterns
  • Refactor existing designs to use design patterns
  • Reason about applicability and usability of design patterns

Syllabus

Introduction

An overview of the different topics that we'll encounter in this course as well as some info on the way the course is organized and a few words about the instructor (that's me!)

Read more
Learn about the SOLID design principles used in software engineering
Overview

The Single Responsibility Principle (SRP) states that a class should have a single reason to change (i.e., one primary responsibility). The opposite of an SRP-adhering class is an antipattern called God Object.

A look at the Open-Closed Principle (OCP) through the prism of the Specification pattern. Two for the price of one! :)

The Liskov Substitution Principle (LSP) suggests that you should be able to substitute a base class for a derived class. What does it mean? Watch the lesson to find out.

The Interface Segregation Principle (ISP) suggests that you split interfaces into smaller interfaces so that clients don't have to implement things they don't need. Also related to the YAGNI (You Ain't Going to Need It) principle.

The Dependency Inversion Principle (DIP) states that high-level modules should not depend on low-level modules but on abstractions. I also suggests a preference for depending on abstractions (interfaces/abstract classes) over concrete implementations.

Summary
Learn to implement the Builder design pattern

A brief note about the three categories of design patterns: creational, structural and behavioral.

An overview of the Builder design pattern.

There's at least one well-known builder in Java: the StringBuilder. But what problem does it solve, exactly?

Let's implement our own builder for constructing HTML lists!

Fluent interfaces allow multiple calls of a builder to be called as part of a single invocation chain.

And you thought recursive generics were just for Enum? No way! They are also useful when inheriting from classes that have fluent interfaces.

Sometimes the object is complicated enough so that you need more than one builder. This lesson illustrates how several related builders can interact with one another through inheritance and a fluent interface.

Builder Coding Exercise

A summary of all the things we've learned about the Builder design pattern.

Learn about the Abstract Factory and Factory Method design patterns

An overview of the Factory design pattern.

Having a static function for making an object allows us to avoid overloading problems. We can have two factory methods with identical sets of parameter types, but different names.

Let's relocate all factory methods to a separate class. We have a problem: private field are no longer accessible!

The Abstract Factory design pattern allows you to create hierarchy of factories corresponding to a hierarchy of types those factories create.

Factory Coding Exercise

A summary of all the thing we've learned about the Factory design patterns.

Learn to implement to Prototype design pattern

An overview of the Prototype design pattern.

If we have Object.clone() and the Cloneable interface, why don't we just use them?

How can we be explicit about the fact we are making a deep copy? From the land of C++ comes the idea of making copy constructors.

If your object graph has 10 classes in it, making 10 copy constructors (or dedicated cloning methods) is unrealistic. But we can automate the copying process via serialization.

Prototype Coding Exercise

A summary of all the things we've learned about the Prototype design pattern.

Learn about the much-maligned Singleton pattern

A look at all the things we'll learn about the Singleton design pattern.

Let's implement the simplest possible singleton!

Even though a constructor is private, there are at least two ways of instantiating it. The obvious way is with the use of reflections. A less obvious ways of accidentally replicating the singleton is with the use of serialization.

If the singleton constructor can throw, you can initialize the singleton instance in a static block instead.

We discuss two concerns of the Singleton: lazy instantiation and thread safety.

Thread safety issues can be mitigated via the use of a nested class.

A singleton that exposes itself as an enumeration instance. No problem with reflection or serialization, except... you cannot serialize field values. Also, you cannot inherit from this singleton.

The Monostate design pattern is a peculiar variation on the Singleton. It's not very practical, but can be used as a 'last resort' whenever Singleton-like behavior needs to be added without breaking existing API usage.

A multiton is a Singleton-like key-value store with (optional) lazy loading.

Why is the Singleton so disliked? One reason is testability. Let's take a look at how a Singleton can become problematic for testing.

The only socially acceptable way of using a Singleton is via dependency injection: either done by hand or, preferably, through the use of a Dependency Injection framework.

Singleton Coding Exercise

A summary of all the things we've learned about the (not-so-scary) Singleton design pattern. This concludes our investigation of Creational design patterns!

Learn to implement the Adapter design pattern

An overview of the Adapter design pattern.

We consider a scenario where vector objects need to be rendered in raster form... this requires an Adapter!

Quite often, implementation of Adapter generate temporary objects. We can implement caching to make sure we're not regenerating them on ever instance of adapter creation.

Adapter Coding Exercise

A summary of all the things we've learned about the Adapter design pattern.

Learn to implement the Bridge design pattern

An overview of the things we are going to learn about the Bridge design pattern.

A demonstration of vector/raster rendering with the Bridge design pattern using both manual instantiation as well as automation using Google Guice.

Bridge Coding Exercise

A summary of the things we've learned about the Bridge design pattern.

Learn to implement the Composite design pattern

An overview of the things we are going to learn about the Bridge design pattern.

We illustrate an implementation of a Composite design pattern with an object that can (optionally) contain child objects.

A slightly more complicated demo where we get a scalar object to behave as an Iterable<> and also implement a default interface method!

Composite Coding Exercise

A summary of all the things we've learned about the Composite design pattern.

Learn to implement the Decorator design pattern

An overview of the Decorator design pattern.

One well-known final class is String. So if we want to give additional behaviors, we need to introduce our own String-like class and then delegate the members. Luckily, IntelliJ IDEA helps here!

Let's build a set of decorators for geometric shapes. These decorators are all composable, so you can mix and match!

If you want to predefine the composition of decorated types at compile-time, you can do it with Java generics, but you'll have to jump through hoops due to type erasure.

A look at a hybrid of two patterns, the Adapter and the Decorator.

Decorator Coding Exercise

A summary of the things we've learned about the Decorator design pattern.

Learn to implement the Façade design pattern

An overview of the Facade pattern.

Financial trading systems often need large monitoring consoles that display aggregated data across multiple markets and bots. A typical text console is a complicated beast, but we can provide extra APIs to make it more palatable.

A summary of what we've learned about the Facade design pattern. And yeah, no exercise in this section of the course. Sorry. What can I say, this is one of the more boring/obvious patterns. Write a Facade for your own system instead!

Learn to implement the Flyweight design pattern

A look at the Flyweight design pattern.

Imagine an online game with lots of players with similar names. Do you really want to repeat the string "Smith" a thousand times? I don't think so.

Another implementation of Flyweight - this time, to save some memory when formatting text!

Flyweight Coding Exercise

A summary of the things we've learned about the Flyweight design pattern.

Learn to implement the Proxy design pattern

An overview of the Proxy design pattern.

A protection proxy controls access to a particular resource or, in other words, performs some sort of checks or validation before allowing or disallowing the underlying operation.

Field assignments are difficult to intercept and control. What we can do is replace each field with a corresponding Property<> class that has getters and setters as methods, and interception can happen in those methods.

Dynamic proxies are proxies constructed at runtime. Here we build a dynamic proxy for recording the number of times each object's method was called.

What is the difference between a Proxy and a Decorator?

Proxy Coding Exercise

A summary of the things we've learned about the Proxy design pattern.

Learn to implement the Chain of Responsibility design pattern

An overview of the Chain of Responsibility design pattern.

The simplest implementation of a Chain of Responsibility involves calling a chain of handle() methods.

An explanation of the concept of Command Query Separation (CQS).

Let's take a look at a much more sophisticated example of CoR, combining also the Observer and Mediator design patterns.

Chain of Responsibility Coding Exercise

A summary of the things we've learned about the Chain of Responsibility design pattern.

Learnt to implement the Command design pattern

An overview of the Command design pattern.

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Develops and enhances knowledge and skills of design patterns at all levels, from beginner to advanced learners
Covers a wide range of patterns, from fundamental creational to advanced behavioral patterns, providing a comprehensive understanding
Utilizes modern approaches such as dependency injection, reactive programming, and IntelliJ IDEA, making it applicable to contemporary development practices
Leverages a variety of approaches, including discussions, demonstrations, and coding exercises, to cater to diverse learning styles
Offers thorough explanations, code examples, and hands-on exercises for each pattern, ensuring a practical understanding
Emphasizes industry relevance by using real-world scenarios and aligning with current development standards

Save this course

Save Design Patterns in Java to your list so you can find it easily later:
Save

Reviews summary

Highly recommended design patterns course

According to students, this course is highly recommended. The course is very complete and each design pattern is expertly explained. The pace is quick and there will likely be times when you need to replay portions of the course to fully understand. Dmitri has a unique gift at explaining and his coding skills are impressive.

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Design Patterns in Java with these activities:
Review code
Refamiliarize yourself with basic Java syntax.
Browse courses on Java
Show steps
  • Go over old code
  • Go over basic exercises from the book "Effective Java"
  • Practice writing code that implements the Strategy and Factory design patterns
Read "Design Patterns: Elements of Reusable Object-Oriented Software"
Provide a comprehensive overview of design patterns and their application.
Show steps
  • Read the book
  • Take notes
  • Practice implementing design patterns in Java
Solve LeetCode problems
Practice solving LeetCode problems to improve problem-solving skills.
Show steps
  • Pick a few problems from LeetCode
  • Solve the problems
  • Go over the solutions
Four other activities
Expand to see all activities and additional details
Show all seven activities
Follow tutorials on Udemy
Provide step-by-step guidance on implementing design patterns in Java.
Browse courses on Design Patterns
Show steps
  • Search for tutorials
  • Follow the tutorials
  • Practice implementing design patterns in Java
Help other students with design patterns
Provide an opportunity to reinforce knowledge by teaching others.
Browse courses on Design Patterns
Show steps
  • Identify students who need help
  • Provide guidance and support
Build a Java application that uses design patterns
Provide hands-on experience in applying design patterns to real-world scenarios.
Browse courses on Java
Show steps
  • Design the application
  • Implement the application using design patterns
  • Test the application
  • Deploy the application
Write a blog post about design patterns
Provide an opportunity to summarize and share knowledge about design patterns.
Browse courses on Design Patterns
Show steps
  • Choose a topic
  • Research the topic
  • Write the blog post
  • Publish the blog post

Career center

Learners who complete Design Patterns in Java will develop knowledge and skills that may be useful to these careers:
Software Engineer
Software Engineers are responsible for designing, developing, and maintaining software applications. This role requires a strong foundation in computer science fundamentals, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course can be helpful for Software Engineers by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Software Engineers learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Software Architect
A Software Architect is responsible for designing, developing, and maintaining software applications. This role requires a deep understanding of software design principles and patterns, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course can be helpful for Software Architects by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Software Architects learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Java Developer
Java Developers are responsible for developing and maintaining Java applications. This role requires a strong foundation in the Java programming language, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course can be helpful for Java Developers by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Java Developers learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Technical Lead
Technical Leads are responsible for leading a team of developers and ensuring that a project is completed on time and within budget. This role requires a deep understanding of software development principles and practices, as well as the ability to effectively communicate with a team of developers. The "Design Patterns in Java" course can be helpful for Technical Leads by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Technical Leads learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Software Consultant
Software Consultants are responsible for providing advice and guidance to businesses on how to use software to improve their operations. This role requires a deep understanding of software development principles and practices, as well as the ability to effectively communicate with a variety of stakeholders. The "Design Patterns in Java" course can be helpful for Software Consultants by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Software Consultants learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Web Developer
Web Developers are responsible for designing and developing websites. This role requires a strong foundation in web development technologies, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Web Developers by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Web Developers learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Project Manager
Project Managers are responsible for planning and executing projects. This role requires a deep understanding of project management principles, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Project Managers by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Project Managers learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Systems Analyst
Systems Analysts are responsible for analyzing and designing business systems. This role requires a deep understanding of business processes, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Systems Analysts by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Systems Analysts learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Mobile Developer
Mobile Developers are responsible for designing and developing mobile applications. This role requires a strong foundation in mobile development technologies, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Mobile Developers by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Mobile Developers learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Quality Assurance Analyst
Quality Assurance Analysts are responsible for testing and validating software applications. This role requires a strong foundation in software testing techniques, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Quality Assurance Analysts by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Quality Assurance Analysts learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Product Manager
Product Managers are responsible for managing and developing products. This role requires a deep understanding of product development principles, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Product Managers by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Product Managers learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Data Scientist
Data Scientists are responsible for collecting, analyzing, and interpreting data. This role requires a strong foundation in data science techniques, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Data Scientists by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Data Scientists learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Business Analyst
Business Analysts are responsible for analyzing and designing business processes. This role requires a deep understanding of business processes, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Business Analysts by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Business Analysts learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Data Analyst
Data Analysts are responsible for collecting, analyzing, and interpreting data. This role requires a strong foundation in data analysis techniques, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Data Analysts by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Data Analysts learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.
Database Administrator
Database Administrators are responsible for managing and maintaining databases. This role requires a deep understanding of database management systems, as well as the ability to work with a team of developers to bring a project to fruition. The "Design Patterns in Java" course may be helpful for Database Administrators by providing a comprehensive overview of all the Gang of Four (GoF) design patterns. This course can also help Database Administrators learn how to apply these patterns to real-world projects, leading to more efficient and maintainable code.

Reading list

We've selected 13 books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Design Patterns in Java.
역시 디자인 패턴을 소개하는 한국어 책이에요. 이 책은 초보자를 대상으로 디자인 패턴을 설명하고 있어요.
Covers design patterns for microservices, which are a popular architectural style for modern applications.
Provides a comprehensive guide to domain-driven design, which software design approach that focuses on the business domain.

Share

Help others find this course page by sharing it with your friends and followers:
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser