TubeSum ← Transcribe a video

5 Design Patterns That Are ACTUALLY Used By Developers

0h 09m video Published Sep 8, 2023 Transcribed Aug 2, 2026 A Alex Hyett
Beginner 5 min read For: Beginner to intermediate software developers looking to understand common design patterns.
AI Trust Score 70/100
⚠️ Average / Some Fluff

"Delivers on the promise of five commonly used patterns with clear explanations and examples, though some patterns are common knowledge."

AI Summary

This video introduces the concept of design patterns in software engineering, explaining their origin and purpose. It then highlights five design patterns that the presenter finds most useful in practice, providing analogies and code examples for each.

[00:01]
Introduction to Design Patterns

Design patterns are typical solutions to common problems in software design, born from recognizing similarities in problems and solutions over time.

[00:44]
Analogy: Recipe vs. Birthday Party

An algorithm is like a recipe with step-by-step instructions, while a design pattern is like the concept of a birthday party—a reusable idea that can be adapted to different situations.

[02:05]
Gang of Four Book

In 1994, four authors wrote 'Design Patterns: Elements of Reusable Object-Oriented Software', documenting 23 design patterns, commonly known as the Gang of Four book.

[02:42]
Three Categories of Design Patterns

The 23 patterns are split into creational (object creation), structural (class composition), and behavioral (communication between objects).

[03:24]
Strategy Pattern

The strategy pattern allows you to define a family of algorithms, encapsulate each one, and make them interchangeable. It's useful for avoiding messy if/switch statements, e.g., different cake recipes or navigation modes.

[04:35]
Decorator Pattern

The decorator pattern lets you extend an object's behavior without modifying its original implementation, by wrapping it in a decorator class that implements the same interface.

[05:28]
Observer Pattern

The observer pattern is used to notify interested parties (subscribers) when something happens (publisher). It involves a publisher with subscribe/unsubscribe/notify methods and subscribers that implement an update method.

[06:21]
Singleton Pattern

The singleton pattern ensures a class has only one instance and provides a global point of access. It's useful for resources like database connections, but requires thread-safety measures like locking or using Lazy<T>.

[07:53]
Facade Pattern

The facade pattern provides a simplified interface to a complex subsystem, hiding implementation details and making code cleaner. It's useful for poorly designed libraries.

[08:59]
Refactoring Guru

The website refactoring.guru covers all 23 design patterns and is a great resource for learning and reference.

The video emphasizes that while there are 23 design patterns, only a handful are used frequently. Familiarity with all patterns helps in recognizing when to apply them, and resources like refactoring.guru are invaluable.

Mentioned in this Video

Study Flashcards (8)

What is a design pattern?

easy Click to reveal answer

A typical solution to a common problem in software design, a reusable concept that can be adapted to different situations.

00:30

How many design patterns are documented in the Gang of Four book?

easy Click to reveal answer

23

02:05

What are the three categories of design patterns?

easy Click to reveal answer

Creational, structural, and behavioral.

02:42

What is the strategy pattern used for?

medium Click to reveal answer

To define a family of algorithms, encapsulate each one, and make them interchangeable, avoiding messy conditional statements.

03:24

How does the decorator pattern work?

medium Click to reveal answer

It wraps an object in a decorator class that implements the same interface, allowing additional functionality before or after the original call.

04:35

What is the observer pattern?

medium Click to reveal answer

A pattern where a publisher notifies subscribers of changes, using subscribe/unsubscribe/notify methods and an update method on subscribers.

05:28

What is a common issue with the singleton pattern?

hard Click to reveal answer

It is not thread-safe; multiple threads can create multiple instances unless locking or Lazy<T> is used.

07:14

What is the facade pattern?

easy Click to reveal answer

A pattern that provides a simplified interface to a complex subsystem, hiding implementation details.

07:53

💡 Key Takeaways

💡

Analogy: Recipe vs. Birthday Party

Provides a clear and memorable distinction between algorithms and design patterns.

00:44
📊

Gang of Four Book

Historical reference to the foundational book that cataloged 23 design patterns.

02:05
🔧

Strategy Pattern Example

Practical example of using the strategy pattern to avoid messy conditionals in a cake recipe app.

03:24
⚖️

Singleton Thread-Safety

Highlights a common pitfall and solution for the singleton pattern.

06:21

Refactoring Guru

Recommends a valuable resource for learning all design patterns.

08:59

[00:01] so in today's video we're going to talk about design patterns now high level programming languages have been around since around the 1950s and since then solve all sorts of different problems over time programmers have realized that

[00:16] there's often some similarities between the problems and the solutions they're not exactly the same so you can't create a library or use an algorithm to solve it instead they would reuse some of the main ideas of the solution for the

[00:30] and eventually names were given to these typical Solutions and that is how design patterns were born so what is a design pattern if you're struggling to work out the difference between a design pattern and an algorithm then maybe this analogy

[00:44] will help so let's say it's my birthday tomorrow and my wife is going to bake me follow a recipe and this is going to give a step-by-step instructions on how to bake that cake the recipe in this case is an algorithm it's giving you

[00:58] step-by-step instructions on how how to bake a cake you can repeat over and over again to produce the same thing sure you might switch out some of the ingredients to produce different cakes but these are really just different input variables as

[01:10] it's my hypothetical birthday I also want to have a birthday party now if you head you're probably thinking about balloons and Banners and maybe someone out at least that's what you all think about now but everybody's idea of a

[01:26] there's no set steps to follow there's no recipe like you have with a cake essentially a birthday party is going to be different for every person like the problems that we face in software engineering but let's imagine that you

[01:39] you see what everyone else is thinking if everyone's thinking about a birthday party even though they're very different you would still recognize it as a birthday party the birthday party in this case is a design pattern it's the

