Factory Method Design Pattern [An Introduction for .NET Developers (using C#)]

preview_player
Показать описание
In this video, I am going to walk through the implementation of Factory Method Design Pattern [An Introduction for .NET Developers (using C#)].

I am going to go through a couple of ways we can implement the Factory Method design pattern.

00:05 - Definition of the Factory Method Design pattern
00:32 - Scenario where Factory method design pattern can be used
01:35 - Controller for supporting
01:50 - A non-elegant way of implementing the requirement of the Factory method, without using Factory method design pattern
03:00 - A standard factory class implementation of the Factory method design pattern
05:45 - Trying out the implementation using Swagger
06:40 - Explaining unit testing with Factory method implementation
07:06 - Implementation of the Factory Method Design pattern using a Func delegate
09:08 - Trying out the delegate implementation using Swagger
09:30 - Debugging through the implementation

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

The way you implemented is very similar to strategy pattern, practically is the same. Can you please clarify me the difference? because here you selected a particular behavior on runtime based on the type, that's the definition for strategy pattern instead of factory pattern.
Thanks in advance

zeusmortegh
Автор

Awesome! thanks for this video, if you try to register like scoped or Transient there are this error: "Cannot implicitly convert type string to system.IServiceProvider"

bgva
Автор

Awesome! it just answered the question in my brain!

williamliu
Автор

Please make a video on Abstract factory design pattern

dilipgautam
Автор

Nice video, in my opinion lambda looks disgusting in line rather in a it's on class hahah, I know it was just a demo! :P

nicklaspillay
Автор

Is this is factory design pattern? The name in the heading is factory method design pattern. Can you say difference between factory and factory method design pattern or can you please make video of factory method in .net core

noufalp
Автор

Appreciate your efforts but this is not Factory method design pattern, rather this implementation is of a Simple Factory Design pattern.
Factory method design pattern states that "It provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created."
In the video, we are just returning instances of the subclasses based upon the type - this is simple factory design pattern implementation.

anurag
Автор

Maybe for some one this can be useful: In first aproach minute 2.50, into Startup.ConfigureServices sadd: services.AddSingleton<ILawnmowerCatalog, DieselLawnMowerCatalog>(); services.AddSingleton<ILawnmowerCatalog, ElectricLawnMowerCatalog>(); services.AddSingleton<ILawnmowerCatalog, ManualLawnMowerCatalog>(); . And inside LawnMowerCatalogController create a constructor with this sign: lawnmowerCatalog then you can test this aproach.

bgva