Тёмный

Factory Pattern in C#: Creating Objects with Ease 

campbelltech
Подписаться 2,3 тыс.
Просмотров 12 тыс.
50% 1

In this video, you'll learn how to implement the Factory Pattern in C# and how it can help simplify your object creation process. You'll see step-by-step how to implement this design pattern in your #csharp projects and follow along with practical examples to reinforce your understanding. By the end of this video, you'll be able to create objects with ease using the Factory Pattern, making your code more maintainable, scalable, and organized. Whether you're a beginner or an experienced C# developer, this video is packed with valuable insights that will take your coding skills to the next level.
Link to code in GitHub: github.com/sean-campbelltech/...
#designpatterns #softwareengineer #developer

Наука

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

 

11 май 2023

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 33   
@Nobody-hs9cl
@Nobody-hs9cl Месяц назад
A perfect example of the meaningful application of the Factory Design Pattern. I have seen dozens of videos. This is the only one that clearly shows the benefits of the Factory Pattern.
@campbelltech
@campbelltech Месяц назад
Thank you!
@souvikdatta97
@souvikdatta97 11 дней назад
Amazing
@unnatpandyaGhost
@unnatpandyaGhost 7 месяцев назад
May be tons of videos/articles I watched, but this explains way simpler way. Great work 👍🏼
@campbelltech
@campbelltech 7 месяцев назад
Thank you for the great feedback Unnat. This is our greatest goal, to simply complexity.
@criticalthinker1123
@criticalthinker1123 Месяц назад
*for that I subscribed*
@msdhonicoolcaptain
@msdhonicoolcaptain 6 месяцев назад
Just loved your explanation!! more energy to you
@campbelltech
@campbelltech 6 месяцев назад
Thank you! The same to you!
@akhtar4993
@akhtar4993 7 месяцев назад
Just simple and excellent. Please keep it up.
@campbelltech
@campbelltech 7 месяцев назад
Thank you so much. Simplicity is our greatest goal!
@preslaviliev6843
@preslaviliev6843 2 месяца назад
So simple . Thanks a lot !
@campbelltech
@campbelltech 2 месяца назад
Thanks Preslav!
@GergelyCsermely
@GergelyCsermely 6 месяцев назад
Thanks
@campbelltech
@campbelltech 6 месяцев назад
You're welcome.
@susanfalk2148
@susanfalk2148 Месяц назад
Great video! I was watching one of your other videos explaining abstract factory methods in C#, but halfway through it was marked as private, so I didn't get to see the rest. Will it come back up?
@T0g3ly
@T0g3ly 3 месяца назад
Hi I’m learning design patterns I like your videos but can you possibly make a video of when I should maybe use factory method vs abstract. I understand there isn’t a simple answer but maybe a “Look for these signs answer”
@campbelltech
@campbelltech 3 месяца назад
Thanks for the request. I will consider it.
@Guillen8606
@Guillen8606 4 месяца назад
Great video. What font are you using on vsCode?
@campbelltech
@campbelltech 3 месяца назад
I use the Material Theme on Linux Ubuntu 22.04.
@kylebrault4414
@kylebrault4414 5 месяцев назад
What do you do if CreditCard has a method GetStatement that returns a CreditCardStatementModel object, but GetStatement for paypal returns a PayPalStatementModel object with different fields? Since methods have the same name but a different return type, you couldn't implement a common interface.
@campbelltech
@campbelltech 5 месяцев назад
Hi Kyle, you can introduce a base or abstract StatementModel. Then CreditCardStatementModel and PayPalStatementModel can inherit from or extend StatementModel. Then, let the GetStatement method return StatementModel, and through Polymorphism you can "cast" it back to the concrete types in the concrete classes.
@abdullahbinmamun3803
@abdullahbinmamun3803 6 дней назад
In this case we can use abstract class instead of using an interface. which can have an abstract method named "Statement" which will return a statement. other classes like GooglePay, PayPal and CreditCard will override and implement the same "Statement" method but will return different statements. I hope, I explained it correctly.
@Benndot97
@Benndot97 3 месяца назад
What extension is he using to get that dropdown menu for creating new C# documents quickly?
@sewcyde
@sewcyde 3 месяца назад
DOTNET DEV KIT EXTENSION
@campbelltech
@campbelltech 3 месяца назад
And C# Extensions by JosKreativ
@dipanjandhar3982
@dipanjandhar3982 Год назад
How does your code promotes open closed principle ?
@campbelltech
@campbelltech Год назад
The Factory method allows you to decouple creation logic from your client code. In this way, if you add, for example, a new payment method you only need to add a new class, e.g. ApplePayPayment and add support for it in your factory method. Your client code, which could be your main service code, can then stay exactly the same. In other words, it is closed for modification, but the Factory method makes it open for extension.
@RuanCowley
@RuanCowley Год назад
@@campbelltech Good answer! 👌
@scotterd
@scotterd 3 месяца назад
@@campbelltech wouldn't use also need to add a new enum called ApplePay and modify the client to call the factory with the new enum?
@NewQuietBear
@NewQuietBear 5 месяцев назад
You violate the open/closed principle. Everytime u have to add a new payment method to the factory and enum.
@campbelltech
@campbelltech 5 месяцев назад
The client code, however, remains unchanged and follows the open-closed principle. Many would argue that adding the enums and extending the factory method only, still remain within the boundaries of the open-closed principle. If you want to comply on all levels, you will have to use reflection, possibly compromising on performance.
Далее
Saga Pattern: Mastering Distributed Transactions
7:23
Просмотров 1,5 тыс.
БЫДЛО НА ПУНКТАХ ВАЙЛДБЕРРИЗ
13:26
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
10 Design Patterns Explained in 10 Minutes
11:04
Просмотров 2,2 млн
Design Patterns: Factories
25:26
Просмотров 54 тыс.
ИГРОВОВЫЙ НОУТ ASUS ЗА 57 тысяч
25:33
Сравнили apple и xiaomi!
0:21
Просмотров 33 тыс.
Сложная распаковка iPhone 15
1:01
Просмотров 14 тыс.