Wednesday 14 March 2007

Abstract Factory (Blog 4)

The next blog on which we were asked to understand and do research is Abstract factory. I have looked in to many websites, tried to get as much knowledge as I can and now I am going to write what I understood about Abstract factory..!
The Factory Pattern known as Abstract Factory is used to facilitate class instantiation. In the Abstract Factory pattern, a special class, called a factory, is created whose main aim is to create instances of a class.
The factory method pattern is like defining an agreement for the creation of a given type of classes
  • An abstract factory is an object creator.
  • It can produce different types of objects.
  • Each object that it produces is recognized by receiver of the object which is created only by the interface of that object, not by the object's real implementation.
  • Objects which are produced by abstract factory are related to each other or you can say they belong to a common family

Benefits

Abstract factory eliminates the need of classes to bind in to the code. The code deals with the interfaces, therefore it is possible that I can work with any class that implements an interface.
It also allows the subclasses to give an extended edition of an object because it is hard to create an object within the class but It is more easy to create an object in the client directly

6 comments:

Bash said...
This comment has been removed by the author.
Hani said...

Thanks for appreciating!!

Abbas said...

One thing you missed out hani is Concrete class;

Abstract factory creates interfaces for differnt objects that are related to eachother or depend on eachother, such that there is no specific concrete class. In simple words, it encapsulates a group of individual factories having same essence.

Hani said...

oh yes abbas! actually i did write about it but not in much detail in the BENEFITS sections.But thanks anyway for pointing it out . :) ..

stephen said...

Your explanation on the abstract factory is a bit shallow. You failed to comment on the concrete class component

stephen said...

Hi, i couldn't congratulate you the more on the blog about critiquing the Abstract Factory. I have aquired few bits from your blog. I happened to have done the same pattern. See if you can learn frome mine as well.