Builder Design Pattern in Java

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024

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

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

    I have seen multiple videos, no one's clearer in explanation than you :). You're doing such an amazing work! Thank you so much!

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    Thanks for explaining it in such an easy manner. Another important benefit of the builder pattern which you brushed upon briefly is "immutability" which is something I have personally found out to be very useful in many cases.

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

    thank you .this helped me a lot.Some articles and videos are making it complex by taking complex examples.This is perfect and to the point.10/10

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    The best explanation I've seen. My instructor could learn a lot from you. Thank you. I've subbed.

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching. Sure share channel with him ;)

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

    This is the greatest explanation of the builder method that I've ever seen. Thank you for the explanation!

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

    I had so much difficulty in understanding the builder design pattern but you made it so simple to understand its concept. Love your videos. Keep posting as they are really helpful.

    • @CodingSimplified
      @CodingSimplified  2 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

  • @jvsnyc
    @jvsnyc 3 ปีที่แล้ว

    Three minutes in and I already have to give a thumbs-up. Very clear, calm, and concise.

    • @CodingSimplified
      @CodingSimplified  2 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

  • @MaheshShinde-pj5fk
    @MaheshShinde-pj5fk ปีที่แล้ว

    Very nice explanation, Thank you so much!!

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

    your way of explanation is really superb brother really ...... so good please make vedeos on data structures and algorithms as well. Once again thank you so much.😊

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

    This was very simple and easy to understand. Thanks a lot.
    5:50 if you want to skip the theory, though.

    • @CodingSimplified
      @CodingSimplified  2 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    Thank you very much!! Best builder pattern video!

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    Great explanation. Thank you so much

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

    You're really such a good trainer ❤️

  • @minnuvlog-edigapalli3900
    @minnuvlog-edigapalli3900 ปีที่แล้ว

    Nice explanation Sir ❤

  • @e.ch.vidyasagarkorada7341
    @e.ch.vidyasagarkorada7341 3 ปีที่แล้ว +1

    Helps a lot to understand the concept thank you Coding Simplified team #KnowledgeSharingCodingSimplified

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    Thanks for explaining the concept .

    • @CodingSimplified
      @CodingSimplified  2 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    Very nice explanation but i have a doubt like can we update the value of parameter for second time....

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

    Very nice explanation with very easy example which helps is preparing for interviews. Thanks for uploading this.

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

    Great explanation...thanks a lot for making this video......!!!

    • @CodingSimplified
      @CodingSimplified  2 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    You have explained in a very simplified way and this makes it more easy to digest.👍 Thanks

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Thanks Mukund for nice feedback. Keep Watching.

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

    explanation is too good, easily understand ..thanks

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    simple example and clear explanation.

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

  • @chitranshsaxena59
    @chitranshsaxena59 3 ปีที่แล้ว

    Hey, so based on 2:14 , the way we mark parameters as required=true/false in jcommander, does this come in BuilderPattern too? If yes, how?

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

    content is very easy to understand. Thanks

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    Great explanation, keep the good working going..

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

      Thanks for your feedback. Keep Watching.

  • @ParasharShweta
    @ParasharShweta 2 ปีที่แล้ว

    Hi
    Can you please guide me
    For debugging what all buttons you are using

    • @CodingSimplified
      @CodingSimplified  2 ปีที่แล้ว

      It's all basic buttons in Eclipse. On top, you can see all debugging buttons.

  • @saiyaswanth8
    @saiyaswanth8 4 ปีที่แล้ว

    Here Defining a builder method as static. It's not thread safe right? when multiple threads trying to create vehicle instace using this apporach.

    • @jvsnyc
      @jvsnyc 2 ปีที่แล้ว

      I believe it is not a problem. You are correct to avoid static methods but that is not what we have here, right? In the lines:
      Vehicle car = new Vehicle.VehicleBuilder("1500cc", 4).setAirbags(4).build();
      and
      Vehicle bike = new Vehicle.VehicleBuilder("500cc",2).build();
      The constructor of Vehicle.VehicleBuilder() gives us back our own instance of an object.
      The .setAirbags() and .build() calls are NOT static methods, they are instance methods of class Vehicle.VehicleBuilder. Good question to ask, because it would be a common mistake to make, but was not made here unless I am confused. Static modifier on the nested class means only that you do not need any instance of the outer class to call the constructor of the nested class, which is essential here, because we can't get an instance of the outer class until after we have an instance of the inner one.
      A bit tricky, but very cool.

  • @hazhirahmadzadeh2055
    @hazhirahmadzadeh2055 2 ปีที่แล้ว

    For the factory pattern I believe if you create a VehicleEnum and then put each to the VehicleFactory would be more descent

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

    Thank you for sharing.good tutorial

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

  • @syedovaiss
    @syedovaiss 2 ปีที่แล้ว

    Don't you think Vehicle Builder violates Dependency Inversion Principle?

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

    I understand whole code. But i dont get why we do in seperate class? we can do same inside Vehicle class. If you will say me for private then my answer if we can set anything from vehiclebuilder then what kind of privacy is it.

  • @_akagrawal
    @_akagrawal 4 ปีที่แล้ว

    What if I want to change airBags after vehicle is created ?

  • @AmanSharma-vb5jl
    @AmanSharma-vb5jl 2 ปีที่แล้ว

    U r awesome bro

  • @mohsentaleb7270
    @mohsentaleb7270 3 ปีที่แล้ว

    simple and great : Thanks a lot.

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

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

    thanks

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

    Where did you set airBags default value to zero ?

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Zero is the default value. For 'car' we called the function setAirbags, but for 'bike', we didn't call, so it initialized with default value, which is 0 because it's integer. So this what is required that if we're not setting other value, it'll set to default values.

  • @viratsuresh5946
    @viratsuresh5946 3 ปีที่แล้ว

    What is the reason for nested class as static ( builder)

    • @jvsnyc
      @jvsnyc 3 ปีที่แล้ว

      If it wasn't static, we would already need an instance of the outer class to use it, so we would have a chicken-and-egg problem, right? Why nested at all instead of stand-alone separate class? We could do that and it would work, but when one class is very much associated with another, we will consider a static nested or inner class. Also, both static nested and (instance) inner classes can access all members, public, protected and private of the containing class. If it was a standalone class in the same package, in order to let that class access the members the members would need to be marked as default access, rather than private, so that is another reason we might choose this.

    • @jvsnyc
      @jvsnyc 2 ปีที่แล้ว

      I watched another video and see a further very good reason why we do it this way. They avoided the nested static class you don't like by providing Setters for all the optionals, which to me almost makes the Builder class pointless. Here's the problem tho. You might set five or six things with the Builder, then when you are done with those and ready to actually build it, it can verify that your combination that you requested even makes any sense. Now, doing the sets one at a time you can't check that the combination is good. Let's say (not perfect example but shows what I mean) you want to say you are married, your anniversary is on April 1st and your wife's name is Taylor Swift. Doing a set on any one of these leaves us in a totally invalid state. You just set a date for your anniversary, but your object says you are not married. Maybe you are about to set the flag to say you are, or maybe you will forget to or setting the Anniversary was just a mistake.
      There's nothing my program can do at that point to prevent you from putting in nonsense combinations of data into the object.
      Sure, you aren't crazy about the static nested class (for some reason) but look at all the pain and suffering it can prevent us!

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

    Mind blowing sir

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Thanks Sumit. Glad you liked it. Keep Watching.

  • @girijaganeshbhat2713
    @girijaganeshbhat2713 4 ปีที่แล้ว

    sir pls share the source code link .The link which you have shared is not working

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Could you please check again. It seems to be working fine.

  • @DimosMos
    @DimosMos 3 ปีที่แล้ว

    Чтож все индусы так коряво по английски говорят!?!

  • @HimanshuSingh-ti6qw
    @HimanshuSingh-ti6qw ปีที่แล้ว

    Bekar pattern h

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

    Helpful

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

      Thanks for your nice feedback. Keep Watching :)

  • @manikantaammula9279
    @manikantaammula9279 3 ปีที่แล้ว

    Your amazing, it's a great explanation.

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.