Function Chaining Tutorial in Godot 4.x

Поділитися
Вставка
  • Опубліковано 8 лют 2025
  • Thanks for watching my tutorial video on function chaining in Godot 4!
    If you are interested in taking a deeper dive into the Godot game engine you can check out my other courses at this link: www.heartgamed...
    Thank you all so much for your support!

КОМЕНТАРІ • 34

  • @NeZversSounds
    @NeZversSounds 14 днів тому +3

    If all you need is to initialize, then create custom _init(args) function and pass arguments into new( args) when creating new instance.

    • @uheartbeast
      @uheartbeast  14 днів тому +2

      Hey! Great question. I think I picked a bad example for the video because passing the actor into an _init() function makes perfect sense. This pattern is better suited for optional parameters. Something like the start of the video with the create_tween() function shows a better use case since those parameters are optional and have default starting values.

  • @cgl4de
    @cgl4de 17 днів тому +19

    The intro never gets old

  • @bleizius
    @bleizius 13 днів тому +1

    Glad you are back making yt video !

  • @davidvanderhaar313
    @davidvanderhaar313 14 днів тому +1

    Heartbeast!👋glad to see you and your lessons again.

  • @atalay7260
    @atalay7260 17 днів тому +5

    new banger just dropped

  • @brycea5452
    @brycea5452 16 днів тому +1

    So sick. Never thought about doing this

  • @azzzaazz5809
    @azzzaazz5809 15 днів тому +2

    The goat is back

  • @greenwiener
    @greenwiener 17 днів тому +3

    saving this to watch later

  • @Timidger
    @Timidger 16 днів тому +7

    This is usually called the "builder pattern" in non-game software.

    • @uheartbeast
      @uheartbeast  16 днів тому +2

      Thanks for letting me know! It's probably called that in game software too. Now I can use the correct term for it.

    • @patfre
      @patfre 5 днів тому

      This is incorrect. Builder pattern and function chaining are not the same thing and has two different meanings. Function chaining is just function chaining this is a principle that comes from functional programming. Meanwhile builder pattern is an OOP principle and is different, here your taking the object you want to end up with and setting its settings directly while builder pattern has a different object whose soul purpose is to configure and create instances of the desired object so you might have MoverBuilder that you can configure which will create a Mover using .Build() with the same settings. Both principles are mutually exclusive

  • @LOGGYBOI
    @LOGGYBOI 17 днів тому +3

    He's back

  • @RebelliousX
    @RebelliousX 17 днів тому +2

    👍🏼

  • @MAV_DEV
    @MAV_DEV 17 днів тому

    Master!

  • @herrspaten1796
    @herrspaten1796 17 днів тому +7

    Why not override the _init-method so you can pass the arguments upon creation

    • @uheartbeast
      @uheartbeast  17 днів тому +2

      Good question! That can work too but it's not as readable and so I prefer chaining. There are also a few other tradeoffs (since chaining allows you to choose which properties you decided to pass in on creation).

    • @watchagoblin
      @watchagoblin 15 днів тому +3

      Came here to make a similar comment. In this particular case, where the Mover needs an actor to work, and will fail in runtime if one is not provided, I'd ague it's more idiomatic to pass it via constructor. But chaining could still be valuable for more "optional" parameters (such as of looping/easing behavior in tweens).

    • @uheartbeast
      @uheartbeast  14 днів тому +3

      @@watchagoblin Really good point! The example I picked to show the pattern isn't a great one and is causing some confusion. I do still like how readable it is, though. It's hard for me to let go of that even though I agree with your point.

    • @watchagoblin
      @watchagoblin 14 днів тому +2

      @@uheartbeast Just to be clear, I still think the video is a good breakdown of the technique, and helpful in that regard! I think most programmers will be able to abstract away the specifics of a toy example, and focus on what the pattern itself enables them to do.

    • @gleefuluv
      @gleefuluv 13 днів тому

      @@uheartbeast I think it'd be great if you can append this note in your description so people don't get confused or have to scroll through the comments to find this.

  • @patfre
    @patfre 5 днів тому +1

    This is slightly incorrect. Function chaining IS NOT builder pattern. Builder pattern is when you have a class (or just any form of object) whose task is only to instantiate complex objects. Like take the thumbnail for it to be the builder pattern you would make MoverBuilder and when you call .Build() on it it will return a Mover with what ever settings you defined on the builder. Function chaining and builder pattern is usually used together but that does not mean its the same thing

    • @uheartbeast
      @uheartbeast  5 днів тому

      Thank you for the clarification. I'll update the title.

  • @gass-tube
    @gass-tube 14 днів тому +1

    I don't understand the way you are instantiating. why not use _init() within the class and create the instance as className.new(...initial_props) ?

    • @uheartbeast
      @uheartbeast  14 днів тому +2

      Hey! That's a good question. I'm going to copy paste my response from a different comment.
      I think I picked a bad example for the video because passing the actor into an _init() function makes perfect sense. This pattern is better suited for optional parameters. Something like the start of the video with the create_tween() function shows a better use case since those parameters are optional and have default starting values.

    • @gass-tube
      @gass-tube 13 днів тому

      @@uheartbeast I guess that's fine. There can be different implementations for the same thing. Nonetheless you can still use the _init() constructor with optional parameters by specifying default values.

  • @CodingQuests
    @CodingQuests 17 днів тому +3

    hi :)

  • @saroporoggo
    @saroporoggo 17 днів тому +2

    Any update on any games or have you stopped working on everything?

    • @uheartbeast
      @uheartbeast  17 днів тому +7

      Released a demo for WASarD on Steam and I'm still working on it. I'll don't have anything big to announce yet.

    • @saroporoggo
      @saroporoggo 16 днів тому +1

      @@uheartbeast Glad to hear it man, sending good vibes and hoping it's going well, you've got a lot of talent

    • @Snyper-if3kt
      @Snyper-if3kt 10 днів тому

      @@uheartbeast Oh good to know. I've had it wishlisted for some time now, will have to check out the demo.