Back to list
Views:   15.9K
Replies:  1

What is the difference between Abstract Factory Pattern And Builder Pattern


   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.


 Best Regards.

Volkan Genç, Feb 01, 2012
Reply 1
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.

Ankit Parikh
Ankit Parikh, Feb 02, 2012
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.