Builder Design Pattern in Java

Поделиться
HTML-код
  • Опубликовано: 17 ноя 2024

Комментарии • 72

  • @TheTravelJunkiee
    @TheTravelJunkiee 4 года назад +22

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

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

  • @jvsnyc
    @jvsnyc 3 года назад

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

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

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

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

  • @rachamallidorasrivignesh4499
    @rachamallidorasrivignesh4499 6 месяцев назад

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

  • @MaheshShinde-pj5fk
    @MaheshShinde-pj5fk Год назад

    Very nice explanation, Thank you so much!!

  • @e.ch.vidyasagarkorada7341
    @e.ch.vidyasagarkorada7341 3 года назад +1

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

  • @sumatapatil860
    @sumatapatil860 4 года назад +2

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

  • @ratulsamanta3158
    @ratulsamanta3158 Год назад

    You're really such a good trainer ❤️

  • @elzwang
    @elzwang 3 года назад +2

    Thank you very much!! Best builder pattern video!

  • @mukundpatel1768
    @mukundpatel1768 4 года назад +1

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

  • @ankurgarg5326
    @ankurgarg5326 2 года назад +1

    Thanks for explaining the concept .

  • @PeekIntoMyDiary
    @PeekIntoMyDiary Год назад

    Great explanation. Thank you so much

  • @supriyadivvela7400
    @supriyadivvela7400 Год назад

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

  • @nagavaraprasadpuppala6715
    @nagavaraprasadpuppala6715 4 года назад +1

    explanation is too good, easily understand ..thanks

  • @tirupatirao7521
    @tirupatirao7521 4 года назад +1

    simple example and clear explanation.

  • @minnuvlog-edigapalli3900
    @minnuvlog-edigapalli3900 Год назад

    Nice explanation Sir ❤

  • @shashikantverma3215
    @shashikantverma3215 4 года назад +1

    content is very easy to understand. Thanks

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

  • @djr4793
    @djr4793 4 года назад +2

    Great explanation, keep the good working going..

  • @venkataramanan2381
    @venkataramanan2381 4 года назад +1

    Thank you for sharing.good tutorial

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

  • @syedovaiss
    @syedovaiss 2 года назад

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

  • @mohsentaleb7270
    @mohsentaleb7270 3 года назад

    simple and great : Thanks a lot.

  • @manikantaammula9279
    @manikantaammula9279 3 года назад

    Your amazing, it's a great explanation.

  • @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 3 года назад

      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.

  • @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?

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

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

  • @vedant6460
    @vedant6460 Год назад

    thanks

  • @fromEmotion
    @fromEmotion 4 года назад +1

    Mind blowing sir

  • @_akagrawal
    @_akagrawal 4 года назад

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

  • @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 3 года назад

      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!

  • @AmanSharma-vb5jl
    @AmanSharma-vb5jl 2 года назад

    U r awesome bro

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

  • @sumanadey6004
    @sumanadey6004 2 года назад +1

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