Builder Pattern - Applicability & Examples
by, 03-09-2012 at 08:15 PM (1034 Views)
Builder pattern could be used when:
- Creation algorithms of complexed objects are not dependent upon parts that compose the objects.
- System allows the representation of many different objects.
Consider an example of vehicle manufacture that creates bicycle, a car, a scooter and a motorcycle. In such case, builder would be the Vehicle Builder. Interface is being specified to build any kind of vehicle in the above list by using similar parts and different rules for all types of vehicle. The ConcreteBuilder would be those builders that are linked to under constructed objects. Of course, vehicle is the product which is constructed & director is its manufacturer & also the shop.
If an application is under use of University students which provides them their exam’s grade list then there exists a strong need to run that application differently depending at the users who log in. It simply means that admin requires certain enabled buttons which are needed to be disabled by students who are its common users. Interface is provided by the Builder to build form, depending at the login information. ConcreteBuilders in this case would be considered as the specific forms, for each user type. Final form would be the application that will be used by the application & director would be the application which requires a specific form depending upon the login information.