![]() ![]() ![]() There is no relation between a car and a bike, but both the builders may use the same vendors to procure parts like nuts and bolts and hence may extend the same abstract class VehicleBuilder.Įxample 2: Let’s say your school/work canteen has a MealBuilder. There is also a BikeBuilder, which builds a bike using gear box, chains, etc (don’t really know the parts). Both of these are pizzas, but they will look and taste very different.Įxample 1: There is a CarBuilder, which builds a car by building its transmission system, engine, wheels, etc. Now, the ChicagoPizzaFactory will serve you deep dish pizza, whereas NaplesPizzaFactory will give you Neapolitan pizza - both with the same toppings. The AbstractPizzaFactory will allow you to choose toppings like pepperoni and margherita. Let’s assume that there is an AbstractPizzaFactory with its subclasses in Chicago and Naples (yum). Builders may also be abstract and its subclasses may have common logic to build a certain subpart. Builder, on the other hand, is concerned with building a single type of object. Abstract factory is used for creating a family of objects, which share a common interface. Abstract factory and Builder, both help in creating objects and are as such part of the creational design patterns. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |