USE COMPOSITION trust me.

Поділитися
Вставка
  • Опубліковано 22 гру 2024

КОМЕНТАРІ • 456

  • @betatester03
    @betatester03 5 місяців тому +889

    I'm not pointing this out to be pedantic, I promise, but what you've called a behavior tree is a hierarchical state machine. A behavior tree is a fundamentally very different approach to a logic control structure. The ONLY reason I point this out is because you have an audience of new developers and this could cause a lot of confusion over time as this misunderstanding propagates outward and with state machines and behavior trees both being fundamental approaches to game AI.
    Similar to the way Roblox kids call incremental/idle games "simulators", which are something else entirely, or how so many younger people say "literally" when they mean "figuratively". It creates a communication barrier between two generations that makes it more difficult for lessons to be passed down.
    New devs have to fight through a lot of confusion and endure a lot of frustration in their journey to becoming intermediate devs and these kinds of misunderstandings can make the harder parts of the learning curve even harder.
    The misnomer aside, you did an excellent job of communicating some useful concepts that are usually hard earned through experience and that's very difficult to do well. I sincerely hope you keep making content like this because you're an excellent communicator and we really don't have enough of those in the world.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +124

      @betatester03 Yeah I know I put it in the description of the video that I mixed those up.
      I was looking for a different name to call the nodes and I called it a "Behaviour Tree" and it stuck I had no idea my bad.
      I made the correction in the description

    • @NoTimeLeft_
      @NoTimeLeft_ 5 місяців тому +23

      Not a new developer but a thankful one.
      I've encountered my fair share of incomplete or confusing tutorials developing my game (vids under channel).
      I appreciate the effort to help the community !

    • @ince55ant
      @ince55ant 5 місяців тому +19

      just to play off you're pedantry, the word "literally" has been used to mean "figuratively" for basically as long as the word has recorded use, so lets not blame the kids for this one. the video lays out the logic behind what has been made so really the only problem that can arise is a viewer using the term "behaviour tree" to some 3rd person whom either corrects the viewer or misunderstands what they're talking about. which really isnt that big of a deal (i mean if they're actually in a serious production situation, then it would be corrected by someone senior)

    • @diadetediotedio6918
      @diadetediotedio6918 5 місяців тому +5

      They can be structurally equivalent tho, it just depends on how you implement the states of the hierarchical state machine.

    • @Hellbending
      @Hellbending 5 місяців тому +9

      Massive respect for the way you voiced your opinion in a thoughtful, constructive and still courteous way- god I wish more people spoke with respect like this.

      Also mad respect to the channel owner for acknowledging and responding in a reasonable manner too ❤

  • @erasercs
    @erasercs 5 місяців тому +147

    Whatching that video feels like sitting at some jazz cafe in a noir detective movie

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +18

      Because of the music choice?

    • @AloisMahdal
      @AloisMahdal 5 місяців тому +11

      @@NesiAwesomeness Music, but also the way you speak, the overall mood. It's really relaxing.. :)

    • @TheThunder005
      @TheThunder005 Місяць тому

      ​@@NesiAwesomenessyeah the voice is great as a narrative voice over and falls into that noir feeling... like a Dick Tracy movie solving complex coding pitfalls one inference and inheritances class at a time! Nice work

  • @xlerb2286
    @xlerb2286 4 місяці тому +13

    Some of the best advice I've ever heard was "Favor composition over inheritance". In 30+ years of software development there have been very few times when I've found non-trivial inheritance to be of use. But I'm constantly finding composition to be useful.

  • @JustSteve85
    @JustSteve85 5 місяців тому +85

    I really appreciate your explanation, Nesi. This is exactly why I dropped modding ArmA 3 and decided to just make my own damn game with Godot. Everything custom in A3's config scripting inherits from base classes at the top of the game asset inheritance tree, which results in having to redefine or add unnecessary lines to turn off certain features to each custom class, while the original class is still technically the overriding class, meaning to add new stuff you have to inherit from the base class all of its code, and if you want to change anything in your custom class at the bottom you usually have to hunt down and modify lines that pertain to what you want to change. In this example of a state machine, you can not only pick and choose what to inherit from but you're not stuck with pre-packaged components you might not even use. It's just smarter and more efficient to work with.

  • @Hysorix
    @Hysorix 5 місяців тому +77

    This coding style is one I've gradually moved towards over time. I didn't realize it until watching this. I always thought I was using inheritance, but it turns out I was employing a hybrid approach. I use this method when writing full-stack programs, and it has saved me so much trouble because it's easier to swap out modules and functions without breaking everything.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +13

      @@Hysorix I actually spent some time with functional programming and just gravitated towards other styles of coding

  • @williammonden871
    @williammonden871 Місяць тому +1

    I've been trying to understand the different methods of this kind of implementation because all of my code is horrible and awful and terrible. But I've never been very good at understanding the videos, but this has been probably the best example I've seen. Thanks!!

  • @HakanBacon
    @HakanBacon 5 місяців тому +3

    Thank you for sharing your ways. It is really helpful to see how people manage their structures, and yours seem not only organised, but functional

  • @davidsolair7879
    @davidsolair7879 4 місяці тому +2

    Loved this video. I've seen other explanations of behavior trees and state machines for game development that seemed to overcomplicate the communication between nodes. This was a great video!❤

  • @joemama-j8b
    @joemama-j8b 5 місяців тому +53

    The problem with inheritance is not necessarily itself, but the fact that people use it in places that they are not supposed to. It is a principle like any other in software development/computer science, and like any other principle, you need to think about if, and how you should implement it. Its common use probably stems from the fact that it gets taught the earliest in university/courses, and alternatives are taught either later or not at all. A different way to mitigate the problems that you referenced is the decorator pattern, but I would not recommend it, since it can get overly complicated quick, especially if there is a lot of divergence between the classes that exist. I am currently not involved in any projects that would need OOP principles, but if I find myself in a situation like that in the future, I will give it a try.
    I enjoyed the video, good job. The editing is really good.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +6

      Definitely, the point of the video was never to tell people to abandon it just to be careful and in some cases prefer composition

    • @TuberTugger
      @TuberTugger 5 місяців тому +3

      The problem with inheritance is it's not visible. Nothing warns you that the class you're editing is a child. Only if it's a parent and only one level deep.
      Composition flattens the inheritance tree and makes code intention very transparent.
      The video's example of composition wasn't correct. Composition shouldn't have multiple levels. It's all at the top.

    • @Wyvernnnn
      @Wyvernnnn 3 місяці тому

      The problem with the infinite flaming laser 3d printer is not the 99.99% injury rate, it’s that 99.99% of the people shouldn't be using it. It's that simple!

  • @S_Tone_Rock
    @S_Tone_Rock 5 місяців тому +20

    Good video structure. I can tell you that you're a lot easier to understand than other channels I've watched on UA-cam and the reason why that is, is because when you are about to explain something you take short breaks before explaining everything and even when you do explain everything you also are taking short breaks in-between each chunk of information to let the viewers mind catch up with the information you're saying. I would say that in the future try to think of doing this more often because it really helps the viewer (me) and also, I can say that it makes you stand out as a content creator as well.
    Keep up the hard work Nesi. 🙏

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +7

      @@S_Tone_Rock thank you, that was exactly what I was going for. It was something I decided one when I came back to watch my own video.
      I just felt like there were too many points where I had to actually pause.
      It's nice to know I made the right call, I will definitely continue

  • @BatteryAcidDev
    @BatteryAcidDev 5 місяців тому +2

    What a great video and well explained! Becoming more familiar with composition is fundamental for Godot devs. Plus, the delivery and composition of your video is fantastic! Keep it up! Subbed! Thank you!

    • @BatteryAcidDev
      @BatteryAcidDev 5 місяців тому +1

      Also, I don't think this content is considered "long" - since it's a technical topic, feel free to deeper dive into those 15-30+ minute videos. Editing does get a bit more involved though 😅

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +1

      Thanks so much

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +1

      My usual videos are 3 to 4 minutes to 10 minutes is kind of long for me.
      I'm going to start trying to make videos like 7 to 12 minutes of much longer

    • @BatteryAcidDev
      @BatteryAcidDev 5 місяців тому

      @@NesiAwesomeness Sounds good!

  • @anon_y_mousse
    @anon_y_mousse 5 місяців тому +4

    This is probably the best explanation and comparison of the two I've seen yet. All of only one thing is never good, but instead you mix and match them. And sometimes, as you show here, neither inheritance nor composition are the best choice and thus you go to a state machine, or in other cases some different construct, where that is most appropriate.

  • @ahumanb3ingthatexists67
    @ahumanb3ingthatexists67 8 днів тому

    One thing to keep in mind for anyone using composition and overall just trying their best to make good code:
    PROTOTYPING IS GOOD, DO IT!
    You do NOT want to be the person that spends a year (learning how to and then) creating a versatile system full of state machines and scripts for every little thing you could ever need only to then find out that Godot's 3D hinges are the most confusing thing ever and therefore you either need to spend god knows how long learning the intricacies of Godot's physics engine to make a version of them that does what you want or just give up the project entirely.
    BEING ABLE TO JUST MAKE SOME *REALLY* **REALLY** BAD CODE SO YOU CAN FIGURE OUT WHAT TO DO IS REALLY GOOD!
    also this is a really good video and i will use similar things in my projects now thank you

  • @hamoodhabibi7026
    @hamoodhabibi7026 День тому +1

    OMG I litearlly was thinkging the same thing and i didn't know what to do ;.; ... ty for conceptualizing it

  • @nkacey2000
    @nkacey2000 5 місяців тому +5

    love these educational / devlog style of a vids

  • @Noober666
    @Noober666 4 місяці тому +2

    Really enjoy your style of editing, keep up the grind 👍

  • @majdbitar1891
    @majdbitar1891 4 місяці тому

    Great video, keep up the good work man!

  • @mgan59
    @mgan59 4 місяці тому

    Loved the video especially the end product with the attached debugger to see state displays on the entities

  • @JasonStorey
    @JasonStorey 5 місяців тому +1

    Great video! Composition is definitely a far more flexible way to compose complex ideas. One small note though, that just might come across a bit confusing to people new to the ideas watching the video, Composition and OOP are not different paradigms. OOP is an umbrella term for a collection of ideas _including_ Encapsulation, Inheritance and Polymorphism. with Polymorphism (the **is a** relationship being considered the weaker of the tools relative to composition the **has a** relationship.) As a programmer myself I always love watching the way people solve problems. awesome work!

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      I never said Composition was a paradigm, it's a code pattern, OOP is the paradigm.
      Thanks for the notes, maybe it was confusing

  • @jaaakkals
    @jaaakkals 3 місяці тому +1

    This is a valid approach in many regards, my issue however is with separating behaviours into nodes. If you want to expand upon a project and have a large scale scene with many behaviours, there will be a significant performance cost with the huge amount of nodes. In conclusion, this is perfect for small scenes with few nodes, but not advisable if you want to craft a large game that is also performant.

  • @pinglebon770
    @pinglebon770 4 місяці тому +6

    Hey congrats on tackling that tech debt. It always surprises me that no matter how long I've been coding I always accumulate tech debt like this and have to go back to refactor it.

  • @XionicalXionical
    @XionicalXionical 5 місяців тому +203

    As an OOP pilled dev, the randomize function seems like an oversight in the first place. That sort of manipulation of variables upon creation of the object would be better done in the constructor method. You can have as many constructors with different method signatures as you want. Usually, for this sort of operation, you would have a blank constructor, say, titan(). This would initialize the object, and you could use it to set values randomly. Then you would have another constructor, say, titan(String name, int hp, int speed) and set the in scope variables using those values. There would be no need for creating subclasses.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +26

      @@XionicalXionical it was a crude example, it's an excuse to just use Titans to explain because I thought it would be interesting.
      They're better examples, some issues I've come across were from a similar situation of something I predefined conflicting with something else I want to now inherit from.
      If you've never run into issue then that's amazing because like I said OOP is great they're just some cases.
      I'd also highly recommend trying Composition. I've found it easier, that's my personal preference

    • @TheOnlyGhxst
      @TheOnlyGhxst 5 місяців тому +12

      I personally think OOP has no place in game programming, and a purely functional style is much more suitable.

    • @christianbrenner984
      @christianbrenner984 5 місяців тому +23

      @@TheOnlyGhxst Is there any game engine that supports purely functional programming?

    • @lunarthicclipse8219
      @lunarthicclipse8219 5 місяців тому +37

      Purely functional is sadly horrible for performance. It's good for most event driven logic, but NEVER in a game loop​@TheOnlyGhxst

    • @TheOnlyGhxst
      @TheOnlyGhxst 5 місяців тому +3

      @@lunarthicclipse8219 There are ways to optimize it quite heavily. If I remember correctly I believe the Jak and Daxter games were made with a custom in house engine that was purely functional and made with Lisp.

  • @steve_rico
    @steve_rico 5 місяців тому +1

    Really enjoyed your explanation and use of examples

  • @ImperiumLibertas
    @ImperiumLibertas 5 місяців тому +7

    The pattern when combining the singleton and observer patterns to manage state is called a reactive store or observable store.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +2

      @@ImperiumLibertas I've learnt more from these comments than the research I did for this video 😂

    • @ImperiumLibertas
      @ImperiumLibertas 5 місяців тому +1

      @@NesiAwesomeness the best way to learn is by building and teaching. Great video, your explanation of -behavor trees- hierarchical state machines was great.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      @@ImperiumLibertas I'm never going to love this down 😂
      I didn't know you could cross out words on UA-cam

  • @blackandwhite7402
    @blackandwhite7402 2 місяці тому +1

    Nice, I actually didn't see it coming to use behaviour trees in the plane and the camera ✌️ I learned something new

  • @erumabo
    @erumabo 5 місяців тому

    Your video gave me some good ideas.
    For some reason I was trying to implement those behaviors/actions/states using events, and that let to some weird phenomenon like a character who can negate dead, dying before triggering the skill.
    Using states is much more sensible.
    Also, OOP is the paradigm, Inheritance is a property of OOP, and Composition is a pattern of OOP. You have some concepts mixed up there, but the general idea is well explained.

  • @Nik-dz1yc
    @Nik-dz1yc 5 місяців тому +2

    Very good video that got recommended to me exactly when I needed it since im about to run into the same issues

  • @andycusatti5845
    @andycusatti5845 5 місяців тому +1

    The hardest part here is being organized and knowing how to separate the stages. Create the entire workflow and then couple each stage together.

  • @DeepFriedOreoOffline
    @DeepFriedOreoOffline 2 місяці тому

    This is an amazing video! Composition, or ECSs are extremely useful and something that people tend to either misunderstand, or ignore. However, I do wish you had a better example than Titans because Titans are actually an amazing example of where Inheritance would shine bright. For the main reason that there are thousands of them. The way you describe composition is such that you can apply components to your entity to make exactly what you need, but no one is going to manually create 1000s of Titans, that is ridiculous. You would manually create the, maybe 10, special Titans, and then have some systems that create Titans with a random set of a group of components based on the genetic needs of each class of Titan. Which would be very easy and efficient to do with composition, but in terms of actually managing the Titans themselves, you would want an inheritance layer that controls how the composition happens. In other words, sometimes it's best to use the 2 patterns together.

  • @theraven1232
    @theraven1232 2 місяці тому

    As a Haskell truther, you're on the right track. Just wait till you get into the insanity category theory offers. Problem is applying it to the main game engines, unless you're building your own engine it's hard to squeeze efficiency out of monadic composition, you're always gonna be beholden to OOP to some degree. The Scala-esque mixed approach will always be the best you can get away with in most cases.

  • @mkaks22gamerserise16
    @mkaks22gamerserise16 3 місяці тому +1

    Support you bro,i will be always there for you😊😊

  • @felipejhony6039
    @felipejhony6039 3 місяці тому

    Great video, cool ideas. Beatiful game design. Be well!

  • @Iridium.
    @Iridium. 4 місяці тому

    Glad I’m on the right track . I name them “actions” and are basically containerized behaviors. I got priorities setup as well as additive capability which I can either have the next action be the current behaviour or an addition to the current .

  • @Wyvernnnn
    @Wyvernnnn 3 місяці тому +1

    Message busses are dicey to debug, they turn straightforward bugs ("loop -> npcs -> ai -> lookForEnemy -> stealthSpot -> segfault) into hard to debug asynchronous call chains (loop -> npc -> messageRead -> segFault) that require you to have good observability and look through logs to understand unreliably who wrote what and why things got buggy.
    If I make a message bus now, what I do is add a "synchronous mode" where each Publication into the bus immediately follows with a function call to wake up each and every subscriber to that call.
    It keeps the call stack in a single monolith which is great! And it will shine a light on unwanted infinite loops

  • @Garniy_Hlopchik
    @Garniy_Hlopchik 5 місяців тому

    This is incredibly cool! I finally feel like I understand all of it good enough to work like that on my future projects. Right now I have, weeell, I guess you could also say a mix of inheritance and composition, but in a ratio of something like 90% inheritance, 10% composition. By the way, just saying, inheritance is also valid for most projects, you can work around most problems. For example, in my game, all melee weapons a player can use actually shoot projectiles that fly really fast, but self-destruct after flying several pixels (and are invisible ofc)

  • @VideoGamesAreBad
    @VideoGamesAreBad 5 місяців тому

    This was great! Both from a video and information perspective.

  • @divy1211
    @divy1211 5 місяців тому +5

    Some time ago, I read a reddit post which explained this extremely well (sadly I can't find the link, so I have to paraphrase) and it said that inheritance is basically composition but with extra features: 1. compose the supertype in the subtype, 2. automatically delegate properties and methods to the composed instance (syntax sugar: instead of having to do x.y.z you get to do x.z), 3. Make all subtype instances valid instances of the supertype from the perspective of the type checker. Interestingly, not only does inheritance often mislead new OOP programmers into the problem you described, the 3rd feature, formally called subtype polymorphism, makes a program harder to type check too in certain cases.

  • @studiologixgames
    @studiologixgames 5 місяців тому

    awesome video man, great to see stuff like this and massive luck on your game and future videos

  • @felfar197
    @felfar197 5 місяців тому

    such a great video! beautiful animations and pretty helpful

  • @JamesKelly89
    @JamesKelly89 4 місяці тому

    I'm an experienced software engineer and what you've created is called an HFSM: Hierarchical Finite State Machine. When you say behavior tree, especially in the context of game dev, it usually refers to a form of AI that's similar to an HFSM but is more specialized and centric around execution over time. There are lots of videos and information on it.

  • @JustinDuijn
    @JustinDuijn 3 місяці тому +1

    @1:39 Make the randomize an optional Boolean passed to BaseTitan that is true by default?

  • @sindiinbonnienclyde
    @sindiinbonnienclyde 4 місяці тому

    Composition is incredibly powerful.
    I wrote my own set of systems using composition, ecs, state machines and archetypes.
    This has given me amazing versitility in writing my engine, adding to it and not even remotely worrying aboit spaghetti hierarchies, multi inheritance and many other issues that i found with oop (oop is still great)
    I feel that systems that find objects of certain types/composition in the project and add functionality 8s incredibly powerful.
    Imagine a ball, apple and wheel.
    They all have very different properties but all roll. Add a roll to them all and let the roll system do the rest.
    Just a simple example tbf.

  • @blendedphoenix
    @blendedphoenix 5 місяців тому +2

    This is what includes/mixins/interface
    Which basically is a feature set that can be added to a class, that then from that point forward I herits naturally but isn't bound or part of the hierarchy.
    It's the wings problem in the animal tree

  • @VitSoonYoung
    @VitSoonYoung 2 місяці тому +1

    Thanks for talking in such a peaceful way, not cutting the silence too much nor speed up talking as my brain uses those time to process. One question, what's the behavior of Camera: Freefall?

    • @NesiAwesomeness
      @NesiAwesomeness  2 місяці тому +1

      It's just a script that controls the camera's movement when the player is free falling it keeps the player and plane in frame during that interaction

  • @Zewofficial
    @Zewofficial 5 місяців тому

    Love this. A mix of comedy and learning. Great voice over. Keep it up! Haven't checked your channel but I'll def sub. Im interested in 2D tutorials!

  • @sharifcorbic5026
    @sharifcorbic5026 3 місяці тому +6

    Composition is great sure but I'm not sure this is the best example. I feel the randomize function should never be in the class. This example should probably use a factory instead

  • @az-kalaak6215
    @az-kalaak6215 2 місяці тому +1

    most people do not understand that, inheritance is there to inform what an object is
    (a titan IS a creature, it IS living, it IS tall, it IS a monster).
    Composition is there to inform what an object has
    (a titan HAS a shape, it HAS high hp, it HAS high damage).
    Interfaces (and also member functions) are there to inform what an object can do
    (a titan CAN crush you, it CAN move, it CAN eat humans).
    For your example at the very beginning, the randomize has imho no place inside the titan class, as it does not define a titan. it defines how to generate one, which is not the role of a titan (a titan cannot generate a titan can it?).
    if I complete the example:
    The Titan Generator can create any kind of titans! it can create basic titans which can run, kill, and eat! it can also generate weird titans, which for some reasons cannot move, but can do everything a basic titan can do. it also generates special titans, which have shielded plates, have higher speed or attack. Those titans can even use a special attack! when basic titans try to use it, they fail miserably...
    in this example, BasicTitan have four functions (run, kill, eat, attack). they also have a shape, that is passed to the constructor.
    The WeirdTitans inherits the basicTitan, and overrides the run function to do nothing (as they cannot move)
    The SpecialTitan inherits the basicTitan, and modifies its base characteristics (hp, strength, speed...). its attack function is overrode to implement a special attack.
    The TitanGenerator is a factory whose sole job is to create titans, based on what is asked to it. if it creates a basic titan, it is randomly generated. if it is a special titan, it has presets.

  • @skeleton_craftGaming
    @skeleton_craftGaming 5 місяців тому +1

    In the game engine I'm designing, I'm using a single level of inheritance event bus system by that I mean I have a base entity class of which there is a vector entities which it loops through and calls the perspective function depending on what type of event it is. [Think htmls Dom event bus]
    And also you have to have some sort of inheritance to properly polymorphize the container for your entities. No game engine that I know of uses truly compositional design [in fact, ECSes rely heavily on the whole polymorphism idea if I understand correctly]

  • @origanami
    @origanami 5 місяців тому

    I clicked the video and came straight here to say THIS MAN HAS SEEN THE LIGHT AND YOU WILL TOO

  • @noontimedreamer
    @noontimedreamer 4 місяці тому

    I'm always worried about how ro format this kind of code, but it really looks so much cleaner by the end. Hope I can use this better in future projects, thank you!

  • @UltimatePerfection
    @UltimatePerfection 3 місяці тому

    Can't wait to debug why my character is running, jumping, falling and being idle at the same time.

  • @DaxSudo
    @DaxSudo 5 місяців тому

    Hell yes just from the thumbnail. Ur on the right track.

  • @ourfriendjon9826
    @ourfriendjon9826 5 місяців тому

    Content with style. Great video

  • @kieran8266
    @kieran8266 5 місяців тому

    I really appreciate all the thought you've put into this video, and you make a lot of valuable observations. As someone who has been working both independently and inside the industry for 15+ years, I really have to say. None of this stuff matters. Making good games matters.
    I have worked so many jobs where so much stress and emphasis was put on coding paradigms. It never paid off. The engineers who wrote good code had always been that way, and the ones who wrote spaghetti had always written spaghetti. Adherence to coding paradigms and practices are born out of businesses needing to cater to a lowest common denominator. You need to focus on writing code that achieves the goal of your game. Have you seen Notch's original source code for Minecraft? It's a freaking MESS. It would make even novice coders puke. But it didn't get in the way of the game's goals, and it certainly didn't stop it from becoming the best selling game of all time.

  • @ryuseki-oni
    @ryuseki-oni 4 місяці тому

    Having well defined configuration settings can come in handy also.
    For example, I am working on components which require asynchronous data, so there is a use case for a separate initialization code path after construction. The options for guarding this separate execution path from user ( in this case developer ) mishandling are limited in the language I am working in. So I came up with a way to internally validate the initialization invocation, which made it possible to expose the code path, but ensure it is only being invoked internally. This also permits implementations to decide which parts of the initialization procedure they want/need for their own requirements by selectively calling up the inheritance chain. So like lazy, piece-wise configuration, similar to ad-hoc interfaces. Also kind of like an effective form of shared privacy. The language does not have built in OOP interfaces and does have private member access but not shared privacy natively.

  • @patrickshepherd1341
    @patrickshepherd1341 5 місяців тому +11

    My biggest issue with inheritance is that it always makes sense when you're doing it. Like, if i start writing a program from literal scratch, and i make a bunch of simple struct-like things, then eventually I'll see what they all have in common and make a base class. Then you build more and you need base classes for your base classes. Then again, and again, and again, and by the end of it i have an impenetrable layer cake a mile high of class hierarchy. AND to top it all off, i usually don't remember which base classes did what specifically, which bloats debugging time

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +2

      Exactly, or you just need a work around all the time.
      It feels like a bandage to the over arching problem

    • @patrickshepherd1341
      @patrickshepherd1341 5 місяців тому

      @NesiAwesomeness lemme ask your opinion on something if you don't mind. I just found your channel and I've been binging lol.
      Okay, so I never took a compilers or programming language class, but I always wanted to learn them, so I followed this tutorial on UA-cam to get all the basic pieces built and see how it works. Now I'm done with the tutorial and I'm able to start building from it quite a bit. I've already built support for a map type, and interchangeable static and dynamic typing, and a few other easy things. Here's the question.
      I'm about to start implementing structs, and I want to try to strike the right balance between customization and conciseness. I'm thinking about designing structs to be just general collections of objects to begin with, and functions will be typical functions as well. Like, not methods per se. But I want to be able to add a statement in the definition of a struct that will let me attach a function to it by telling the struct how it needs to handle itself with respect to the inputs and outputs of that function. Example at bottom.
      What I'm going for is a mix and match approach for structs and functions, but I've never done this before so I don't know if I'm effectively just creating traditional classes at the end of the day. Any thoughts?
      Example:
      I have a function add(a, b) that returns a+b. Then I have a struct called Person that has a string property called "name". Whenever I call add with a Person as one of the arguments, I want that Person to feed in its 'name' property instead of its whole self, so I add a line in the definition like this:
      struct Person {
      name = 'some name'
      ...
      .add

    • @patrickshepherd1341
      @patrickshepherd1341 5 місяців тому

      K turns out this is already a thing. But hell, I'm not complaining! I didn't even know it was a thing, so apparently what I thought was a good idea actually was! That's kinda cool to know.

    • @ryan-skeldon
      @ryan-skeldon 4 місяці тому +2

      Spend more time in the design stage before writing code. You'll have fewer surprises.

    • @patrickshepherd1341
      @patrickshepherd1341 4 місяці тому

      @@ryan-skeldon I agree with you in the cases where the entire functionality of the program is known beforehand. If you're trying to solve a problem that isn't already solved, the usefulness of design hits a hard ceiling pretty fast.

  • @friendswithcyd
    @friendswithcyd 5 місяців тому +1

    Excellent explanation! These map perfectly to general software dev (though based on the way you described them I’d guess that’s your background!

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      I'm purely game development, I have no professional background in software development, just a lot of free time studying programming as a concept

  • @Rejuker
    @Rejuker 5 місяців тому

    The free fall mechanic is pretty cool, not sure I’ve seen that before. Seems like you have an interesting expandable core with this approach so best of luck building on that to a more fleshed out version.

  • @Kinos141
    @Kinos141 3 місяці тому +1

    In Unreal Engine, composition is called actor components. This method is kinda the same as composition, where you can add and remove components.

    • @andreww4751
      @andreww4751 3 місяці тому

      Yea it's not that revolutionary. I was like, is he just talking about components lol

  • @lowgos0606
    @lowgos0606 5 місяців тому

    Great video man! I would love a deep dive on the animations you hooked into this proto. I'm having a tough time with animation/trees with Composition.

  • @TuberTugger
    @TuberTugger 5 місяців тому +37

    Composition isn't just having a list of things on an object.
    Composition is inheriting multiple interfaces instead of one baseClass.
    So instead of Enemy : Entity.
    You have Enemy : ICanJump, ICanWalk, IDamagable, IHasInventory
    And each of those interfaces handles the default logic.
    Then later when you want to damage an object, you don't check if it's an Enemy, you check if it's an IsDamagable and call the object's TakeDamage method. Now anything can be IDamagable. Destructible environments, the ground, the player. It doesn't matter what, because all it's promising is that it takes damage. The code's intention is super transparent and easy to maintain.
    When people say use Composition over Inheritance, they mean direct inheritance. Not inheriting in general. Composition is still a type of inheritance. You just inherit components instead of one root class.
    If you're not using interfaces, you're not really using composition. Just Lists.
    Every baseClass you consider creating, instead break it down into many interfaces each responsible for a singular thought.

    • @edattacks
      @edattacks 5 місяців тому +1

      mmmm, okay that clicks. Good stuff

    • @TricoliciSerghei
      @TricoliciSerghei 5 місяців тому +1

      How can you describe logic in an interface?
      Can you have default implementations in an interface in C# now?

    • @chylex
      @chylex 4 місяці тому +1

      Interface inheritance to define an object's components has way too many disadvantages.
      - You need a new class for every combination of components.
      - You can't dynamically change which components an object has.
      - You can't have multiple components of the same interface type on one object.
      - You need the language to support default interface implementations.
      - Interfaces can't hold data, so any data a component needs has its fields duplicated across all classes that implement it, and accessed through public interface methods which are inadvertently exposed to anyone with a reference to your object.
      A simple list of components doesn't have these problems.

    • @DestopLine
      @DestopLine 4 місяці тому +1

      @@TricoliciSerghei Yes

    • @schnitzel_city
      @schnitzel_city 3 місяці тому

      This is incorrect. What you are describing is interface inheritance. It is different from true composition in the sense that composition is about coupling existing components. Interfaces are not components.

  • @prodbreeze
    @prodbreeze 5 місяців тому +2

    Beautiful video!

  • @skaruts
    @skaruts 5 місяців тому +3

    Just one thing, though: composition is actually OOP (and should not be confused with ECS). It's just a different way of doing OOP. A long time ago, in the golden days of Flash games, all the tutorials were hyping OOP, but they all advised people to use "composition over inheritance". But then.... everybody used inheritance. :)
    There's an interesting talk by Bob Nystrom about roguelikes where he shows the benefits of OO composition too.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +1

      Thanks so much for the clarification. I've learnt so much from these comments.

  • @NoVIcE_Source
    @NoVIcE_Source 5 місяців тому +3

    This looks like fun game to play!
    Something about biplanes on floating bases on the sky totally sounds like my dream game when I was 10 :D
    I love composition so much, but I use it so much because I can't use OOP at all, I feel like I'm not a "real programmer" because everytime I have to make interfaces I make total spaghetti and I get disappointed and burned out so fast :(

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +1

      1). There's no such thing as a "real programmer". Gate keeper skill level is such an 'internet validation' thing. So try not to think about stuff like that just code and have fun and mess up and learn 😂
      2). You should learn some aspects of OOP it's super useful. The combination of OOP and Composition I feel is the best place to be.
      3). Thanks, I've been working on it for sometime now and I'm just now finding a balance between UA-cam, gamedev, school and work so progress has been slow.

    • @NoVIcE_Source
      @NoVIcE_Source 5 місяців тому

      @@NesiAwesomeness thank you! hope you have a good time making your game while balancing other things^^

  • @beMotionAR
    @beMotionAR 5 місяців тому +6

    This is insane quality and super useful stuff! I can't believe you have only 2.5k, at least for now :)
    As the other guy said, I didn't know this was about Godot until I started watching. Maybe adding "Godot" somewhere in the title or thumbnail would help?
    Anyways, you just earned another sub. Keep the quality going!!💪

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +1

      I didn't want it to be Godot specific, I was hoping what I was talking about could be implemented anywhere

    • @blue.pixels
      @blue.pixels 5 місяців тому

      @@NesiAwesomenesstrue, not mentioning the engine was the right choice as this isn’t limited to single engine. Cool video! I share the sentiment :)

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      @@blue.pixels thank you

    • @beMotionAR
      @beMotionAR 5 місяців тому

      @@NesiAwesomeness You're right, this could be applied anywhere!

  • @ClashClash89
    @ClashClash89 4 місяці тому

    I have no clue what anime those „titans“ are from. But they remind me of David lewandowski‘s animations „going to the store“, „late for meeting“ and „time for sushi“ to be specific… (all on his UA-cam Page)
    but not a word about his work on „tron: legacy“, „oblivion“ or „top gun: maverick“

  • @indycinema
    @indycinema 3 місяці тому +1

    you got a good style of video

  • @FileTh1rt3en
    @FileTh1rt3en 5 місяців тому +1

    Rendezook as a game mechanic is an amazing idea.

  • @chonkusdonkus
    @chonkusdonkus 5 місяців тому +2

    Never thought about using a behavior tree for the character I'm controlling.
    I did implement a behavior tree in a similar manner to this in my game though, with nodes for each behavior, and it traversing through the tree from top to bottom.
    Might be worth investigating for my project too..

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому +2

      @@chonkusdonkus you should definitely, it's super clean and it's something I can use in a different project later too

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      Quick correction to my video, I kept referring to the "Finite Hierarchical State Machine" as a behaviour tree, these things actually happen to be completely different.

    • @chonkusdonkus
      @chonkusdonkus 5 місяців тому

      @@NesiAwesomeness it's definitely a very modular approach to modeling the logic for my AI, so I can see how it would be a really easy way to make an extensible character controller as well, I'll have to do some experimenting.

  • @AgodzillaFace98-yj5nq
    @AgodzillaFace98-yj5nq 2 місяці тому

    Good exercise is to write some game logic in c.
    And when you try to create Oop in c, slap your wrist.
    This exercise will help you understand that game is not real life. And that In turn, will give you more freedom to create solutions that make sense for you and for the machine.

  • @zanagi
    @zanagi 5 місяців тому +1

    The pilot freefall mechanic was pretty neat xD

  • @FirstNameBasis_
    @FirstNameBasis_ 5 місяців тому

    Entertaining and educational plus clearly articulated with visuals. Holy fuck my damaged brain is in heaven for learning. 😂
    BIG thankies

  • @donkeyblade
    @donkeyblade 5 місяців тому +1

    i like your video style

  • @OverBlackSands
    @OverBlackSands 3 місяці тому +1

    Bro... in a video that isnt exactly about OOP, it taught me how OOP classes work better than 99% of other things I've seen over the years. Holy crap this was fantastic, and your editing is top notch. Instant sub

  • @thecoweggs
    @thecoweggs 5 місяців тому +4

    editing is on point

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      @@thecoweggs thanks, I was trying to make it "invisible" this time, lol

  • @cariyaputta
    @cariyaputta 5 місяців тому

    Nice explanation of composition over hesitance.

  • @Kinos141
    @Kinos141 3 місяці тому +4

    Behavior trees are NOT state machines. They are decision trees that flows down to leaf nodes based on parameters, mostly booleans and enums, to make a choice at a specific time under specific conditions. It can quite robust.
    The difference between this and state machines is that a state machine needs enter and exit condition to switch between states. A behavior tree reruns from top to bottom, re-evaluating the it's conditions.

  • @JoeyG-o8r
    @JoeyG-o8r 2 місяці тому

    "This old code I wouldn't touch with a 10 foot pole. The code smelled like vomit; spaghetti"
    "So I had this player class, which inherited from a class called Entity, which had code for movement..."
    Uh oh.

  • @hola_chelo
    @hola_chelo 5 місяців тому

    inheritance was perfect in this example if you already knew exactly what you were going to do, but it can become tricky once you start developing and coming up with new stuff. Also I get how it can become complex similarly to circular imports in python, this module needs that class and the module that defines the class needs the first module and it becomes a wooden wheel instead of a tree.

  • @artoriapd
    @artoriapd 2 місяці тому +1

    And that's why you should be a hardcore coder like me, which prefer inheritance 😂😂
    Btw, this is just personal thought: I think inheritance is just composition, but not a full composition
    If I'm not mistaken, C++ internally compile inheritance into a composition too

    • @az-kalaak6215
      @az-kalaak6215 2 місяці тому

      internally, c++ gets entirely rid of classes and every single oop stuff to generate machine code :p

    • @artoriapd
      @artoriapd 2 місяці тому

      @@az-kalaak6215 ya, I know?

  • @gabrieldeoliveirabelarmino7461
    @gabrieldeoliveirabelarmino7461 5 місяців тому +1

    Thank you Bro! ♥

  • @buagseitei
    @buagseitei 4 місяці тому

    Inheritance as well as composition have their place and often a mix is the most useful approach imo. you can have a titan that inherits from a titan base class, if there is commonly shared code between them, lets say they all have eyes and blink with them. that does not mean everything has to be shared and the different titans then even can all have their own components. Just don't overdo it with inheritance, since it becomes very confusing very quickly. Use it, if you expect to save a lot of time when changing something in the future, since you only need to change the base class(for example blink twice as fast or whatever). If you have hundrets of titans, it may save you a lot of time. If you only have 3 titans i would not bother anyway. Also in my opinion i would define the behaviour tree in your example more of a state machine - A component would be for example a damage area, that an enemy can have or not have to do damage, imo. But that beeing said, very nice to watch video, i really liked it! Good and clean presentation 👍

  • @kryyto6587
    @kryyto6587 5 місяців тому +39

    Using both is usually the best

    • @lializ_666
      @lializ_666 5 місяців тому +18

      As long as you keep inhenritance two levels deep at most, trust me.
      When you're trying to change a node that extends "Wolf" and you're coming from Entity -> Enemy -> Animal -> Wolf, you have so much code scattered that is hard to keep it in check.
      The concept of Locality of Behaviour is more important than Single Responsability

    • @kryyto6587
      @kryyto6587 5 місяців тому +7

      @@lializ_666 indeed, sometimes it's better to do it the "dumb" way; instead of making a bunch of scattered code, which makes developing a hassle

    • @TuberTugger
      @TuberTugger 5 місяців тому +4

      You can use both poorly and both correctly.
      BaseClass inheritance should be done with an abstraction. Not a class you're going to actually create. In the video's example, he was spawning BaseTitans in game. That's already a mistake. And the randomization should have been in the constructor anyway. Bad example.

    • @jcdentonunatco
      @jcdentonunatco 5 місяців тому +1

      @@lializ_666 there is simply so many use cases that require more than 2 levels of inheritance that there would never be a "two level" rule

    • @mysterry2000
      @mysterry2000 5 місяців тому +1

      ​@@lializ_666 I was also gonna comment on the two-level rule, let's go!
      To the comment above me, that's actually true yeah, but I've found that in those cases it massively helps to relocate implementations to be more composition-based than inheritance-based.
      Basically, choose composition when inheritance introduces conflicts

  • @patty4449
    @patty4449 5 місяців тому

    My wizard for fixing codes is this process...
    I encounter a problem...
    I feed the problem to ChatGPT while thinking about it
    ChatGPT gives me proposals and I play around with them...
    I fix the problem without having to figure out where I made the problem...
    I ask GPT to help me revisit my problem and how to avoid it in the future...
    I learn and keep going...

  • @TommyLikeTom
    @TommyLikeTom 5 місяців тому +1

    It's best to use both, actually.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      That was the point in the video

    • @TommyLikeTom
      @TommyLikeTom 5 місяців тому

      @@NesiAwesomeness My bad! I commented without watching.
      The bottom line is that you can spend hours trying to generalize your code or asset to work in any situation, but in practice your assets will always end up intrinsically linked to your project.
      The best way to create is to dive straight in and do whatever works, and then once you have it working then clean it up, generalize, optimize, etc. THat is why they say optimization is the root of all evil. You need to create unselfish-consciously and recklessly, and then when you have something apply your critical eye to it.

  • @NewSchattenRayquaza
    @NewSchattenRayquaza 5 місяців тому

    You have such a nice acent ^^

  • @DavidMorales-s8d
    @DavidMorales-s8d 5 місяців тому

    Any coding paradigm that you like is good to go. For me the only restriction i set is: Do not repeat yourself. If I have to update the same code in two places I better write a function or inherit it.

  • @nxone9903
    @nxone9903 5 місяців тому +2

    Sounds kind of like bevy's ECS paradigm. I have no idea what I'm talking about though

  • @Cerbyo
    @Cerbyo 5 місяців тому

    I always run into this problem. If the scope of the project is small(most are) and experimental(unique objects all over) you are better off ditching inheritance cause the busywork to get the system to adhere defeats the point of setting up inheritance (same is true with nesting). Inheritance is pretty redundant to begin with as you can just rewrite redundancies in terms of function calls fine and formulate the various types with basic if-blocks. I experimented heavily with bullet outlines across game projects, inheritance structures were never clean always dirty and a complete nightmare to edit/read/update regardless of setup. Falling back on simple principles is actually cheaper(inheritance is usually costly) and way easier to edit/organize/read:
    add_bullet("shotgun")
    function add_bullet(type)
    if type="shotgun" then n=10 else n=1
    for i=n do
    add(bullets,{x=x, y=y, init=function() if type="shotgun" or "likeShotgunWithLessPellet" then dmg=5.... elseif type =...."})
    You can compartmentalize everything with functions and if-blocks however you want just like could classes. It's literally the same thing as you could do in classes just you have everything together and you invoke with a single function call. The point is you don't need classes; you can generate however many bullet copies of whatever variants as desired.
    In regards to using classes: to solve the issues of updating I've been throwing in nested blank functions in the middle of the class's methods. So instead of rewriting the entire method for unique object or extend trees all over I can just update the tiny part. This does mean that classes who don't use it will always call a blank function, obviously not ideal to ever call blank functions, but if you calculate the alternative costs of extending all over it's usually better or irrelevant.
    Case usage makes every argument irrelevant though, you might have other considerations forcing traditional class outlines. Or maybe you dont need many if any unique objects and dont want to run if-blocks u dont have to...then messy class code is ideal, but can also just solve it without by making separate bullet functions (repeated code can be mitigated with functions returning functions returning the object).
    I like to compare most language choices to the lua one of coroutines vs switches....u can write in either to get the same job done, but you can always rewrite your coroutine code into cheaper switch code.

    • @dominikdoom
      @dominikdoom 5 місяців тому +1

      Not going to say it's totally wrong for small experiments, but your example with if branches is one of the worst ways to do this. If this starts to scale at all, you'll end up with YandereDev level code that will be impossible to manage, incredibly hard to read, and have way worse performance than a proper use of inheritance and composition. The program will have to worst-case traverse the whole if-tree until it gets to the case that is relevant for it, which will result in many pointless comparisons and thus significant overhead (definitely more than any potential OOP overhead).
      The proper way to do something like this is having your custom guns implement interfaces (aka the composition patterns talked about in this video) for stuff they can't share with the common base class (e.g. hitscan vs. velocity based bullets) while inheriting what's sensible from the base gun (like bullet count and damage). That way you can feed your parameters in directly or even with some type of config JSON or the likes, and it also solves your "blank function" problem. Interfaces enforce contracts, so you can selectively call only those who implement it.
      If you do this right, there will be no gun, no matter how special, that can't be modeled like this, even for crazy stuff like bullets that heal or are actually NPC controllers (think nanobots, homing missiles etc.). It will take a bit of planning and foresight to not write yourself into a corner, but it definitely beats having to refactor a gigantic if else block. Especially since every good IDE has features that make editing classes and interfaces as easy as possible, where the same can't be said for hacky if blocks that cosplay as worse versions of a class/closure.

  • @pawegorka8589
    @pawegorka8589 4 місяці тому

    I found myself cerrin on if my code is clear and well writen more than if it's usefull and working and this stop me from coding too long befor i actually start to make it right

  • @akselholbech7940
    @akselholbech7940 5 місяців тому

    really nice graphics for the video. wow

  • @ince55ant
    @ince55ant 5 місяців тому

    Components are great. nothing feels better than slapping some component you've made for something else onto a new object and it just *works*.

    • @NesiAwesomeness
      @NesiAwesomeness  5 місяців тому

      @@ince55ant I can't wait to use it when I'm making a game for a game jam

  • @ryuseki-oni
    @ryuseki-oni 4 місяці тому

    Misfired the comment button earlier and youtube edit seems broken for me. :S
    But I would say that composition more often refers to functional code, or maybe sometimes with OOP interfaces.
    I have used the *Item* -> *Tree* inheritance pattern you described though, works well.
    Lately though I have started using more abstract classes which actually throw if some tries to construct them directly.
    No doubt complexity becomes its own challenge and it depends how much you like the pain of it for the benefits you can gain.:D
    I start going sideways after about 4 levels deep in abstraction/hierarchies, but I have seen awesomeness at levels 5 and 6.
    It just depends what the use case is.
    I have found that the more I force myself to document closer to the root of my abstractions the more focused I am by the time I am punching out the leaf components where everything is supposed to just do what I want.
    Essentially, think need near the top, want at the bottom and you should do ok. :-)

  • @MyManJohnny
    @MyManJohnny 3 місяці тому +1

    The main issue is not inheritance. It's bad design. Titan shouldn't randomize it's own stats. Ideally, that should be a work for some titan factory if you have a lot of types.
    Im also not saying everything has to be done using inheritence, in case you want to add a special trait like armor, hair, goofy lip.. composition makes sense, it also makes the code more readable and design less complex.

  • @bluebible1199
    @bluebible1199 5 місяців тому +1

    The goat has uploaded 🔥

  • @LilArquebus
    @LilArquebus 5 місяців тому

    Great video! I love the depth of thought put into the video and the game. Have you live streamed development? I recently started doing that and it’s really fun and all the smarty pants in the audience have helped me a lot.

  • @londanomala1734
    @londanomala1734 4 місяці тому

    I get everything you said Nesi, nice video. I still need to understand what exactly is the function "set_behaviour" doing. Like how does it actually change the behavior to one of the child nodes listed in the behaviour tree?

  • @bananaglove3377
    @bananaglove3377 2 дні тому +1

    Honestly, just add 2 constructors to the base titan, an empty one that automatically randomizes the stats, and one that requires you to pass the stats as arguments.. I get the whole inheritance vs. composition debate, but I've honesty never had to use composition because any problem that could be fixed with composition could also be fixed with a smarter inheritance system.

    • @NesiAwesomeness
      @NesiAwesomeness  2 дні тому +1

      @@bananaglove3377 just use composition.
      Save yourself the headache

  • @proceduralart-ub3cq
    @proceduralart-ub3cq 5 місяців тому

    I subscribed because you are a Nigerian and you are making content I love. Keep up the great work.

  • @pokefreak2112
    @pokefreak2112 5 місяців тому +18

    Inheritance makes sense if you actually have shared logic, but it's easy to overuse because we have a tendency to want to create "logical" inheritance hierarchies.
    Having a ParticleEmitter base class the efficiently batch renders particles makes sense to me, the only reason you'd ever want to inherit from it is if you want to emit particles
    while for your titan example you could imagine a friendly titan that just caries you from place to place instead of attacking, in that case the inuitive thing to do is inherit from Titan, but the practical thing to do is inherit from something like Transporter or MovingPlatform

    • @joshuathomasbird
      @joshuathomasbird 5 місяців тому +1

      the problem is if you have an abstract motor class that all your motors inherit from, and you have like em drive or warp drive or rocket motor. only the rocket motor emits particles and you need to inherit from particle emitter AND abstract motor. (deadly diamond). something like ECS, or rust's traits solve this.

    • @pokefreak2112
      @pokefreak2112 5 місяців тому +1

      @@joshuathomasbird Forgot to explicitly mention it in my comment but inheritance also only makes sense when you actually need the shared API between descendants so you can swap them out interchangeably. The motor shouldn't inherit from particleEmitter because that's not its primary function, composition is the right pattern here.
      ECS is just one way to achieve composition, there are many more

    • @TheOnlyGhxst
      @TheOnlyGhxst 5 місяців тому +1

      @@pokefreak2112 I think for game development in general, Composition and functional programming is just the right way to go, and Inheritance/OOP really has no place. Sure, using Inheritance might make some things EASIER, but also makes your code messier and more likely to break in the long run. If you make as many things as possible their own separate, self contained, reusable module, then you avoid chain breakages where one messed up part of the program breaks everything else.

    • @joshuathomasbird
      @joshuathomasbird 5 місяців тому

      @@pokefreak2112 I think maybe you're missing my point about why multiple inheritance is problematic. the motor is just to visualize a concrete inheritance pattern that is easy to understand. if you don't like that one consider quadrilaterals: rhombuses, rectangles, and squares. If your pattern is supposed to compose behaviours objects can have but the pattern can't organize how those objects behave, then it would be incorrect to say that it is a way to acheive that, let alone claim that it's the "right" way.
      I hope you don't find that out the hard way, nor make someone else's life miserable standing on this hill.

    • @pokefreak2112
      @pokefreak2112 5 місяців тому

      @@joshuathomasbird Harsh. You'd need to provide more context what you're doing with those quadrilaterals. Personally I don't think I'd ever make a quadrilateral base class, but I could see myself making a "collider" class or "renderer" class where subclasses implement a collider or renderer for a specific shape.
      And yes, you'd use that collider and renderer class to compose entities just like you'd do in ECS. I'm not saying inheritance solves every problem, just arguing that it's useful in some cases and sharing my rules of thumb for when I use inheritance vs composition.