Home  /  Questions  /  Question



88   96.5
Feb 01, 2012


What is the difference between Abstract Factory Pattern And Builder Pattern

 
 Hİ,

   I think that you discussed this quesiton before. But I couldnot find is there topic like this question on here

      I wrote a car factory with abstract factory pattern. I have 2  factory  ( MercedesFactory,HondaFactory) and i have 4 concrete class (MercedesFamilyCar,MercedesSportCar,HondaFamilyCar,HondaSportCar ) .I have a abstract classess  Family and Sport which includes
 below methods.    
        public abstract void Speed();
        public abstract void Wheel();
        public abstract void Door();
        public abstract void Price();
        public abstract void Display();

So my question is i can do this with builder pattern. Assume that its name is CarBuilder instead of CarFactory. What is the main difference between  Builder and Abstract Factory Pattern.

 Thanks.

 Best Regards.




50   50
Feb 02, 2012
Hi,
The main difference between Abstract and Builder pattern is Abstract will return the instance directly while in Builder there will be one Director class which will instruct Builder class to build the different parts/properties of your object and finally retrieve the object.

Also, Abstract does not keep the track of it's created object while Builder will have reference to the created object.

Regards,
Ankit Parikh