Stop using the AS Operator (so much) - Visitor Design Pattern - C# Tutorial

preview_player
Показать описание
Really, there are so many reasons why you shouldn't rely too much on the *as* operator. In this video, I'll talk about a pattern you can use to avoid using the *as* operator: the *Visitor*.

For more Coding & Gamedev related content, follow me on Twitter:

If you have some questions regarding my tutorials, feel free to ask them on the Discord Server:

Thank you to the YouTube Audio Library for providing the music.

0:00 Intro
1:44 The Visitor Design Pattern
3:57 Example: RTS Units
6:09 Caveats
8:25 Outro
Рекомендации по теме
Комментарии
Автор

There are of course some cases where it's ok to use the is/as operators in your code.
What cases do you tolerate ?

fluffygamedev
Автор

I seriously have no idea how you only have 800 subs. I said the same thing to another channel last year and she just hit 20k. Hope you see the same results, your content is on point.

jonathanjblair
Автор

Complex and better script script:*exists*
Me: uses mostly "if" statements xd

teo-chan
Автор

I don't get it, why not just use the strategy pattern and give the method you want to a unit with scriptable object? You would need only one unit script and it would call the method you give it with an SO. Why go threw the hassle of this pattern?

violon