Generics vs. Inheritance: When to Use Each in Game Development

preview_player
Показать описание
Generics and inheritance are two powerful tools in programming, each with unique strengths and use cases. In this video, we explore their differences and practical applications, particularly in game development. You’ll learn when to leverage generics for type safety and code reusability, when inheritance excels for shared functionality, and how to combine the two effectively for cleaner, more maintainable code. By the end, you’ll confidently know which approach to choose and why.

Want to support me? 😀

#unity3d #gamedev #indiedev

▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬

0:00 Generics vs. Inheritance
4:00 Refactoring
8:00 Builder and Factory
11:13 Enforcing Types

More Useful Code:

Assets Shown In This Video (Affiliate Links)

*Follow me!*
Рекомендации по теме
Комментарии
Автор

Happy Sunday! Hope everyone is having a great holiday! 👍

git-amend
Автор

I've read so many books to understand what git-amend is saying, and I've grown up to the point where I can finally understand what he's saying by watching the video. I'm proud of myself.

정동우-nx
Автор

I was teaching C# to a great group of students back when C# 2.0 released with generics (2005 - ouch). We were so blown away by how amazing it was - and I still learn new ways to use generics to this day.

TheArghnono
Автор

I appreciate the consistency and clarity of your videos. And great advice, as always

Wbjpen
Автор

This is such a great video, especially as your game grows in complexity. I wasn't expecting another video over the holidays, have a great one and looking forward to the new year!

silchasruin
Автор

Thanks for another PRO video! Super useful. Great topic, quality and great audio commentary understandable even for non-native speakers :) Thanks a lot Adam!

jackieczech
Автор

Appreciated as always, Combining inheritance and generics is powerful indeed!

kpm
Автор

As always, really informative, well-explained and to the point.

oldshamen
Автор

Great video! Never thought about adding a second generic type (T, TResolver) like that to enforce types, thanks!

prometheus
Автор

Always happy to see a new git-amend video notification. Thanks for all you do for the community. Happy new year and I wish the best for you in 2025. Cheers! 🎉

colourfulseal
Автор

Thanks for your new video! Very helpful & useful for me to understand better

akiruiruwan
Автор

Thanks for the great video! Happy Sunday!

rutchjohnson
Автор

I just recently graduated from a beginner Unity/c# course and learning from you seems like the next best step for me. I have almost the exact "noob" code that you showcased so I was wondering, aside from watching all your videos, do you have any other resources an absolute noob like me would love? Much appreciated and happy holidays sir 🎉

carbo
Автор

I hope you start making videos for UE5 C++ . The community needs you!!! I dodnt use unity anymore but as a software engineer i like watching every single video you make.

AlexSW
Автор

For the animations in the Intro, did you use motion matching or did you code/use a "normal" animation system for the turn animations?
I am curious because if you didnt use motion matching i would be interested on how you coded this "state"

derbabonennt
Автор

5D game dev!

Love how this lesson just added pattern after pattern after pattern. 😂

Genuine question here - when you know how each pattern implementation is adhering to SOLID principles (builder, factory, injection, interfaces, inheritance, generics), it gets easier to build this functionality out with scalability and extensibility in mind, knowing that extra effort now saves bloat further down the line... But, in the middle ground of intermediate coding, these things are not necessarily clear and so all the extra pieces mean we go from a single albeit bloated and inflexible class to a complex set of relations that might be difficult to track without that knowledge of how patterns can work together.

To my mind, it's two kinds of complexity, that one is fundamentally flexible while the other does NOT scale well.

So, question, would you keep all of these classes used to build out the functionality in a single file, or a single folder as a strategy for not having to jump around a half dozen files just to see how your basic functionality is put together? I guess I'm wondering how you maintain that umbrella concept for the functionality so that it doesn't get lost amid all the moving parts?

Like I said, i think with more experience, it's less taxing to decompose mentally the 'what' and 'why' of each sub element, so maintaining a complex web of relations and purposes is easier.

Squared
Автор

Love the video! Hope 2025 is a great year for you and your channel!

vSwaize
Автор

Yeah! :D
I hit the like button before i even watch your videos now...

suntonio
Автор

Nice! I really Enjoyed the part where ironman took on the hulk in this scene.

damonfedorick
Автор

my brain kinda stopped braining, almost feels like too much at once, even tho i can understand everything

andrelisboa