Builder Pattern - Design Patterns

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

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

  • @DodaGarcia
    @DodaGarcia ปีที่แล้ว +16

    The purpose of the Builder pattern is not just so that you can have optional parameters, it's to separate the construction of an object from its representation. Of course it's overkill if all your setters are going to be this.property = value, but it should be communicated that there's a massive benefit in using the pattern for cases where properties need to be validated before being set, or where setting them affects properties that had been set beforehand and so on.

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

      thanks for information.

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

    I am preparing for a technical test for applying to a company and during the interview they hinted out that the test is going to be mostly about design patters. I have never heard of design patterns before and every source on the internet is confusing. However, you are just making it simple and understandable by breaking down each pattern. Thank you so much for these videos. Subscribed.

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

      Wish you all the best with your interview!

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

      how was the interview?

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

    Discovered your channel today, great series of videos, deserves more views!

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

      Thanks! I really appreciate it. I have more videos planned for this series as well.

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

    There are very few good teachers and you are one of them. Amazingly explained. Loved it. And thanks for that.

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

    Your channel is underrated. (full stop!)

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

    I was so stuck trying to implement this functionality in my application but know I know this pattern it's made things incredibly easy, thanks for sharing.

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

    so clean. Your videos are perfect little nuggets for beginners. Enough info to understand the "why" without getting bogged down in the weeds. Thanks!

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

    Another great lesson. I'm a php guy, but this is all the same theory. I think accidently created builder class the other day, but now I know what it was I made.

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

    I like short videos that only explain one thing vs long tut videos that do it all.

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

    This is good stuff. Glad someone did a good JS vid on this pattern. I think it would be nice to show more of the most powerful reason why you use the builder method which you did allude to at the very end. When an object ends up having to pass many objects to the constructor that could just be composed and built out with builder methods. That's where the real power shows up. Love your content. Great presentation. Would love to see more.

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

    Thanks for the clear and straightforward explanation of this concept! The examples you used helped me understand builders a lot better.

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

    Beautiful article. Well explained, loved it. Thank you.

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

    Great stuff buddy! Love these pattern explinations.

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

    Great stuff Kyle ! Loved these design patterns, keep up the good work :)

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

    This is very useful. Perfect req fields

  • @SaminYasir-f3m
    @SaminYasir-f3m 11 หลายเดือนก่อน

    Great Explanation with examples! Keep it up, man!

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

    Thank you very much!!!

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

    Thanks for sharing !

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

    Thanks. Trying to learn Builder Pattern in Java, and found your video very helpful 🙂

  • @GustavoFélix-f1d
    @GustavoFélix-f1d ปีที่แล้ว

    Simple, useful and very clear. Thanks man for that amazing content!

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

    Imagine having builder class for every class taking care of super classes and child classes and composition

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

    This is so slick. Very nice.

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

    Good explanation!

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

    Thank you so much, well explained and all

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

    Keep up the good work man!! Your channel is going to be epic one day 👍🏻👍🏻👍🏻

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

    Thanks. Pretty nice explanation, subscribed

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

    Really helpful. I was looking for python examples but the ones I found were making it bit too complicated, this was simple and precise.

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

    The first one is builder pattern. Second example is called "named parameters" , you can use it in classes and functions.

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

    You are a Legend.

  • @joeb.1163
    @joeb.1163 4 ปีที่แล้ว +1

    Very good stuff

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

    Great video !!! Thanks for sharing this knowledge !

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

    thanks a lot

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

    good video, please keep up and do more videos. thanks

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว

      Thank you. I have a backlog of video ideas so long I fear I will never reach the end of it, so you won't have to worry about me stopping anytime soon 😜

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

      @@WebDevSimplified could you also do videos on SOLID principles. I find some of them really difficult to grasp. I purchased a course on Udemy but I always end up watching your videos to really understand how these work.

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

    awesome thank you

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

    Thank you :) Need more pattern please

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

    One thing that the Builder could be better than named Parameters is that : When the set.... method not only need set the value solely but has other logics which may relate to other parts.
    Please verify my guess. Thanks~

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

    makes me really appreciate python kwargs

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

    Wouldn't it make more sense to create the User object inside the build method? That way you can build as many different User object as you want.

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

      Correct... Heres an example on java th-cam.com/video/0GTe8e7DYHk/w-d-xo.html

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

    Why not use "Object.assign(this, options)". It prevents use to write this.address = address etc

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

      how would we implement this? Like this(?):
      class User {
      constructor( name,{age,phone,address}={} ) {
      User.assign(this, name, age, phone, address)
      }
      }

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

    thank you

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

    I'm wondering if use the get and set method could be a way to solve this problem....thanks for the course, it help us a lot...ok I tested this way, but I realize we cannot declare a property class like private to try esolation them. So, the method getters and setters become useless in this case...I reviewed the case and we can has the private fields with # before the variable name

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

    thx from Russia..!

  • @sankethb.k642
    @sankethb.k642 3 ปีที่แล้ว +1

    Thank you. Can you please tell how did you linked live server to javascript

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

    nice
    your doing so good man

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

    Kyle, can you do a design pattern series? :)

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

    whats the idea behind creating new class called UserBuilder , we can simply add all set methods inside the class user itself ?

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

    where did you get that boomerang in the background?

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

    thanks, Kyle for the great video
    Kyle is it possible to remove the final build method and gets the same result
    if so then how

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

    Kyle, how about using optional parameters like constructor(name?, age?) ?

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

      By default every parameter in javascript is optional.

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

      @@WebDevSimplified thanks for replying boss

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

    is there a video on Factory Design Pattern ?

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

    cool...👍

  • @fiddler-dv4or
    @fiddler-dv4or 4 ปีที่แล้ว +2

    Thanks for the great break down in this pattern! I love that your doing design patterns for JavaScript. Have you given it any thought on do this series using proto_types?

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

    Hey, can you say Backbone's way of initializing views and models, uses the second approach of the builder design pattern?
    Thanks !

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

    Really useful video!
    But resolution options are available in the only 360p.

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว

      I am able to select 1080p resolution on this video. Maybe youtube was having some trouble when you tried to view the video.

    • @ivanpavlovnorth
      @ivanpavlovnorth 5 ปีที่แล้ว

      ​@@WebDevSimplified I familiar with that thing, but it was so strange to watch it twice on 360p on two different devices... As it turns out the problem is in Firefox on Windows 10 N.
      Thanks for smooth picture at 60fps.

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

    I tend to keep separate objects with data value from objects with methods and properties (getters and/or setters)… what wording (or naming) could be used to describe such objects in JavaScript? I would tend to use POJO but it’s not like it is something that is without any method or I would call it a JSON like object (obviously it wouldn’t have a constructor)…

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

    Thanks a lot for your effort.. BTW in builder class methods we are setting properties of actual user object , i.e. in setphone method setting phone property of user object so user is not immutable ... So why can't we set these properties individually from the client (calling code)?

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

    Hi, why we've used build method in builder class ? Like what's wrong about using builder class.

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

    Can't you create the "functions" from the first builder in the user class itself? I don't see to point of the builder object.

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

    Thanks

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

    for the second methode is that available just in javaScript ? and why not for other languages ?

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

    Why don't you use const instead of let, when initiating class?

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

      Let allows to update field within the scope while CONST don't.

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

    Thank you for Video Kyle. I actually have a doubt if we can call any parameters for multiple times in the builder pattern?

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

    can we use this design pattern with react js?

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

    Shouldn't you use extends?

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

    I'm surely not understanding something. Why even use a builder class in the first approach?
    afaik this is valid code (assuming that each set method returns _this_):
    const user = new User('Bob').setAge(22).setPhone(phone)

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

    Hi, I cannot find optional parameters on MDN or any other resourses. It looks like destructuring and thats all. No need to call it optional parameters? or I mistake?

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

    Great video, I wonder if there is a way to implement builder like in JS with php, regardless the original way

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

      What do you mean? You can implement this pattern in any programming language of your choice.

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

      Yes, you can do the first way in PHP. Methods in a php class can return $this. Works beautifully and is a great way to eliminate the use of long parameter lists.

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

    thank you so muchh

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

    Hey you're posting Great Stuff man!! Thank you for that. Btw Can you show us how do you run your js files in browser? 😂

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

    when I use the build method it returns an undefined even though I did exactly as you did !!!

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

    Maybe I'm old school but I like the having semicolons. What does everyone else think?

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

    Interesting, thanks for this, but quick question - why no semi-colons? Are they not needed anymore in javascript?

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

    What's the advantage of using a builder comparing to using setters directly in the user class? Sorry I didn't quite get it

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

    Why don't we just put a setter and getter inside the User class?

    • @blank-vw2sb
      @blank-vw2sb 4 ปีที่แล้ว

      It's pretty time consuming to write for every single property.
      AND
      I personally don't like that interface...

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

    Can we do this with keyword arguments like **kwargs in python

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

    So this is like the state Hook in React?

  • @elhamuddin.mahmoodi
    @elhamuddin.mahmoodi 5 ปีที่แล้ว +1

    Which theme is this in your VB Code
    I love it, plz name it.

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

    Why can't we simply use named parameters?

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

    Where is the director. I am confused. I have seen other tutorials where they use something called a director.

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

    Can't you just remove 'age' and 'phone' from the constructor, and put the Setters in the User class?

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

      Exactly what I was thinking.

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

      agree, quite misleading....

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

      @Sagy Assor the reason is explained at the beginning of the video

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

      @@m3awna in what exact time?

    • @matikb.6733
      @matikb.6733 2 ปีที่แล้ว

      @@sagyas I agree, and believe this at 1:50 is the reason, Building is nice.
      Also Setters aren't better, cause the Builder implies semanticaly that We are *creating* something - the Setters on the other hand just say that You *set* something... "But on what purpose", coz the constructor is right there? - Code Viewers could ask.
      Plus You can feel like Java Dev with Builders - I don't believe that it's a negative name.

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

    Why don't we just put the setters method inside the user class with constructor having one parameter "name"

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

    Bro you make coding simplified !!

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

    builder pattern is confusing w/ all those "this' keywords.

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

      not really if you understand the meaning of "this" keyword first, try to understand it and make resume of what you understand with your own word.

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

    Please do a hair styling tutorial.

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

    //why not just do this:
    class User{}
    var user=new User();
    user.name="asd";
    user.address=new Address("1","main");

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

    Its painful when you write code without semicolon 😨

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

      Semicolons aren't needed and only make the code messy in my opinion.

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

      @@WebDevSimplified I find them make code more clear. When changing syntax in multiple line then it make it clear where it ends. Visual studio 2017 also show an error when do not use semicolon. Also it brings c# and other serverside languages closer to js. Well it's just me. Everyone has their preferences.

  • @Ali-mc4le
    @Ali-mc4le 4 ปีที่แล้ว +3

    Please tell me you work at google? You are damn good. Thanks for explaining this.

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

    Why can't a C++ Builder Pattern be this simple? haha

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

    Im sorry but this is not a classic builder pattern, you also have to implement a director class, and pass a builder object to it , then call construct() on the director and get product from builder

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

    You should really use console.table() for these examples :)