8 Design Patterns EVERY Developer Should Know

preview_player
Показать описание

Checkout my second Channel: @NeetCodeIO

While some object oriented design patterns are a bit outdated, it's important for every software engineer to understand the most important ones. I cover several of my favorite ones in this video.

0:00 - Intro
0:45 - Factory
1:35 - Builder
2:23 - Singleton
3:38 - Observer
5:12 - Iterator
6:28 - Strategy
7:18 - Adapter
8:22 - Facade

#design #patterns #python
Рекомендации по теме
Комментарии
Автор

A cool thing happens if you learn programming by yourself: after some time you start to implement these patterns without knowing them formally. Most often they are more clumsy than the original but the spirit is there. Really cool how patterns are just a result of efficient and modular thinking.

jse-shack
Автор

This was a good introduction! I will say, because they are the usually the most talked about, there are some things that are worth elaborating further on in regard to creational design patterns:

Factories aren't just about fabricating objects. One of the big advantages is that they disconnect how an object is made from where it might be needed to be created. The best part of factories are that they can be instantiated and shared and passed between code. Otherwise, they're just a set of default constructors. They're often considered outdated because most languages have first class functional support these days. A function that takes no arguments and returns a new thing when called can usually be passed around. This is essentially the same as a factory.

Builders aren't necessarily identified by their methods that can be easily chained. You can have builders that don't do this and they're still a builder. They're useful, like the factory, for when you have pass them around to other code. For example, you might have a lot of code that wants a say in how an object is created. It lets you spread the logic for how something is created over multiple places and build it once everything has had its input. It also lets the final result be immutable if you would prefer, making it mutable during creation and allowing for the resulting object to say "no more changes!"

Singletons are great but hard to test. Best practice is to make a singleton extend some kind of interface class and provide the instance to the code that needs it, either as-is or via a factory. This lets you swap it out when you do testing. Otherwise, you're locked into always using that global state in your tests and it gets harder to work with!

Comet
Автор

Been putting off reading head first design patterns for a long time.
This seems like an excellent intro to each concept that I can now find more references to

Ryukachoo
Автор

I'm a Java developer since 2008, and I LOVE your punches towards Java 😍 they are to much fun and true

RaveKev
Автор

NeetCode is to coding to what The Organic Chemistry Tutor is to all school subjects, everything is clear and easy to understand when you guys teach it!!

vhbatistela
Автор

The facade reminds me of some subs/functions that I have in one of my libraries that are too dangerous to handle directly so I added safer wrapper subs/functions around it, which can each be used depending on the required features. It's also kinda like a factory, but not quite.

DrewTNaylor
Автор

Nice refresher.

On the topic of GoF patterns, many of them may seem outdated or unnecessary for inclusion as patterns because for modern developers many of these patterns are even included at language level as basic features, however, it was much different back then when OOP was just taking off in enterprise world.

blackplaydoh
Автор

Awesome explanation! This is a life-saver when it comes to quick brush before the interview! 😄Thank you so much for making this video!

gauravprabhu
Автор

This is a really nice video, well worth subscribing to this channel for. I hope you turn this into a series and cover more patterns in the future.

Themerp
Автор

Hey NeetCode, thanks for the succinct breakdown of these patterns. I am an engineer, but not a dev, and don't really use these patterns, but in areas such as IaC just as an example, it's interesting to think about how I could implement concepts introduced in these patterns. Loved your analogies so I could visualize these concepts better. Thanks!

phillipgilligan
Автор

Appreciate you breaking it down so thoroughly while making it easy to understand!

Remember working with a senior engineer who would talk about a few design patters he implemented but he couldn't always explain it effectively. This was very well done! Motivated to get back to learning these patters on my own now! Thanks!

thomasmendez
Автор

These examples are easy to digest and understand, great video

deltoidx
Автор

What a great and simple to understand video! Thank you

LOLorMrLOL
Автор

This is really great stuff, I cannot tell you how much your videos have helped in solving questions while I am hunting jobs. The way you explain concepts with such intuitive examples is something I have not seen before. Please keep posting awesome content like this.

ajith
Автор

Thanks man you explained it so well I am never gonna forget. Please keep posting videos like this. 👍

adityasahu
Автор

Please never stop making videos. You have a gift for teaching. Your S-tier ability to explain topics is amazing.

thomash
Автор

This makes more sense than the semester long course I had on design patterns

riyanahmed
Автор

you're great at teaching thank you for letting me brush up on my knowledge of these things

paultaylor
Автор

Love the vid! Much more concise than my CS Object Oriented class

notzarp
Автор

I use these but never really bothered to learn the formal definitions. Seems a bit dated in today's patchwork of random NPM libraries engineering, but still fun to finally link the names to the faces!

darkwoodmovies
welcome to shbcf.ru