Тёмный

How to Implement the Decorator Pattern in C# 

Tech With Pat
Подписаться 9 тыс.
Просмотров 2 тыс.
50% 1

In this video, we'll explore the Decorator design pattern and how to implement it in C#. The Decorator pattern is part of the Gang of Four design patterns and it allows you to add behavior to objects dynamically. This makes it a powerful technique for extending the functionality of an object at runtime without affecting other objects. We'll cover the basics of the Decorator design pattern, including its structure, and advantages. We will then go step-by-step through an example implementation of the Decorator pattern in C#. By the end of this comprehensive guide, you'll have a thorough understanding of the Decorator design pattern and know how to apply it to your own projects in C#.
Subscribe for more content like this: ru-vid.com...
Support the channel: www.buymeacoffee.com/itsmepat...
Where you can find me:
💻 Github: github.com/techwithpat
🌐 Website: www.techwithpat.com
🕴️ LinkedIn: / patrick-tshibanda-4310...
en.wikipedia.org/wiki/Decorat...
#csharp #designpatterns

Опубликовано:

 

15 апр 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 8   
@Takayaki42
@Takayaki42 Год назад
These tips on design patterns are lit, mr. Pat! Thank you so much!
@cverde1234
@cverde1234 Год назад
I remember discussing this pattern with you back in 2018 after a team member put try...catch clauses in nearly all methods 😂. Keep up the good work Patrick 👌😁
@TechWithPat
@TechWithPat Год назад
I remember... 🙂
@williamliu8985
@williamliu8985 Год назад
Nice explanation! I have one question, if I use DI to get the instance of service, and all these three services implement the same interface, how to resolve them then? thanks!
@TechWithPat
@TechWithPat Год назад
William, you can use DI to get the initial instances, but if you need to get instances dynamically, that could be difficult to achieve. Overall, I think the best way would be to use a Factory.
@williamliu8985
@williamliu8985 Год назад
@@TechWithPat Thanks for your reply!
@witChaos
@witChaos Год назад
Don't you break the open close principal with the second example? Would it be better to made this size check in the implementation of Resize class, before return the SaveFile?
@TechWithPat
@TechWithPat Год назад
That's a valid option, I hesitated to include this check in the Resize class.
Далее
Decorator Pattern - DESIGN PATTERNS (C#/.NET)
14:51
Просмотров 6 тыс.
The Trump rally shooting from a photographer's POV
00:58
Кто быстрее? (GTARP)
19:19
Просмотров 453 тыс.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Decorator Pattern - Design Patterns (ep 3)
54:35
Просмотров 477 тыс.
Factory Pattern in C#: Creating Objects with Ease
12:54
Design Patterns: Decorator
17:21
Просмотров 25 тыс.
The Trump rally shooting from a photographer's POV
00:58