简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM