Tag : c
Tag : c
This is a creational design pattern. It encapsulate the object creation logic from the user by creating a logical separation between the object creation and use.
We will gather and create a family of classes having almost similar features. Then we will create a factory class to create and return the desired objects.
We will consider creating documents in this example.
As a first step let us create an interface and call it as iDocument
1 2 3 4 5 6 7 8 9 10 11 |
namespace DocumentFactory { public interface iDocument { string CreateDocument(string documentName, string path); string ReadDocument(string documentName, string path); bool Saved(); } } |
We will create classes for separate documents and inherit them from iDocument
Categories: Design Pattern