Function Chaining (Builder Pattern) Tutorial in Godot 4.x

Поділитися
Вставка
  • Опубліковано 1 лют 2025

КОМЕНТАРІ • 36

  • @NeZversSounds
    @NeZversSounds 7 днів тому +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  7 днів тому +1

      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 10 днів тому +19

    The intro never gets old

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

    Glad you are back making yt video !

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

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

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

    The goat is back

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

    new banger just dropped

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

    So sick. Never thought about doing this

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

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

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

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

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

    saving this to watch later

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

    He's back

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

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

    • @uheartbeast
      @uheartbeast  10 днів тому +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 9 днів тому +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  7 днів тому +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 7 днів тому +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 6 днів тому

      @@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.

  • @gass-tube
    @gass-tube 8 днів тому +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  7 днів тому +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 7 днів тому

      @@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.

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

    Master!

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

    👍🏼

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

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

    • @uheartbeast
      @uheartbeast  10 днів тому +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 10 днів тому +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 4 дні тому

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

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

    hi :)

  • @thejuice027
    @thejuice027 10 днів тому

    Does Godot 4.x have anything to do with Godot games (the board game company)? because if so they are a shit company.

    • @KyleLuce
      @KyleLuce 10 днів тому +5

      Nope. I've never heard of the board game company, until now.

    • @jmvr
      @jmvr 10 днів тому +1

      Plus, Godot (game engine) is open source and mostly funded by a non-profit organization of the same name, called the "Godot Foundation".
      Godot Games GbR (the board game company) is a company, not a non-profit. They make things for money. They're definitely not the same.

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

      I've never heard of the board game company

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

      Unrelated