Structural Patterns (comparison) – Design Patterns (ep 12)

preview_player
Показать описание
Video series on Design Patterns for Object Oriented Languages. This time we compare a few structural patterns.

💙 BUY MY BOOK:

CORRECTION: At 2:10 I draw a has-a arrow from the concrete decorators to the abstract decorator. This is a mistake. The arrow should be drawn from the abstract decorator to the component. Otherwise the pattern doesn't work. Sorry about that, and thanks Naman Saxena for pointing it out! Later in the video I put letters in the boxes. Expressed in letters the arrow should go from D to C. Mea culpa.

More specifically:

Adapter Pattern
vs
Proxy Pattern
vs
Facade Pattern
vs
Decorator Pattern
vs
Bridge Pattern

...and then we throw in Strategy Pattern in the end :)

► The playlist

► Head First: Design Patterns

► Design Patterns: Elements of Reusable Object-Oriented Software

💪 Patreon Community

📚 Products I Recommend
Рекомендации по теме
Комментарии
Автор

Seeing all 6 of those UML diagrams on one board is a great way to see just how different or similar the various patterns are.

chrisjust
Автор

Here's a silly story I've made up to memorize and fit it all together 😁

On Fridays one guy likes to finish the day with a shot of plain rum, actually he used to distill it on his own, but that was too complicated process so he started buying bottles in a local shop, which is a great FACADE that removes all the complexity and pain of production process away from him.
Couple months later he decides that plain rum is good but maybe it might taste better when DECORATED with lemon and other ingredients. But damn he's too lazy so he heads to a local bar. Apparently, that bar is a limited club, so in order to get in, he gotta know a friend who's already a club member (PROXY) who could tell the security he's cool enough to get in.
The security guy is angry and just mumbles something, but our man happened to recognise some phrases in Spanish so he ADAPTED to the situation and replied in that language. That made the security guy smile so he happily allows this gringo to enter!
Finally our man reaches out to the bartender who is standing behind the counter, which in fact resembles a BRIDGE between all of the party people and the bottles of various spirits on the shelves.

And they all SHOUT OUT to Chris and wish him luck with his book :)

Artem
Автор

00:03 Comparison of structural patterns: bridge, adapter, decorator, proxy, and facade
02:02 Structural patterns like decorator and facade provide ways to simplify complex interactions.
06:15 Proxy pattern is used to control access to a real subject
08:19 Bridge pattern involves an abstraction and an implementer with multiple concrete implementations
12:21 The adapter pattern converts the interface of a class into another interface that the client expects.
14:32 Facade simplifies a complex subsystem, while Adapter adapts from one interface to another.
18:23 The proxy pattern provides a surrogate or a placeholder for another object to control access to it.
20:18 Proxy pattern is used to control access to a single thing, while decorator pattern is used to solve the problem of class explosion and treat different combinations of classes as a special case.
23:36 Structural patterns like Decorator and Proxy solve different problems.
25:23 The bridge pattern decouples an abstraction from its implementation.
29:10 Strategy pattern is about dependency injection
31:00 Bridge pattern is a flexible way of coupling classes using interfaces.
34:20 Facade pattern simplifies complex subsystems by providing a simpler interface.
35:50 The video discusses the importance of books in learning and working with object-oriented programming.

safvanp
Автор

I can confirm that the bridge pattern is a natural conclusion, because I did it in my app the other week without knowing it's a pattern, and then watched your bridge pattern video the other day which pleasantly surprised me, since it means my design makes sense. In fact, it was even more or less the same example you used with different media types being used for the same UI components/widgets.

TheJustinmulli
Автор

The decorator pattern UML has a small problem. The D has C instead of CD has D.

liangzeng
Автор

Christopher, your teaching style is exceptional, and I truly appreciate the clarity and depth you bring to these complex concepts. Thank you so much for sharing your knowledge in such an engaging manner.

The idea of you writing a book is incredibly exciting! It's definitely going to be an amazing contribution to the field. Looking forward to delving even deeper into these fascinating topics through your upcoming book.

safvanp
Автор

It really amazes me how much of these discussed patterns really are things that we use often without even noticing. That being said, it is really important to sometimes sit down and define what they really mean and what they are applied for (or when they make the most sense). Great video as always, Christopher!

michor
Автор

This is a remarkable effort to help anyone getting the concepts right away with such simplicity and ease. Thanks!

wilwazka
Автор

One of the best video comparing Structural Patterns on youtube today - Thanks mate.

suvaaich
Автор

With this comparison, I realized that the abstract decorator is a proxy for the concrete component.

Super series! Thanks. Waiting for the next one.

Diego-dbuw
Автор

Binge watching the series... this was a very needed comparison between things that seemed related but nebulous before this instruction. Thanks for the lesson.

seanbuckmaster
Автор

wow -- this video is just great, especially sort of seeing the bridge pattern as a more general form as strategy pattern

andryushkax
Автор

Q: Dumb Questions
Is it possible to create your own Design Patterns? Or is that something you have to be a “patterns guru” to do?
A: First, remember that patterns are discovered, not created. So, anyone can discover a Design Pattern and then author its description; however, it’s not easy and doesn’t happen quickly, nor often. Being a “patterns writer” takes commitment.
You should first think about why you’d want to – the majority of people don’t author patterns; they just use them. However, you might work in a specialized domain for which you think new patterns would be helpful, or you might have come across a solution to what you think is a recurring problem, or you may just want to get involved in the patterns community and contribute to the growing body of work.
(c) Head First

mildlyinteresting
Автор

I gotta say...there are maybe 3 people who teach coding that I get a whole lot from. Jeffrey Way, Caleb Portzio, Luke Downing, and now you. You're a very good teacher my man

rkonTheAutomator
Автор

I don't know how to say that But I Just want to appreciate you for making this playlist, Its awesome

hassangholipoor
Автор

Videos like this are really helpful because they also help to do a quick revision of previous concepts.

mazhar
Автор

Super interesting video for me. I think it's the first time I actually understand many of these patterns. Thank you!

LeandroTabaj
Автор

32:00 "Programming is discovered rather than invented", I really like that and helps a lot with understanding where these design patterns stem from. :)

leomeror
Автор

This comparison video is very helpful to identify and choose the most suitable pattern for a specific problem.

sarenodev
Автор

I got a habit of saying 'SUPER' before everything. You are super talented.
Thanks for this series :)

sagarsati