Builder Design Pattern Explained in 10 Minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.ย. 2024
  • Builder Design Pattern Explained in 10 Minutes. Easy to understand!
    code: github.com/sel... Join the Discord to talk to me and the rest of the community!
    / discord

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

  • @darienverdugo290
    @darienverdugo290 8 หลายเดือนก่อน +7

    At 6:43, this was like my lightbulb moment lol. Then, possibilities started coming to mind. Thanks so much; you just saved me a lot of time.

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

      That’s awesome! Thanks for watching 😊

  • @rutujawattamwar5132
    @rutujawattamwar5132 ปีที่แล้ว +5

    You just made this real easy to understand! Thank You.

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

      That’s great! I’m happy to help 😊

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

    Thank you very much for a very straightforward and easy to understand explanation. I'm going to look at more of your content.

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

      Happy to help!

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

    that was an easy explanation. I've been trying to figure this out, for a week now! lol. thanks dude! kudos!

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

      That’s awesome! Thanks for watching 🙂

  • @acidbunny999
    @acidbunny999 23 วันที่ผ่านมา

    The fact you only have 40k subs is a crime. Subscribe people

    • @kantancoding
      @kantancoding  23 วันที่ผ่านมา

      Hey, thanks for the support 🙂
      More subs will come!

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

    My understanding about builder pattern is use a predefined object inside director class and get the product of our choice Imagine we have a house, different preference of house by different people, instead of constructing a house of one’s choice, why not create a different type of house that are possible and use director to get the house. This saves time as well as avoid bloating of constructors.

  • @ivanmenshchikov4288
    @ivanmenshchikov4288 ปีที่แล้ว +4

    The explanation is very detailed. Thank you. However I would pay more attention to the use cases (when and why do we need this pattern). And I would also use a different language such as Java, C# or Typescript in order to make it easier to understand for people that are not familiar with python syntax. It's also easier to understand what are the instances of variables with those languages.

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

      Good points. I considered adding "when and why" to use the patterns but I felt the videos would be too long for the average attention span. The most recent video that I'm releasing later on goes into a bit more detail about when and why and it easily exceeds 20 minutes. Kind of need to play the balancing game.
      I think you make a really good point about the language and I actually almost used Java (I also considered Go) but I ended up going with Python because it's easy to read. But who knows, maybe I'll remake the videos for multiple languages. Not sure yet.

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

      @@kantancoding I think the language selection as Python is fine, and I'm really thankful for it.

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

      If you want this for a different language, then use the search bar to find it :)

  • @Chronomatrix
    @Chronomatrix 9 หลายเดือนก่อน +7

    How is this pattern better than using the constructor? Perhaps I've not yet seen a real case where this would make sense, maybe if we're dealing with really big constructors with a lot of parameters? Idk

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

      It would be nice to have a complementary video showing why the pattern is useful.

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

      I can also see this as useful if the object's parameters are only given one at a time. You can then use build once all the necessary parameters are given.

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

      I explain why you might use this pattern in the video. Both points about many constructor params and building individual attributes of the object at different points that you both mention are explained in the video. Please watch the whole video 🙂

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

      This pattern comes to handy only when you understand the need. If you are concerned about why it is good replacement of constructors is that it strictly follows open close principle. Otherwise it’s all same tricks, it just saves you from modifying existing working class. I do not see other benefit. The client is happy that additional features didn’t interrupt writing flow.

    • @Javier_Corado
      @Javier_Corado 5 หลายเดือนก่อน +1

      For example I am working on a library for a communication protocol, I have to take multiple types of inputs and depending of those I need to build different type of messages, applying this made my code flexible because I decoupled creation from use and I was able to create different methods for different types of message objects. An alternative would be to create an abstract message class and have concrete implementations and use a factory method pattern, but due to the size of attributes I was repeating my self like crazy, that's why this pattern worked great for me in this case. This also comes in handy when working with protobuffs.

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

    Helpfull? Are you kiding? Was amazing!

    • @kantancoding
      @kantancoding  4 หลายเดือนก่อน +1

      I’m really happy to hear that. Thank you!

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

    I wish I go hug you my friend. You channel is such a gem.

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

      *virtual hug. thank you! I'm happy to help bro

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

    Thank you so much, that was indeed a perfect tutorial! Genius :)

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

    Very nice and straightforward explanation!

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

      Thank you! Happy to help 🙂

  • @chandrikasaha6301
    @chandrikasaha6301 9 หลายเดือนก่อน +2

    If you could make one on Adapter pattern and Strategy pattern please. These confuse me a lot. Adapter - because i get confused with which needs to be wrapped - the examples around contribute more to the confusion. Strategy because it looks like a if-else which is more like a factory - though factory is a creational pattern and strategy a behavioral one

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

      same here

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

      Thanks for the feedback. I will consider it 😊

  • @chandrikasaha6301
    @chandrikasaha6301 10 หลายเดือนก่อน +2

    This was great! Want more design patterns in python please

    • @kantancoding
      @kantancoding  9 หลายเดือนก่อน +2

      Hey! Thanks for the feedback. I’ll likely add more to this playlist eventually. All depends on demand really.

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

      @@kantancoding not sure how youtube ranks videos. i guess by adding the language in the thumbnail would make your videos come on top once searched, because most of the design pattern videos are in java. Also you may add catchy captions, such as 'concept to code - so that you can code your way' etc. I just happened to have stumbled on this. now i keep searching if your new video has come on design patterns. Your videos on design pattern in python are the best which clarifies the fundament of the pattern definition and demonstrate the code with meaningful example. Honestly, this one was intuitively the best among all i have watched/read - and i had browsed a lot before coming here

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

      @@chandrikasaha6301 Yeah the reason I didn't put Python is because you don't need to know Python to understand this video. I'm pretty sure that as long as you know any programming language you will be able to understand this.. But I always forget how language specific people are when learning. I was the same way in the beginning actually so not sure why I always forget this. I think it's a good idea. Thank you

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

    Thanks a lot. Had a lot of trouble with this pattern

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

      My pleasure, happy to help 😀

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

    Let's always do alot of good and encourage others to do the same

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

    very good explanation.. dude you are awesome!! Thanks

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

    If I may ask, what software do you use for the whiteboard like representation of the video?

    • @kantancoding
      @kantancoding  10 หลายเดือนก่อน +1

      I use davinci resolve for pretty much everything 😉

  • @imran-potter
    @imran-potter ปีที่แล้ว +1

    Hey man, why u stopped making videos about algo patterns? please, do continue

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

      Which patterns are you looking for? I think I did all of the most common ones but I wouldn’t mind adding more

    • @chandrikasaha6301
      @chandrikasaha6301 10 หลายเดือนก่อน +1

      @@kantancoding Please make one on Strategy, registry, decorator, flyweight using Python. This one logically made so much sense

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

    helpful

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

    eXcellent’e

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

    I really nice way to use this is for unit tests. If your class takes in like 15 params, you create a default builder for your happy path, and then can individually change individual fields to test your edge cases.
    happyPath = builder.build()
    InvalidZipCode = builder.setZipCode("INVALID_ZIP_CODE")
    IgnoreInvalidZipCode = builder.setZipCode("INVALID_ZIP_CODE").setIgnoreInvalidZipCode(true)

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

      Yes! We actually do this quite often when writing unit tests in Java. Good insight 🔥

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

    can we achieve immutability with this in python

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

      Hmm, probably better to narrow down your question? 🤔

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

      in your Director class, you could create a specification class variable, that would contain set specs for each house type as a tuple, for example :)

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

    I don't understand the purpose

  • @industrialdonut7681
    @industrialdonut7681 9 หลายเดือนก่อน +3

    jesus christ this pattern is a dumpster fire

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

    This feels like such a waste of

  • @high-level-content-maker
    @high-level-content-maker 5 หลายเดือนก่อน +1

    why all similar explanations are explained by the example of dogs, houses and similar nonsense? Do the authors think that we, programmers, will not be able to perceive an example from a real design problem? imho, such explanations are suitable only for those who need to get an assessment at an educational institution

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +1

      It’s just easier to explain in isolation instead of needing to explain some complex architecture as well as the design pattern.

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

      The are actually programs dedicated to literally help building houses 🤨

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

      Not everyone works with the same technologies, not everyone is a webdev. But everyone knows what a house is. The assumption is not that you are dumb, the assumption is that you are smart enough to extrapolate the example to solve problems that you have.