Refactoring C# with Chain of Responsibility

  Рет қаралды 7,765

Gui Ferreira

Gui Ferreira

Күн бұрын

Пікірлер: 48
@OrgesKreka
@OrgesKreka Жыл бұрын
Please do another video on design patterns!
@gui.ferreira
@gui.ferreira Жыл бұрын
Any Design Pattern, in particular, you would like to see?
@kostasgkoutis8534
@kostasgkoutis8534 Жыл бұрын
I would like to see a video on Pipes and Filters pattern and on State Machines. Together with the Chain of Responsibility, Mediator, and Rule Engine patterns, they form (for me) a logical "pipeline patterns" group (maybe with the Monad pattern as well).
@gui.ferreira
@gui.ferreira Жыл бұрын
That's a big list 😁 Thanks for sharing
@nucasspro1
@nucasspro1 Жыл бұрын
Thank you so much, after watching this video, now I realize asp net core pipeline is following this pattern
@gui.ferreira
@gui.ferreira Жыл бұрын
Excellent and accurate observation! I'm happy you find this video useful.
@ahmet9424
@ahmet9424 Жыл бұрын
Great sample app 👍 Thank you.
@gui.ferreira
@gui.ferreira Жыл бұрын
Glad you like it! Thanks!
@sunnypatel1045
@sunnypatel1045 Жыл бұрын
I be keep to see your experience with observer and visitor design patterns
@gui.ferreira
@gui.ferreira Жыл бұрын
I'm likely doing one on Visitor soon.
@gui.ferreira
@gui.ferreira Жыл бұрын
Here it is the video on the Visitor Design Pattern kzbin.info/www/bejne/r6quo6dtr7igrJI
@FreeMindInMotion
@FreeMindInMotion Жыл бұрын
Great explanation. Visitor pattern would be interesting
@gui.ferreira
@gui.ferreira Жыл бұрын
Noted 😉 Anything, in particular, you would like to see on the Visitor Pattern?
@FreeMindInMotion
@FreeMindInMotion Жыл бұрын
For me the visitor use case is difficult to identify. That's why I chose it 😀 Maybe you have a good example pointing out the double polymorphic dispatch.
@FreeMindInMotion
@FreeMindInMotion Жыл бұрын
Taking your example with the order I think it could be used, if you have IOrder, PriorityOrder and NormalOrder. Both need to be handled by the different Handlers, but differently by each or at least some handlers based on their concrete type without type checking.
@gui.ferreira
@gui.ferreira Жыл бұрын
@@FreeMindInMotion Let me think about it 😁
@gui.ferreira
@gui.ferreira Жыл бұрын
Here it is the video on the Visitor Design Pattern kzbin.info/www/bejne/r6quo6dtr7igrJI
@moab5102
@moab5102 Жыл бұрын
Thank you that's an excellent video I would like a tutorial about rule engine or specification design pattern keep up the good work
@gui.ferreira
@gui.ferreira Жыл бұрын
Thanks for the suggestion. Added to the content idea list 😉
@saqibali7066
@saqibali7066 Жыл бұрын
Good example, Please do explain strategy design pattarn.
@gui.ferreira
@gui.ferreira Жыл бұрын
Added to the pipeline! Anything, in particular, you would like to see on Strategy Pattern?
@saqibali7066
@saqibali7066 Жыл бұрын
@@gui.ferreira how the flow goes ? Is loading web project configuration dynamically is good example mean either I can read configuration from web.config or from dynamoDB
@gui.ferreira
@gui.ferreira Жыл бұрын
@@saqibali7066 I published it weeks ago: kzbin.info/www/bejne/lZy5aJ-GhLF8idk
@saqibali7066
@saqibali7066 Жыл бұрын
@@gui.ferreirathanks
@starterdev
@starterdev Жыл бұрын
Show us all the design patterns 🥰
@gui.ferreira
@gui.ferreira Жыл бұрын
There's a new one comming soon. 😉
@patbeansoo
@patbeansoo Жыл бұрын
Good stuff. Subscribed :)
@gui.ferreira
@gui.ferreira Жыл бұрын
Thanks, Vince! Welcome aboard!
@vagnerwentz1189
@vagnerwentz1189 Жыл бұрын
What is this IDE? JetBrains?
@gui.ferreira
@gui.ferreira Жыл бұрын
JetBrains Rider 🤘
@SimonLomax-qw3dv
@SimonLomax-qw3dv Жыл бұрын
What colour theme are you using?
@gui.ferreira
@gui.ferreira Жыл бұрын
Hi! Dracula for Rider plugins.jetbrains.com/plugin/12275-dracula-theme
@LucasSantos-yw4nh
@LucasSantos-yw4nh Жыл бұрын
Do you see any performance downgrade between Chain Of resposibility and Strategy Pattern? Also, is there any technique to find the the best order to fit the handlers in the chain?
@gui.ferreira
@gui.ferreira Жыл бұрын
To be honest, they solve different problems, so it's not fair to compare them. Regarding the order, it depends on the problem they are solving. In the example from the video, order matters. But, in some cases, the Order can be ignored. For example, if you want to apply Authorization restrictions, you may want to start with the least resource-intensive ones. Long story short, it depends on the domain and business context. Did my answer help? 😅
@LucasSantos-yw4nh
@LucasSantos-yw4nh Жыл бұрын
@@gui.ferreira Yeah, it helped, thanks. But I still think both design patterns solve the open closed principle in order to create new behaviors without the need to change the class. I would like to know more about your point that it solves different problems.
@gui.ferreira
@gui.ferreira Жыл бұрын
@@LucasSantos-yw4nh When I say that they solve different problems it's because Strategy is about having a generic interface that you can use to provide different implementations. On the other hand, a Chain of responsibility is about having a chain of objects which usually go from more detailed to more generic. So, you may solve the same problem with both, but not all the problems.
@xmadcode
@xmadcode Жыл бұрын
The Chain Of Responsibility and the Pipeline Patterns would make a fair comparison, not as with the Strategy Pattern, in my opinion
@SteveNgaiCheeWeng
@SteveNgaiCheeWeng Жыл бұрын
can we also refactor it with DDD?
@gui.ferreira
@gui.ferreira Жыл бұрын
Not sure what you are thinking about. For sure, the service/application can be modeled using DDD. However, Design Patterns like the Chain of Responsibility are useful even with DDD. Can you detail your question?
@ghevisartor6242
@ghevisartor6242 Жыл бұрын
I wonder if this is correct to use in a case where i don't have a commonality like a "discount approval" but regardless i need to check a bunch of conditions, for example for deleting a file. Basically to get those conditions, in one i have to check the database, in another just some of the file properties. By separating these into their own handler, now i have the DbContext for example just in the first handler and not the other. So i end up with "IsFileInUseHandler", "IsFileOlderThanHandler" and then lastly "DeleteFileHandler" where i do File.Delete(filePath). It seems to work fine and simplify the code, but as you can see from the naming it sounds odd, also the last handler is actually having side effects. Am i trying to force a square in a circle?
@gui.ferreira
@gui.ferreira Жыл бұрын
You are building a pipeline, which is a common practice here. As an example, I've seen many implementations similar to the one you mention in MediatR pipelines (which is a Chain of Responsibility).
@alexandrgoncharov5074
@alexandrgoncharov5074 Жыл бұрын
thank you for the video. great explanation
@gui.ferreira
@gui.ferreira Жыл бұрын
Glad you liked it 🙏 Thanks for taking the time to write feedback.
@xmadcode
@xmadcode Жыл бұрын
The strategy pattern
@gui.ferreira
@gui.ferreira Жыл бұрын
Added to the list! 😉 Anything you would like to see on Strategy Pattern?
@xmadcode
@xmadcode Жыл бұрын
@@gui.ferreira an overview of the pattern with a simple real life implementation in C#, and how can someone spot a use case for the pattern, would a make a great video ;)
@gui.ferreira
@gui.ferreira Жыл бұрын
@@xmadcode Thanks for the Tip. I will think about it!
FINALLY, the Visitor Design Pattern makes Sense
11:03
Gui Ferreira
Рет қаралды 9 М.
Chain of Responsibility to the Rescue!
9:15
Zoran Horvat
Рет қаралды 12 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Building better DTOs in C#
11:57
Gui Ferreira
Рет қаралды 7 М.
MediatR Validation and the Chain of Responsibility Pattern
10:22
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 264 М.
Factory Pattern in C#: Creating Objects with Ease
12:54
campbelltech
Рет қаралды 19 М.
Chain of Responsibility Pattern - DESIGN PATTERNS (C#/.NET)
19:16
SingletonSean
Рет қаралды 2 М.
What’s the Result Type Everyone Is Using in .NET?
14:47
Nick Chapsas
Рет қаралды 114 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,4 МЛН
Просто о SOLID (Принципы SOLID)
15:54
webDev
Рет қаралды 224 М.
Why all your classes should be sealed by default in C#
11:43
Nick Chapsas
Рет қаралды 93 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН