When, Why, and How to use Builder and Fluent Builder Programming Patterns

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ธ.ค. 2024
  • เกม

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

  • @the_gobbo
    @the_gobbo ปีที่แล้ว +23

    In 11 minutes you taught me more than 7 whole classes about software engineering

    • @git-amend
      @git-amend  ปีที่แล้ว +2

      Thank you, that's a very encouraging comment! The channel is definitely starting to grow a little faster lately because of this video, and more like it to come! Cheers!

    • @phoenixfire6559
      @phoenixfire6559 ปีที่แล้ว

      @@git-amend You need to leverage your skills as a senior software engineer. Most tutorials/ videos target beginner levels. I've been working through all of yours, and they're all really informative. I also note your consistent release schedule. Just keep at it, once you hit a certain number you'll hopefully get a lot more subs because this channel deserves it.
      My main advice so far is have a look at your thumbnails, the text is really important and I often see "3D" or "Shoot Em Up" really clearly but can't see the rest - I personally don't think 3D or Shoot Em Up should have been the most prominent words but would have clicked if I had seen Parallax or Player Controller. In this thumbnail, "Game Programming Patterns" was very clear. The fluent builder less so, but I clicked based on programming patterns.
      Anyways, the video and audio quality are excellent and you are presenting really well. Its more of a case of getting that youtube algorithm to favor you. I've subscribed, hopefully the high quality content continues.

    • @git-amend
      @git-amend  ปีที่แล้ว

      @@phoenixfire6559 Thanks for the comments and constructive criticism - it's always welcome. I think you are right about the text; I'm going to make some changes based on that suggestion - thank you!

  • @derboss66
    @derboss66 ปีที่แล้ว +3

    This guy is the hero we didn’t know we needed.

  • @hoaxygen
    @hoaxygen ปีที่แล้ว +8

    THANK YOU! I didn't know I needed this knowledge and it fit right into my project, cleaning up a bit of code. It was so cool and easy to implement the builder with interfaces despite its complexity.

    • @git-amend
      @git-amend  ปีที่แล้ว +2

      Awesome! I'm really glad it helped you out!

  • @JiwonSong95
    @JiwonSong95 ปีที่แล้ว +1

    This one single video made my understanding of design pattern whole new level. Very high quality content.

  • @git-amend
    @git-amend  ปีที่แล้ว +5

    Leave a comment if there is a particular programming pattern you'd like me to feature in a future episode - already planning Factory, Adapter and Mediator patterns.
    Hit the bell so you don't miss a thing!

  • @rabrar6200
    @rabrar6200 ปีที่แล้ว +2

    nice idea for thumbnail! really caught my eye.

  • @afriendlyfox
    @afriendlyfox 2 หลายเดือนก่อน

    Thank you so much! I am trying to come up with a clean architecture for a study project, and our mentor is purely decorative, so I have no one to ask advice from, and your explanations really helped me understand how to use this pattern

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Glad it was helpful!

  • @AkakiAkakievitch-kc2vk
    @AkakiAkakievitch-kc2vk 8 หลายเดือนก่อน +1

    There are a lot of tutorials about how to make games, but very few about how to write effective and clean code!
    Thank you for that. I'll definitely browse carefully the content of your channel! A gold mine!

    • @git-amend
      @git-amend  7 หลายเดือนก่อน

      Thanks for the kind words!

  • @switbitz
    @switbitz 9 หลายเดือนก่อน

    Your channel is top tier for advance programming topics not limited to game development. Great work!

    • @git-amend
      @git-amend  9 หลายเดือนก่อน +1

      Glad you think so! Cheers!

  • @eduardoddutra
    @eduardoddutra ปีที่แล้ว +2

    Awesome video! Very well explained! I could definitely watch a playlist of 30 of these video tutorials about other patterns and good practices, it's so hard to identify when to use it, it always looks like magic to me...

    • @git-amend
      @git-amend  ปีที่แล้ว +2

      Thanks! More to come!

  • @PurpleDaemon_
    @PurpleDaemon_ 7 หลายเดือนก่อน

    The last tip with interfaces is awesome!!!

    • @git-amend
      @git-amend  7 หลายเดือนก่อน

      Right on!

  • @matteocampana7582
    @matteocampana7582 4 หลายเดือนก่อน

    Great video, I would like to see more of this type of content.

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thanks, make sure to check out the rest of the playlist!

  • @gnendraaw
    @gnendraaw 6 หลายเดือนก่อน

    I am so grateful that I found your channel! Really help me alot learning game programming the better way since I am learning by myself. This is an absolute gem

    • @git-amend
      @git-amend  6 หลายเดือนก่อน

      Great to hear! Welcome aboard!

  • @6Abdellah9
    @6Abdellah9 7 หลายเดือนก่อน +1

    I watched abt 10 vids within the last hour I feel 10x smarter already

    • @git-amend
      @git-amend  7 หลายเดือนก่อน

      Awesome!

  • @grzegorzpedrycz2630
    @grzegorzpedrycz2630 หลายเดือนก่อน

    Your channel is pure gold 😊

    • @git-amend
      @git-amend  หลายเดือนก่อน

      Thank you! 😃

  • @Broudy001
    @Broudy001 ปีที่แล้ว

    I've learnt so much from your channel, some goes over my head like this one, I'll need to watch it a few more times, and try putting it into a project before I get the hang of it I suspect

    • @git-amend
      @git-amend  ปีที่แล้ว

      Absolutely. Try it out a few times, and it will click!

  • @satibel
    @satibel ปีที่แล้ว

    Congratulations on pleasing the algorithm and hitting that programming/manhwa recap cross section with your thumbnail

    • @git-amend
      @git-amend  ปีที่แล้ว

      Thanks! I had a lot of fun with the thumbnail! Stay tuned for more!

  • @Hazzel31337
    @Hazzel31337 8 หลายเดือนก่อน

    i am still pretty confused about most of your advanced topics, but i am getting there slowly, your content helps, thanks

    • @git-amend
      @git-amend  8 หลายเดือนก่อน

      Glad to hear that!

  • @SirSone7
    @SirSone7 ปีที่แล้ว +3

    Hey, even tho you are not as popular as you should be, this channel is a true knowledge treasure for my level so i hope you keep uploading regardless of your views and subs. these are super helpful and your explanations are easy to understand. thank you
    I would love if you can cover Strategy , Command , State patterns as well

    • @git-amend
      @git-amend  ปีที่แล้ว +1

      I appreciate the comment! Those are great suggestions!

  • @Broudy001
    @Broudy001 7 หลายเดือนก่อน +1

    I finally managed to implement one of the patterns for something useful, I think :S

    • @git-amend
      @git-amend  7 หลายเดือนก่อน

      Excellent!

  • @popuzin
    @popuzin ปีที่แล้ว

    Just a comment for support. Good stuff 💪keep it up!

    • @git-amend
      @git-amend  ปีที่แล้ว

      Appreciate it!

  • @arjanb7158
    @arjanb7158 ปีที่แล้ว

    Using the fluent builder as a child class of a scriptable object finally lets me create instances in tests without making public setters. Amazing!

    • @git-amend
      @git-amend  ปีที่แล้ว

      That's a great usecase!

  • @setroid8235
    @setroid8235 ปีที่แล้ว

    This is great information!
    The video would be better if the audio were higher quality, and the intro was better (or simply removed). I don't see very many smaller channels, but the first thing I notice in smaller channels is the lower quality audio.
    I liked the video. :)

    • @git-amend
      @git-amend  ปีที่แล้ว +1

      Glad you liked the info! Thanks for the feedback - all suggestions are welcome!

  • @Frank_G_Finster
    @Frank_G_Finster ปีที่แล้ว +1

    I learned, i liked, i subscribed. I will put this knowledge to good use in my Godot project. Thank you very much.

    • @git-amend
      @git-amend  ปีที่แล้ว

      Awesome, thank you! Nice thing about programming patterns is you can use the knowledge in almost all modern programming languages!

  • @satibel
    @satibel ปีที่แล้ว +1

    Depending on what you're doing, you could use what I call self builder, where you merge the builder and the class, so you could have a boolean ready, that you set once the class is set properly (can also have it read only and use an initialization method).
    That's useful if you need to modify the class a lot and you're not using inheritance, because the builder is somewhat redundant, because you need setters anyway.
    So instead of
    Var Eb=new enemybuilder()
    Eb.health=100
    Eb.behavior=behavior.followplayer
    Var enemy=Eb.build()
    You have
    Var E=new enemy()
    E.health=100
    E.behavior=behavior.followplayer
    E.init()
    (You can also use that with a fluent builder, where you return this, I did it that way for clarity as it's just an idea, this assumes properties which call setters with that syntax, which aren't available in all languages.)
    Otherwise you're juggling between 2 or 3 classes for basically no reason.
    Though where you'd want to use an external builder is if you need to enforce a "non null" (not necessarily null, but there's no desirable default) behavior, like for example, you want every enemy to have their hp or behavior set (could be more complex, like requireing either a sprite or a 3d model), an external builder can just return null, while with a self builder you have to check that it has been initialized. (I.e. with a builder you can't create a class with an invalid state, while with a self builder you can have one)

    • @git-amend
      @git-amend  ปีที่แล้ว

      Great insights on the 'self builder' approach! It's a neat way to streamline object creation, especially when inheritance isn't a factor. Thanks for sharing this alternative!

  • @kecia9988
    @kecia9988 8 หลายเดือนก่อน

    Great video!, btw on 3:40 you wrote that we should consider initializing the Builder with a prefab but how is that done? what if your "Enemy" class is the prefab in question? Should I put the prefab as a parameter of the method Build()?

    • @git-amend
      @git-amend  8 หลายเดือนก่อน +2

      I would consider using a prefab if you have several components that are common to all of a particular type of thing, like an Enemy. So all Enemies might have the same mesh and colliders for example, and the prefab saves you having to create a new game object and set those for each one. You could pass a reference to that prefab as a parameter, and that way you only need to instantiate a version of that prefab with the additional settings you want set by the Builder. You could also have a factory that has references to many variations of Enemy prefabs that has a CreateEnemy() method - it might choose a prefab at random from a List, then use the Builder to do some additional configuration and return a ready to use Enemy.

  • @ragerungames
    @ragerungames ปีที่แล้ว

    Great explanation!! Thank you!

    • @git-amend
      @git-amend  ปีที่แล้ว

      You're very welcome!

  • @trell_7842
    @trell_7842 ปีที่แล้ว

    Whooa, Great thx. Now i finnaly understand what difference between the two. Not as big as i excepted.

  • @friedcrumpets
    @friedcrumpets ปีที่แล้ว

    I'd be very curious to see your take on a Composite Tree or even a behaviour tree. I built an implementation after reading a blog post by the developer of Project Zomboid, however I've had some trouble finding great use cases for it. Fantastic tutorials. I really hope your channel gains some traction

    • @git-amend
      @git-amend  ปีที่แล้ว +1

      Great suggestion! I have a related topic already on my todo list, and I'll jot this down as well. Thanks!

  • @kevin41307
    @kevin41307 10 หลายเดือนก่อน

    amazing tutorial...!

    • @git-amend
      @git-amend  10 หลายเดือนก่อน

      Haha are you binge watching all the videos? 😀

    • @kevin41307
      @kevin41307 10 หลายเดือนก่อน

      @@git-amend yeah, it is really helpful. The real-world example in video are great. I wish I can watch these video earlier. Thanks a lot.

  • @timurnikolaev1438
    @timurnikolaev1438 8 หลายเดือนก่อน

    nice and clear

    • @git-amend
      @git-amend  8 หลายเดือนก่อน

      Thank you!

  • @oldshamen
    @oldshamen ปีที่แล้ว

    Great tutorial. In the interest of completeness, could you suggest how you build from a prefab instead of creating and setting up a gameobject from code (as suggested in one of the on-screen tips in the video)?

    • @git-amend
      @git-amend  ปีที่แล้ว +2

      Sure - you could either pass in the prefab as part of the constructor, or in the final Build() method. Here is an example:
      public class Builder {
      GameObject enemyObject;
      public Builder(GameObject prefab) {
      enemyObject = GameObject.Instantiate(prefab);
      }
      public Builder WithName(string name) {
      enemyObject.name = name;
      return this;
      }
      public Builder WithHealth(int healthValue) {
      var healthComponent = enemyObject.GetOrAdd();
      healthComponent.SetHealth(healthValue);
      return this;
      }
      public GameObject Build() {
      return enemyObject;
      }
      }

    • @ArnoVai
      @ArnoVai 3 หลายเดือนก่อน

      What's the purpose for Build() method in this context? Does it pass the enemy referece to other classes?

  • @SirDMX
    @SirDMX ปีที่แล้ว

    Pretty useful thank you :D

  • @axiomgamesofficial
    @axiomgamesofficial ปีที่แล้ว

    Subscribed!

    • @git-amend
      @git-amend  ปีที่แล้ว

      Awesome, welcome to the channel! More great content is on the way!

  • @shadyleegamer
    @shadyleegamer 5 หลายเดือนก่อน

    How do you get to use the single line and multiline code prediction and completion in Rider?

    • @git-amend
      @git-amend  5 หลายเดือนก่อน

      There are 2 ways, and I have both but in the videos I use GitHub Copilot: github.com/features/copilot
      The other way is to use JetBrains AI Assistant: www.jetbrains.com/ai/
      Both of these are paid plugins and cost $10/mo.

  • @bhaktijpatil
    @bhaktijpatil 8 หลายเดือนก่อน

    I'm used to Java at work and follow most design patterns. But I'm really struggling to use them with Unity 3D.
    I'm trying to build a minecraft like block system for my game and can't quite figure out a way to do this in a way that's very extendible.
    For now I'm just trying to figure out a way to create 100s of blocks in a way that I have a base block with all the properties for ex: isFlammable, isTransparent, textures (6 for each face) but I'd like a way to select uniformMaterialSetup, distinctMaterialSetup, topDownSidesMaterialSetup, etc. And then I just create 100s of prefabs? And store it somewhere, or in a way that I can apply a block type to any baseblock and it gets all the properties.
    I've explored scriptableobjects, OOP mechanics and patterns so far. But even in my head I can't build a proper architecure I'm happy with.
    Most of my struggles come from how the inspector interacts with classes and mesh vs code.
    Your videos have helped a lot after trying a lot of things for a few days, but I'd appreciate a guideline for how I should start thinking about this.
    Thanks a lot for these videos.

    • @git-amend
      @git-amend  8 หลายเดือนก่อน +1

      Thanks for the comment. I wonder if the Flyweight pattern might help you out with the blocks. By separating intrinsic data (e.g., textures, flammability) from extrinsic state (e.g., position, specific material setups), you can create a base block type and then efficiently instantiate and manage variations through shared data structures. The Flyweight can reference your base prefab. Then maybe a Factory / Builder combination to create all kinds of variations?

    • @bhaktijpatil
      @bhaktijpatil 8 หลายเดือนก่อน

      @@git-amend wow, I just started reading about this as I've not used it ever before and what it intends to do aligns very closely with what I want. I understand that in the end I will end up using most common patterns, but this is exactly what I was struggling with. What should be the outermost pattern if that makes any sense. Thank you so much. I will read more about this and comment back when I make progress.

    • @git-amend
      @git-amend  8 หลายเดือนก่อน

      @@bhaktijpatil Sounds good. I also have a video called Flyweight Factory that does something like this. The video is about projectiles, but you could do something similar for blocks.

  • @stickguy9109
    @stickguy9109 ปีที่แล้ว

    I like this kinda videos. My code always suffers from excess spaghetti

    • @git-amend
      @git-amend  ปีที่แล้ว

      Awesome! Using patterns can make a world of difference in your projects!

  • @ugurkarabulut8598
    @ugurkarabulut8598 ปีที่แล้ว

    Can you make a video about adapter pattern

    • @git-amend
      @git-amend  ปีที่แล้ว

      Yes, I've got that on my to-do list!

  • @Sworn973
    @Sworn973 ปีที่แล้ว

    Meh, the only think I really don't like about the "fluent builder strategy" that is done here, is that you end up coping the entire object that you want to build, having the builder return itself is the way to go, but without making a clone of the target object. So you don't have to duplicate everything. Quick example is to just add a new property like "isActive", so you have the get/set for the actual class, and now you have to duplicate everything in the builder, a new isActive property with also its getter and setters.

  • @octia2817
    @octia2817 ปีที่แล้ว +2

    Cool video, but some of the sound effects near the beginning were too loud.

    • @git-amend
      @git-amend  ปีที่แล้ว +1

      Thanks for the feedback, I'll keep that in mind.

  • @Cxdyy
    @Cxdyy ปีที่แล้ว

    Why you still using unity? Just curious

    • @git-amend
      @git-amend  ปีที่แล้ว +1

      That's a good question, and a few people have asked if I will make a video about that - which I still need to decide. While I'm not happy about the actions of Unity management, I'm also not interested in watching it burn to the ground completely and potentially destroying the work of so many, especially those who make their living making tools for Unity. For the next few weeks at least, I'll focus on making videos that are more about software engineering principles, which are transferable to any modern programming language.