Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Factory Design Pattern

In C#... factory design pattern, why all "factory class" should be inherited from "abstract factory class" ??

Without inheriting also we can achieve same functionality. Cant we?

like image 908
Zodiac Avatar asked Aug 21 '26 07:08

Zodiac


1 Answers

Factories that inherit from an abstract factory class are doing so to follow the abstract factory pattern. The abstract factory pattern is useful when you want to create a strategy out of whole groups of object types. For this reason it is also called the "kit" pattern.

Often, factories are perfectly viable without an abstraction. If you don't need one now, leave it alone. You can always make an abstract factory later, if it is needed.

Some more reading:

http://en.wikipedia.org/wiki/Abstract_factory_pattern

like image 175
tallseth Avatar answered Aug 22 '26 20:08

tallseth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!