[01:52] concept of a birthday party that can be reused even if everything else is slightly different hopefully that analogy makes sense but if it does let's have a look at what the design patterns actually are in 1994 four authors wrote

[02:05] down 23 design patterns in the book design patterns elements of reusable object-oriented software now obviously that's a bit of a mouthful it's not something you can talk about at a party for example so most people call

[02:17] it the gang of four book if you've been programming for a little while already some of the design patterns even without realizing it most of them are actually just common sense I know when I first started looking at them I recognized

[02:30] them immediately for patterns I use in my own code even if I gave them a slightly different name so we have 23 design patterns and these are split into three main groups we have the creational design patterns so these relate to

[02:42] creating objects in your code we have the structural design pattern so how we especially when they get quite large and finally we have the behavioral design between those objects and their responsibilities now you might be

[02:57] I'm never going to remember any of those but no one's really expecting you to know all 23 design patterns but it's worth looking through them all and being familiar with them so that when you do have a problem you can think ah that

[03:11] pattern and then you can go look it up and learn a bit more and see if it applies and the thing is out of all of these different design patterns there's only really five that I find myself using over and over again so let's have

[03:24] pattern we're going to look at is the strategy pattern now let's go back a bit to that cake baking analogy let's say you love cake so much that you decide to write an application that will give you cake recipes so let's say you start off

[03:37] with a birthday cake recipe but later you want to add in a red velvet cake and then a carrot cake now you could just do this with if statements and switch statements and add in all the cakes that way but then you want to add in a coffee

[03:50] cake and a lemon cake and all of these different cakes and eventually your code and it's all going to get really really messy and the thing is the code in your much about which cake you pick this is where the strategy pattern comes in you

[04:05] own classes and have each of them implement the same methods and then when have to do is run two methods get ingredients and get method and this is of achieving the same thing in your application let's say you've got a Maps

[04:22] application and you want to provide navigation via walking via car via cycling they're all going to have the same sort of functions but the actual for each of them this is definitely one pattern that's worth having in your

[04:35] toolbox to help you rightly encode the next pattern that I use the most is The now if you need to extend an object without actually changing the original implementation then The Decorator pattern is one way to do that now I've

[04:48] in my video about solid as it's one of the ways that you can make your code modification I'll put a link at the end haven't watched it already again this is one of the patterns that I've used

[05:01] without realizing it before whenever you wrap a class in another class you're effectively using The Decorator pattern the way we normally do this is to have interface as the component you want to extend and then in The Decorator

[05:15] Constructor we take in that component as an argument you can then implement the original component but now you can add in additional functionality either before or after you make that call number three is the Observer pattern

[05:28] this pattern is something you're probably very familiar with already even pattern before the Observer pattern is used whenever you want to notify interested parties that something has happened if your subscriber to my

[05:41] every Sunday you will get an email from me it's not sent to everyone who watches my YouTube videos or reads my blog it's only sent to those select few who have subscribed to my newsletter this is how the Observer pattern works you have a

[05:55] publisher that implements the Subscribe unsubscribe and notify subscriber methods you then have a subscriber interface that all the subscribers need to implement to let the publisher notify them when a subscriber subscribes to a

[06:08] publisher they get added to an array and then all the publisher needs to do is to Loop through that array calling the update method on all the subscribers now look at is the Singleton pattern now when we think about Singleton's we think

[06:21] about creating one thing of course we have things like Global variables that you can specify and be able to access anywhere in your code the problem with and that causes lots of different problems but there are cases where we do

[06:34] need to have a single object and make sure that we have a single object everywhere such as if you've got a database that you want to access you don't want a different connection to the database for every single time that

[06:46] to do this is to create a sealed class with a private Constructor having a outside of the class can create a new instance of it so you can't do new whatever you then create a separate method or a property that lets you

[07:02] create an instance of that class this is then stored in a static variable inside the class the problem with this code is is not thread safe you could have two threads call this code at exactly the same time they both reach that null

[07:14] check the instance would be null and they'd end up creating two instances of the same object now to get around this we need to have some form of locking mechanism so we need a way to stop the other threads from accessing the code if

[07:26] to do this we have the same initial null check but then we implement the lock and then we check again to see whether the instance is still null before then two threads from creating separate instances of the object

[07:40] another way to do this if you're using C sharp.net4 is with the lazy type it's still thread safe but it uses a lot less code the last pattern that we're going to look at is the facade pattern now this is one that's essential to software

[07:53] the facade pattern is all about Simplicity we're constantly using even though they save us time they can make our code messy and complicated and

[08:05] more than we actually need them to do let's say you're making use of a fictional logging library that isn't very well designed this Library can send logs to a file it can send it to the console and it can even send you a slack

[08:18] message the problem is this log Library only has one method called log and you request what type of log message it is as well as how you want to log in rather than clutter up your code with all these implementation details you can create

[08:32] methods that you can use throughout your code all of this messy code that's caused by this bad library is then just restricted to one class and if you do decide to change out the logging library then you only have one place to change

[08:45] it and the rest of your code doesn't need to be affected so these are the know a lot of other developers do too but there's another 18 patterns that we having a look at them so you're familiar with them if you have them in the back

[08:59] least something about them when you come to solve a problem there's a great website called refactoring.guru that covers the 23 design patterns from the use them it's definitely worth bookmarking so you can reference it

[09:12] later on if you like this video as I mentioned earlier I have a video on thank you for watching and I'll hopefully see you in the next video hopefully see you in the next video foreign

More from Alex Hyett

View all

⚡ Saved you 0h 09m reading this? Transcribe any YouTube video for free — no signup needed.