Tag : c

A Factory Design Pattern Example

What is a Factory Design Pattern ?

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.

How we will do it ?

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.

Let me do it…

We will consider creating documents in this example.

As a first step let us create an interface and call it as iDocument

We will create classes for separate documents and inherit them from iDocument

Categories: Design Pattern

%d bloggers like this: