The Java Builder Pattern, and my favorite secret technique

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 44

  • @Jack_Hodkinson
    @Jack_Hodkinson  Před 5 měsíci +3

    What topic would you be interested in learning about next?

    • @PilarczykM
      @PilarczykM Před 4 měsíci

      Any design pattern will be valuable 🤗

  • @jamessinnott8798
    @jamessinnott8798 Před 29 dny +2

    Thanks for the video. Explained very well compared to some of the other tutorials I've seen online.

  • @Play_Streams
    @Play_Streams Před 5 měsíci +10

    I love this no-fluff approach. Simple and straight to the point. Sub +1

  • @DamLee88
    @DamLee88 Před 5 měsíci +7

    also lombok @Builder makes the job easier, thanks good video

  • @IvanToshkov
    @IvanToshkov Před 6 měsíci +2

    Nice. I normally prefer to use runtime checks and exceptions, but for more complex objects the multiple interfaces may pay up?
    Here's an idea for a followup video: You have three classes: an abstract Base class and classes A and B which extend it. Create builders for them without code duplication.

  • @DominikusHerzberg
    @DominikusHerzberg Před 6 měsíci +2

    Wow, very impressive explanation and coding style. The channel I was looking for but didn't know existed. Thank you very much!

  • @returncode0000
    @returncode0000 Před 7 měsíci +3

    I like your explanations so much! Always on point and really helpful, great job 👍

  • @bcampera
    @bcampera Před 3 měsíci

    Thanks for the explanation. I feel like this is only needed because of modern features that other languages have and Java doesn't.
    I had some experience with Dart and I loved its named constructors and named mandatory and optional parameters. I will never understand why this doesn't get added to Java

  • @vladtudorache2483
    @vladtudorache2483 Před 29 dny +1

    Your best video.

  • @mrindian7422
    @mrindian7422 Před 7 měsíci +2

    Love the way you think ❤

  • @vasealis
    @vasealis Před 5 měsíci

    You can use also a Record class, the fields in a record class are immutable as well.

  • @vib7777
    @vib7777 Před měsícem

    Awesome!! Subscribed

  • @vendettavera4641
    @vendettavera4641 Před 4 měsíci

    Nice explanation, can't wait for more

  • @tylerbakeman
    @tylerbakeman Před 6 měsíci

    Coding setters as chain-able methods is always satisfying:
    instead of- void setX () { … }
    using- ClassName setX() { … return this; }
    so you can theoretically:
    object.setX( v1 ).setY( v2 )…
    The only issue is if the setter’s aren’t final (returning a value other than this)- setters should probably be final anyhow (unless you have some sort of EventDispatch system).

  • @maximschott1300
    @maximschott1300 Před 16 dny

    Thanks a lot for this video! +1 sub, so don't stop recording the interesting videos :)

  • @PilarczykM
    @PilarczykM Před 4 měsíci

    Very good explanation 🎉

  • @prodevops6271
    @prodevops6271 Před 6 měsíci

    Love it and subscribed after watching fist 15 seconds of this video.❤

  • @burningfire2k
    @burningfire2k Před 6 měsíci

    That was a fast explanation 👏

  • @Mirage2020
    @Mirage2020 Před 5 měsíci

    Java seriously needs to consider adding support for named parameters. There is just too much one needs to to in order to have the same functionality as python, dart and kotlin named parameters (it would also help a lot with deconstruction patterns, which they are trying to get good using the new proposed "with" keyword

  • @sobeck6900
    @sobeck6900 Před 5 měsíci +3

    WOW, explained more in 3 min than some books...

  • @mrindian7422
    @mrindian7422 Před 7 měsíci +2

    Can you pls create complete playlist for along with real time project in Java 8 for collage student

    • @Jack_Hodkinson
      @Jack_Hodkinson  Před 7 měsíci +1

      Working on it! I have a live coding project here, where I implement an ArrayList in real time czcams.com/video/P2P-ZUvIsZM/video.html

    • @mrindian7422
      @mrindian7422 Před 7 měsíci +1

      @@Jack_Hodkinson Thank you very much

  • @user-lj6xj5bg6o
    @user-lj6xj5bg6o Před 6 měsíci +1

    I am your 1000th number Subscriber

  • @softwaretactics1536
    @softwaretactics1536 Před 5 měsíci

    It is so mind boggling that you have imbibed so much into a 3 minute video!

  • @noelgomile3675
    @noelgomile3675 Před 5 měsíci +1

    Would this be needed if Java had named parameters?

    • @Jack_Hodkinson
      @Jack_Hodkinson  Před 5 měsíci

      Good question. Not really!

    • @dentjoener
      @dentjoener Před 5 měsíci

      I always tell people that builders are just shitty excuses for named parameters. I tend to shy away from them because I hate them with a passion. Use smaller objects that can be composed into larger objects, link this with some domain driven design (a name might be a string, but an Email sure as hell shouldn't be), and there's way less issues. Also static factory methods >>> constructors.

  • @user-xb4dj3ky6m
    @user-xb4dj3ky6m Před 5 měsíci

    Could you share the editor theme from the examples?

    • @Jack_Hodkinson
      @Jack_Hodkinson  Před 5 měsíci

      Hi, the examples are all written in markdown using Marp (marp.app/). I use the Visual Studio Code extension.

  • @loyyeeko1231
    @loyyeeko1231 Před 6 měsíci

    wonderful

  • @ShubhamKumar-vh7ti
    @ShubhamKumar-vh7ti Před 6 měsíci

    Subscribed

  • @poloolo69
    @poloolo69 Před 6 měsíci

    real

  • @farshidnaqizadeh159
    @farshidnaqizadeh159 Před 6 měsíci

    why just return class object in setter? so alots of codes are removed and result is the same.

    • @desoroxxx
      @desoroxxx Před 6 měsíci

      No, otherwise you wouldn't be able to chain them

    • @scarletdice
      @scarletdice Před 5 měsíci +2

      then you have a class that is mutable. might not what you want when immutability is intended.

  • @terrytorres5026
    @terrytorres5026 Před 5 měsíci

    Wholy crap,then we wonder why coding is overcomplicated and breaks when new releases of Java come out.

  • @josepescina4360
    @josepescina4360 Před 5 měsíci

    too much work