Monday 2 April 2007

Lecture 06.03.07 - Definition of Abstract Factory

Definition of Abstract Factory Pattern

A software design pattern, the Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme. In normal usage, the client software would create a concrete implementation of the abstract factory and then use the generic interfaces to create the concrete objects that are part of the theme. The client does not know (nor care) about which concrete objects it gets from each of these internal factories since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from its general usage.[1]

OR

In short it is defined as, providing an interface for creating families of related or dpendent objects without specifying their concrete classes. [2]


Below, I am going to illustrate an example which was used by my lecturer:-

In the STUDENT class, there is data and methods. The data is student names which comprises methods such as enrolment, add, create, edit, delete and print.
Its the same with the class named COURSE, there is data and methods. The data will be types of courses available and the methods will be registration, add, create , edit, delete and print.

Now, abstract class will create a common interface which will perform all the functions such as add, create, edit, delete and print in new abstract class named may be FUNCTION class. This proves that the concrete class is isolated and its easy as the concrete class produces different product family configuration.

---------------------------------------------------------------------------------------------------
Reference Link

[1] http://en.wikipedia.org/wiki/Abstract_factory

[2] http://www.c-sharpcorner.com/uploadfile/mosessaur/abstractfactoryadonet202152006053643am/abstractfactoryadonet2.aspx?articleid=4468e7cc-57cl-4738-8e83-a8db48fd1d9f



3 comments:

John Ssebaale said...

Thanks for the blog. In your view how what do you think about the Abstract Factory. I found that it hold such an important principle which is the basis of every Object Oriented language.
It seems such a powerful pattern
Cheers

Daljit @ Dil said...

It's very true that Abstract Factory plays important part because of the principle it holds.

Rizwan Khan said...

I find Abstract factory quiet interesting and I also realised that I could 've applied this pattern in my project design if I knew about it 2 months ago.
Anyhow, I don't know if you've noticed, Abstract factory and factory method patterns are quiet similar. The only difference I found between them is that factory method is called from inside the class hierarchy, whereas the abstract factory is called from outside. Intersting isn't it?
Regards