Builder Design Pattern (An Introduction for .NET Developers [.NET 5 and C#])

preview_player
Показать описание
In this video, I am going to walk through the Builder Design Pattern. It is an Introduction video for .NET Developers [.NET 5 and C#].

The Builder design pattern is one of the creational design patterns. This pattern is not very common but very used in scenarios where the creation of an object can become complex.

The previous two videos in this Design Pattern series are:

00:06 - Explaining what is Builder pattern
00:45 - Traditional way for an object creating using a constructor
01:55 - Introduction of the builder class
02:35 - Defining an interface
04:08 - Implementation of the builder class
07:12 - Using builder pattern to register the object in dependency injection container
08:40 - A daily used example of the builder pattern

Рекомендации по теме
Комментарии
Автор

It's a layman explanation. Thanks for sharing

rajneesh
Автор

that was the simplest and clearest explanation of the pattern. good job.

seyhmusozbek
Автор

This was a good intro, but I believe creating the user object in the builder constructor was a mistake. Better to create the user object in the build function, that way you don't have to list all the user properties twice in the builder, and you can keep private setters in the user class itself.

zxph
Автор

All clear, thanks so much for you excellent explain

MrChuyelChief
Автор

How to set address if in case Address is a separate class means address field of User is of type Address. Address class may have fields like StreetNumber, Street, City etc.

pawansarwal
Автор

Thanks much. It would be helpful If you starts the session for Azure or CI/CD pipeline integration...

mahendranchinnaiah
Автор

Thanks! That`s simple and easy to understand! One more question, can I use the "init accessor" from C#9 instead if I want the immutable properties?

williamliu
Автор

just create a interface for the builder and use register it in the ICO not the class itself, so you can use the class in the client or in the api to get the values or assign them in the api not in the registration

twitchdude
Автор

Sometimes it look some patterns are over complex with no reason to use

AliRaza-zyzk
Автор

"services.AddSingleton" what it is?

NameSurnamedsadwrdf
join shbcf.ru