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

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

ความคิดเห็น • 81

  • @git-amend
    @git-amend  18 วันที่ผ่านมา +14

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

  • @정동우-n2x
    @정동우-n2x 18 วันที่ผ่านมา +27

    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.

    • @git-amend
      @git-amend  18 วันที่ผ่านมา

      Nice work!

    • @정동우-n2x
      @정동우-n2x 18 วันที่ผ่านมา

      Personally, I've used 'generic 'to template some patterns. So when I use some patterns, I use them to modify the templates. I think generic is really useful.

    • @정동우-n2x
      @정동우-n2x 18 วันที่ผ่านมา

      @@git-amend thank you!

    • @ScottPrice7
      @ScottPrice7 18 วันที่ผ่านมา +3

      Lol I'm with you. I thought i was a good programmer but, git-amend is on another level and I have a hard time following

    • @priskon5950
      @priskon5950 18 วันที่ผ่านมา +2

      What kind of books would you recommend?

  • @TheArghnono
    @TheArghnono 18 วันที่ผ่านมา +11

    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.

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +2

      Haha! Was it that long ago! Still one of the languages best features!

    • @unitydev457
      @unitydev457 18 วันที่ผ่านมา +1

      Wow 2005 eh? When I first learned about them back in 2013 in college I felt like I’d discovered a cheat code. They’re so powerful they feel like they’re cheating

  • @Wbjpen
    @Wbjpen 18 วันที่ผ่านมา +4

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

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      I appreciate that!

  • @jackieczech1777
    @jackieczech1777 18 วันที่ผ่านมา +4

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

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      Your welcome! Thanks for the comment!

  • @prometheus1100
    @prometheus1100 18 วันที่ผ่านมา +4

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

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      Thank you! Glad it was helpful!

  • @silchasruin4487
    @silchasruin4487 17 วันที่ผ่านมา

    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!

    • @git-amend
      @git-amend  17 วันที่ผ่านมา

      Glad you enjoyed it! Happy Holidays!

  • @GTZ-98
    @GTZ-98 5 วันที่ผ่านมา

    I've got so many ideas on how I could implement these things into my game just watching this video. Another banger, extremely helpful!

    • @git-amend
      @git-amend  5 วันที่ผ่านมา

      Awesome, really glad to hear that!

  • @colourfulseal2595
    @colourfulseal2595 18 วันที่ผ่านมา +1

    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! 🎉

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      Thank you, same to you! Lots more to come!

  • @kpm25
    @kpm25 17 วันที่ผ่านมา

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

    • @git-amend
      @git-amend  17 วันที่ผ่านมา

      Thank you!

  • @oldshamen
    @oldshamen 17 วันที่ผ่านมา

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

    • @git-amend
      @git-amend  17 วันที่ผ่านมา

      Much appreciated!

  • @akiruiruwan
    @akiruiruwan 17 วันที่ผ่านมา

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

    • @git-amend
      @git-amend  17 วันที่ผ่านมา +1

      You're welcome! I'm glad it was helpful.

  • @rutchjohnson
    @rutchjohnson 18 วันที่ผ่านมา

    Thanks for the great video! Happy Sunday!

    • @git-amend
      @git-amend  18 วันที่ผ่านมา

      Thank you! Same to you!

  • @512Squared
    @512Squared 18 วันที่ผ่านมา +5

    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.

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +4

      Thanks for the comment! I think a lot of that comes down to your own workflow. For me personally, I tend to keep things in the same file until I feel it 'makes sense' to move a logical section into it's own file. I don't like jumping around multiple files any more than I like scrolling either, so I tend to use the shortcuts in the IDE to navigate. On bigger projects, I will also start drawing the relationships between systems, or class diagrams as well, in Excalidraw. The more experience you have, the easier it becomes to hold multiple abstractions in your mind at the same time, but everyone has their limit. Another good strategy is to employ good naming conventions - that really helps to easy the mental taxation.

    • @512Squared
      @512Squared 18 วันที่ผ่านมา

      I guess in a way, thinking about what you want to be able to do also guides those early design decisions - I want multiple loot drop types (generics + inheritance), multiple sets of conditions to work with those multiple loot types (interface for resolvers), a set method for dropping loot that will handle the resolver too, then we need to be able to create and initialize our loot drop types (factory).
      It's mapping and meeting all these needs that drives the design.

    • @512Squared
      @512Squared 18 วันที่ผ่านมา

      @@git-amend yeah, that makes sense. Cheers

    • @suntonio7187
      @suntonio7187 18 วันที่ผ่านมา +1

      @262,144 I totally get where this question comes from, i wondered about that too ;)
      I think functionnality is better at start, and to quote @git-amend i learnt a lot trying to refactor a bloated yet functionnal system into a more organised, abstracted, pattern friendly system.
      But sometimes i lost myself in these refactoring, and ended up loosing interrest. Also code readability can indeed be a pain, with too much inheritance escpecialy, you forget the inherited methods and so on jumping from file to file is annoying.

  • @AlexSW3303
    @AlexSW3303 18 วันที่ผ่านมา +1

    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.

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +2

      Haha, maybe one day! Thanks!

  • @carbo740
    @carbo740 17 วันที่ผ่านมา

    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 🎉

    • @git-amend
      @git-amend  17 วันที่ผ่านมา

      Thanks! If you join the Discord, in the #programming section there is a pinned list of books that are worth reading. I also recommend following Zoran Horvat and Iain McManus on TH-cam.

    • @carbo740
      @carbo740 16 วันที่ผ่านมา

      @git-amend I tried to join the discord through your links but it said the link has expired or is no longer available. This might be a me issue though!

  • @torylva
    @torylva 15 วันที่ผ่านมา

    I've always likened it to this with the example of moving objects.
    Is it a vehicle? Use a inheritance (car takes from vehicle, racing car takes from car, etc etc)
    Is it something that just moves? Use a generic.
    When I am not sure what it is going to be, I prefer using generics.
    When you KNOW what it is going to be, I prefer using inheritance. Then you can of course inherit from the generic.

    • @git-amend
      @git-amend  14 วันที่ผ่านมา

      That's a good analogy, I like that.

  • @derbabonennt8876
    @derbabonennt8876 18 วันที่ผ่านมา

    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"

    • @derbabonennt8876
      @derbabonennt8876 18 วันที่ผ่านมา

      nvm found your description-links...

  • @damonfedorick
    @damonfedorick 18 วันที่ผ่านมา

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

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +2

      Make sure you hit the bell for notifications, in case TH-cam mistakes you for a bot and unsubs you!

    • @damonfedorick
      @damonfedorick 18 วันที่ผ่านมา +2

      ​@@git-amend Apparently, comments on videos trigger the algorithm. Since Marvel rivals are topping the 'Gaming' category, this should appear in people's feeds.

  • @grzegorzpedrycz2630
    @grzegorzpedrycz2630 18 วันที่ผ่านมา

    Best moment of every weekend;)😅

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      You just made my day!

  • @vSwaize
    @vSwaize 16 วันที่ผ่านมา +1

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

    • @git-amend
      @git-amend  16 วันที่ผ่านมา

      Thank you! Same to you!

  • @suntonio7187
    @suntonio7187 18 วันที่ผ่านมา +1

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

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      Thank you! And the algorithm thanks you too!

    • @suntonio7187
      @suntonio7187 18 วันที่ผ่านมา

      @@git-amend Unity is an hobby to me, i wish i had taken a path to work in the game industry years ago, but i didnt.
      I learnt C# on my own, because i like challenge, and honestly i find programing very rewarding. (well i'm kinda old so i was taught basic and turbo pascal in the early 90's, but i dont work everyday with programming languages).
      What i know for sure is teaching and pedagogy, that i do everyday... And let me tell you, you are good at teaching, very good!
      I want to thank you for these in depth short lessons. I'm watching them over and over when i want to try a new system implementation in my project.
      I *think* you've upgraded my coding a lot in the past months, so thanks!

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +2

      Haha, I remember Turbo Pascal... and BASIC too of course! Thankfully we've moved beyond GOTO statements. Thanks for the comment!

    • @Luciphear
      @Luciphear 18 วันที่ผ่านมา

      ​@@suntonio7187 I don't think I've learned this much from any other channel or even teacher (in person), honestly. I do make use of ChatGPT a lot to help me discover questions more than answers, so that's the second best learning source for me so far, and I often end up here to get a better understanding, hah. It's great!
      Successfully implemented a ton of things so far into my project (and extending/modifying a lot to suit my needs) and that's made things so, so much easier for me to progress. It's fun.

  • @jumpkut
    @jumpkut 18 วันที่ผ่านมา

    Another amend from the git! 🎉

    • @git-amend
      @git-amend  18 วันที่ผ่านมา

      Thank you!

  • @stefantippi1
    @stefantippi1 18 วันที่ผ่านมา

    Thanks for the great video :)

    • @git-amend
      @git-amend  18 วันที่ผ่านมา

      My pleasure!

  • @klevialushi571
    @klevialushi571 18 วันที่ผ่านมา +1

    my new favourite youtuber

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      Thank you!

  • @andrelisboa7193
    @andrelisboa7193 18 วันที่ผ่านมา +1

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

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +2

      I get that-it’s a lot to absorb at once, but if you already understand everything, you’re closer to mastering it than you might think!

  • @nsyndm
    @nsyndm 18 วันที่ผ่านมา

    Ty

    • @git-amend
      @git-amend  18 วันที่ผ่านมา

      You're welcome!

  • @damonfedorick
    @damonfedorick 18 วันที่ผ่านมา +2

    Composition before either xD

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +2

      In some cases, I'd agree... th-cam.com/video/mAfpfUYhpAs/w-d-xo.html

  • @검은모래
    @검은모래 18 วันที่ผ่านมา

    it's so good.

    • @git-amend
      @git-amend  18 วันที่ผ่านมา

      Thanks for watching!

  • @nightyonetwothree
    @nightyonetwothree 17 วันที่ผ่านมา +1

    modularity > generics > inheritance

  • @TheKr0ckeR
    @TheKr0ckeR 18 วันที่ผ่านมา

    Thanks for your time, effort on that new T();
    and in enemy class
    [SerializeField] private AbilityData, enemy needs to fill "T" here by class definition. I dont want to know what ability I should pass, I only pass the ability I want by serialization. So I found myself planned bad while trying to abstract the system. Its like chain, when you create smth. generic, you somehow need to fill that. I think i misusaged it.

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      Thanks for the comment. One thing to keep in mind is that you can create classes that have a generic and a non-generic version. In fact, you probably already use them. For example, Task and Task.

    • @TheKr0ckeR
      @TheKr0ckeR 18 วันที่ผ่านมา

      @@git-amend Thanks for the idea. I ended up using non-generic version. :'D.
      By the way, I see you use Activator.CreateInstance a lot, whats the difference of creating new class where we define T where T : new(); and create it directly.
      What do you mean by creating dynamically? Is it related to garbage or smth?
      And another question is, do you find using UI toolkit worth now? For example should i make it as "main tools" for canvas? I am using unity's canvas system but planning to learn UI toolkit in deep and use it for every project. Of course canvas is easier and faster to implement but i find myself using "web style" is feeling good.
      Thanks for your reply.

    • @git-amend
      @git-amend  18 วันที่ผ่านมา +1

      Great question! The new keyword is used when you know the type at compile time and want to create an instance. Activator.CreateInstance is used when you don’t know the type until runtime and want to instantiate it dynamically. This isn’t related to garbage collection but rather about flexibility.

    • @TheKr0ckeR
      @TheKr0ckeR 18 วันที่ผ่านมา

      @@git-amend Oh, that would be extremely useful for editor scripts!