FINALLY, the Visitor Design Pattern makes Sense
ฝัง
- เผยแพร่เมื่อ 28 ก.ย. 2024
- Let's explore the Visitor Design Pattern while we refactor C# dotnet code.
💎 Be a Patreon to get the source code: / gsferreira
🚨 KEY LINKS
🤝 Support me on Patreon (and get access to source code) here: / gsferreira
👋 HEY FRIEND
If you're new to my Channel, my name is Guilherme, but you can call me Gui if Portuguese pronunciation is not your thing.
I see myself as a Minimalist Software Craftsman. That says a lot of what I talk about here.
So, why this TH-cam channel? To share with you to simplify your life as a Developer through knowledge, technology, and practices.
If you are into those things as I do, don't forget to subscribe for new videos.
🔗 GET IN TOUCH
LinkedIn: / gferreira
Twitter: / gsferreira
GitHub: github.com/gsf...
Visit my blog: gsferreira.com
#dotnet #csharp
Thanks Gui. Loved the (dynamic)this hint. It makes perfect sense and is so simple (now that I've seen it)
Great to hear, John! Thanks for taking the time to leave a comment.
Great video. I think the strategy pattern may be a better fit for this example but visitor is still great. You are making great c# content. Keep up the good work
Thanks! I think the Strategy Pattern can solve the same problem but doesn't give you the same benefits as the Visitor when you have a Composite.
Thanks for the kind words, Tristan!
Very good explanation, thanks!
Glad you enjoyed it!
Hi Gui, can you tell me what IDE are you using?
Hey Francisco!
JetBrains Rider.
The problem with the visitor pattern is fundamental.
It breaks readability. It lacks domain understanding.
To "Visit" isn't a verb with meaning.
While I agree, I find the idea of isolating the Methods into Objects quite useful, you only have to modify the code in one class without breaking anything else
@@ppg68 - I'm needs based. I never really found a need for this pattern. And when I see it used, it's never relevant, reads horrible, and fails to convince me that I need it. Just like the bridge pattern. Things start getting too pattern happy after a while...
Its a replacement for a type switch case
The visitor is an attempt to implement a functional pattern in an OO language. But C# is getting more functional so now the visitor pattern can elegantly be replaced by pattern-matching expressions.
This was brilliant.
Thank you 🙏
real world scenario, all those permutations will be stored in the database? so need really to create many classes?
You don't need to apply the visitor design pattern to domain or DB objects. It's a useful pattern for things like parsing or formatting
Hi Gui, do you have a video going through your IDE setup (themes, fonts, extensions)? If not, I think you should make one. What font are you using in this video?
Hi! Thanks for the suggestion. I'm not sure if I want to do a video on this channel about it, but I will try to find a way to have that information out there.
Regarding the Font, on the video, I'm using JetBrains Mono.
Nice video. I have never used the pattern, but I will keep my eyes open.
I like the dynamic type hint for the base class
Glad you liked it 🙏
In fact, it's rarely used but it's good to know how it works.
Great content. Although, I think its way too zoomed in
That's great feedback! Thanks! I've been using Presentation mode lately. I will revisit it 😉
Still doesn't make sense for c# because you can use pattern matching which will be faster.
As option the extension methods for the particular type can replace this pattern
Not that you can't do it in other ways in C#, but even then, it's not an "apples to apples" comparison.