Тёмный

Builder Pattern - Design Patterns 

Web Dev Simplified
Подписаться 1,6 млн
Просмотров 137 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 129   
@DodaGarcia
@DodaGarcia 10 месяцев назад
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 2 месяца назад
thanks for information.
@KamelJabber1
@KamelJabber1 5 лет назад
Discovered your channel today, great series of videos, deserves more views!
@WebDevSimplified
@WebDevSimplified 5 лет назад
Thanks! I really appreciate it. I have more videos planned for this series as well.
@skalippanbalippan6972
@skalippanbalippan6972 4 года назад
Why don't we just put a setter and getter inside the User class?
@blank-vw2sb
@blank-vw2sb 3 года назад
It's pretty time consuming to write for every single property. AND I personally don't like that interface...
@maheerali531
@maheerali531 4 года назад
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) } }
@rnater7145
@rnater7145 2 года назад
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)
@xBZZZZyt
@xBZZZZyt 3 года назад
//why not just do this: class User{} var user=new User(); user.name="asd"; user.address=new Address("1","main");
@TheHuntingSpot
@TheHuntingSpot 2 года назад
Maybe I'm old school but I like the having semicolons. What does everyone else think?
@Q99a
@Q99a 2 года назад
Hi, why we've used build method in builder class ? Like what's wrong about using builder class.
@technomaestro6092
@technomaestro6092 3 года назад
Can we do this with keyword arguments like **kwargs in python
@FluidEnjoyer
@FluidEnjoyer 2 года назад
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.
@JimmyC0
@JimmyC0 2 года назад
Why don't we just put the setters method inside the user class with constructor having one parameter "name"
@tubehelpr
@tubehelpr 4 года назад
Great stuff buddy! Love these pattern explinations.
@unique_god
@unique_god 2 года назад
Imagine having builder class for every class taking care of super classes and child classes and composition
@mahdisalem3776
@mahdisalem3776 2 года назад
whats the idea behind creating new class called UserBuilder , we can simply add all set methods inside the class user itself ?
@deansprivatearchive
@deansprivatearchive 3 года назад
Shouldn't you use extends?
@Solarium501
@Solarium501 Год назад
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 Год назад
Wish you all the best with your interview!
@matis9783
@matis9783 4 месяца назад
how was the interview?
@VibhavChaddha
@VibhavChaddha 3 года назад
There are very few good teachers and you are one of them. Amazingly explained. Loved it. And thanks for that.
@soniablanche5672
@soniablanche5672 4 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-0GTe8e7DYHk.html
@sankethb.k642
@sankethb.k642 3 года назад
Thank you. Can you please tell how did you linked live server to javascript
@brijspy
@brijspy 4 года назад
Great stuff Kyle ! Loved these design patterns, keep up the good work :)
@zerobit778
@zerobit778 2 года назад
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~
@adityamishra348
@adityamishra348 2 года назад
Why can't we simply use named parameters?
@TheHuntingSpot
@TheHuntingSpot 2 года назад
where did you get that boomerang in the background?
@imadetheuniverse4fun
@imadetheuniverse4fun 2 года назад
makes me really appreciate python kwargs
@deependrajoshi199
@deependrajoshi199 Год назад
Beautiful article. Well explained, loved it. Thank you.
@aryankumar87771
@aryankumar87771 2 года назад
is there a video on Factory Design Pattern ?
@fabioribeirodecarvalho2382
@fabioribeirodecarvalho2382 3 года назад
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
@donnytechiera957
@donnytechiera957 5 лет назад
Bro you make coding simplified !!
@WebDevSimplified
@WebDevSimplified 5 лет назад
Thanks! That is the goal.
@konstantinkkk8397
@konstantinkkk8397 3 года назад
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?
@kinansharif5625
@kinansharif5625 2 года назад
Hey, can you say Backbone's way of initializing views and models, uses the second approach of the builder design pattern? Thanks !
@3ab9ari1
@3ab9ari1 4 года назад
for the second methode is that available just in javaScript ? and why not for other languages ?
@jonathanmartinez7912
@jonathanmartinez7912 4 года назад
Thanks for the clear and straightforward explanation of this concept! The examples you used helped me understand builders a lot better.
@shivabansfore7510
@shivabansfore7510 2 года назад
can we use this design pattern with react js?
@jamshediqbal7936
@jamshediqbal7936 4 года назад
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.
@abdelrhmanshokr7546
@abdelrhmanshokr7546 4 года назад
when I use the build method it returns an undefined even though I did exactly as you did !!!
@jordanski5421
@jordanski5421 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.
@guitarboy12
@guitarboy12 4 года назад
Why can't a C++ Builder Pattern be this simple? haha
@harshpatel7704
@harshpatel7704 3 года назад
Your channel is underrated. (full stop!)
@yinonelbaz5309
@yinonelbaz5309 Год назад
Thank you very much!!!
@Luxcium
@Luxcium 3 года назад
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)…
@Vibestr
@Vibestr 4 года назад
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.
@NoahNobody
@NoahNobody 3 года назад
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.
@luisrueda4476
@luisrueda4476 2 года назад
Good explanation!
@kaicooper9421
@kaicooper9421 2 года назад
This is very useful. Perfect req fields
@davesomeone4059
@davesomeone4059 2 года назад
I like short videos that only explain one thing vs long tut videos that do it all.
@cesarmuzio1154
@cesarmuzio1154 2 года назад
Thanks for sharing !
@moonshelter9137
@moonshelter9137 4 года назад
Thank you so much, well explained and all
@mattmaloney5988
@mattmaloney5988 3 года назад
Please do a hair styling tutorial.
@praveengundla1235
@praveengundla1235 4 года назад
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)?
@emirsalihovic6616
@emirsalihovic6616 3 года назад
Kyle, can you do a design pattern series? :)
@davidjustice2323
@davidjustice2323 4 года назад
Kyle, how about using optional parameters like constructor(name?, age?) ?
@WebDevSimplified
@WebDevSimplified 4 года назад
By default every parameter in javascript is optional.
@davidjustice2323
@davidjustice2323 4 года назад
@@WebDevSimplified thanks for replying boss
@mdsajaldeowan1054
@mdsajaldeowan1054 3 года назад
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
@sagyas
@sagyas 3 года назад
Can't you just remove 'age' and 'phone' from the constructor, and put the Setters in the User class?
@baphnie
@baphnie 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 года назад
@@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.
@KyleRebstock
@KyleRebstock 3 года назад
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.
@alextipub
@alextipub 4 года назад
Thanks. Pretty nice explanation, subscribed
@amjadshadid90
@amjadshadid90 3 года назад
thanks a lot
@techuchiha6510
@techuchiha6510 5 лет назад
Keep up the good work man!! Your channel is going to be epic one day 👍🏻👍🏻👍🏻
@WebDevSimplified
@WebDevSimplified 5 лет назад
Thanks!
@rolikaseventysix
@rolikaseventysix 5 лет назад
Exactly!
@awekeningbro1207
@awekeningbro1207 2 года назад
And now today he has 1M subs
@NitinKatiyarCircle
@NitinKatiyarCircle 5 лет назад
Its painful when you write code without semicolon 😨
@WebDevSimplified
@WebDevSimplified 5 лет назад
Semicolons aren't needed and only make the code messy in my opinion.
@NitinKatiyarCircle
@NitinKatiyarCircle 5 лет назад
@@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.
@yaseralamoodi8314
@yaseralamoodi8314 5 лет назад
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.
@harag9
@harag9 5 лет назад
Interesting, thanks for this, but quick question - why no semi-colons? Are they not needed anymore in javascript?
@WebDevSimplified
@WebDevSimplified 5 лет назад
They are not needed anymore.
@r3boxx
@r3boxx 10 месяцев назад
Where is the director. I am confused. I have seen other tutorials where they use something called a director.
@joeb.1163
@joeb.1163 3 года назад
Very good stuff
@usmaness
@usmaness 5 лет назад
Great video, I wonder if there is a way to implement builder like in JS with php, regardless the original way
@WebDevSimplified
@WebDevSimplified 5 лет назад
What do you mean? You can implement this pattern in any programming language of your choice.
@purduetom90
@purduetom90 3 года назад
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.
@fiddler-dv4or
@fiddler-dv4or 4 года назад
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?
@barakatosalon
@barakatosalon 5 лет назад
Great video !!! Thanks for sharing this knowledge !
@WebDevSimplified
@WebDevSimplified 5 лет назад
You're welcome!
@austinlords
@austinlords 5 лет назад
so clean. Your videos are perfect little nuggets for beginners. Enough info to understand the "why" without getting bogged down in the weeds. Thanks!
@WebDevSimplified
@WebDevSimplified 5 лет назад
You are very welcome!
@DreQueary
@DreQueary 3 года назад
This is so slick. Very nice.
@yaolegoleynik
@yaolegoleynik 5 лет назад
Thank you :) Need more pattern please
@ivanpavlovnorth
@ivanpavlovnorth 5 лет назад
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.
@andersonlavor
@andersonlavor Год назад
The first one is builder pattern. Second example is called "named parameters" , you can use it in classes and functions.
@quanghong3922
@quanghong3922 4 года назад
awesome thank you
@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
@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?
@blackpurple9163
@blackpurple9163 Год назад
So this is like the state Hook in React?
@helgestegemoen73
@helgestegemoen73 Год назад
Thanks. Trying to learn Builder Pattern in Java, and found your video very helpful 🙂
@elhamuddin.mahmoodi
@elhamuddin.mahmoodi 5 лет назад
Which theme is this in your VB Code I love it, plz name it.
@WebDevSimplified
@WebDevSimplified 5 лет назад
It is just the default dark theme.
@davidfonseca698
@davidfonseca698 5 лет назад
That was funny lol
@GustavoFélix-f1d
@GustavoFélix-f1d Год назад
Simple, useful and very clear. Thanks man for that amazing content!
@d0paminer
@d0paminer 3 года назад
thx from Russia..!
@GenerikV
@GenerikV 2 года назад
Really helpful. I was looking for python examples but the ones I found were making it bit too complicated, this was simple and precise.
@Ali-mc4le
@Ali-mc4le 4 года назад
Please tell me you work at google? You are damn good. Thanks for explaining this.
@SaminYasir-f3m
@SaminYasir-f3m 9 месяцев назад
Great Explanation with examples! Keep it up, man!
@shivammakwan6409
@shivammakwan6409 5 лет назад
cool...👍
@WebDevSimplified
@WebDevSimplified 5 лет назад
Thanks!
@olegsuprun7590
@olegsuprun7590 3 года назад
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
@WhiteSiroi
@WhiteSiroi Год назад
thank you
@dudeimadolphin4318
@dudeimadolphin4318 5 лет назад
nice your doing so good man
@WebDevSimplified
@WebDevSimplified 5 лет назад
Thanks!
@natqe4049
@natqe4049 5 лет назад
Thanks
@WebDevSimplified
@WebDevSimplified 5 лет назад
You're welcome!
@cleverengineer2410
@cleverengineer2410 Год назад
You are a Legend.
@idev6775
@idev6775 3 года назад
thank you so muchh
@jarwishroshan4298
@jarwishroshan4298 2 года назад
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? 😂
@largo17
@largo17 2 года назад
You should really use console.table() for these examples :)
Далее
Singleton Pattern - Design Patterns
8:28
Просмотров 158 тыс.
Builder Design Pattern Explained in 10 Minutes
10:45
Просмотров 29 тыс.
Свадьба Раяна Асланбекова ❤️
00:12
МОЮ ТАЧКУ РАЗБИЛИ...!
39:06
Просмотров 366 тыс.
Teeth gadget every dentist should have 😬
00:20
Просмотров 975 тыс.
FATAL CHASE 😳 😳
00:19
Просмотров 1,6 млн
Node.js Doesn’t Suck Anymore
16:59
Просмотров 114 тыс.
10 Design Patterns Explained in 10 Minutes
11:04
Просмотров 2,3 млн
Facade Pattern - Design Patterns
8:50
Просмотров 105 тыс.
JavaScript Pro Tips - Code This, NOT That
12:37
Просмотров 2,5 млн
Command Pattern - Design Patterns
14:49
Просмотров 99 тыс.
5 Design Patterns Every Engineer Should Know
11:51
Просмотров 939 тыс.
Learn Event Delegation In 10 Minutes
9:57
Просмотров 57 тыс.
Свадьба Раяна Асланбекова ❤️
00:12