wood burning stoves*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Builder and Bridge Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Builder and Bridge Pattern" Watch "Builder and Bridge Pattern" New topic
Author

Builder and Bridge Pattern

Shankar sanjay
Ranch Hand

Joined: Sep 14, 2009
Posts: 117
Hi all,

I am preparing for SCEA, i am unable to find the difference between Builder and Bridge pattern (other then creational and structural) since both of them doing the same.

1. Keep common functionality in abstract class.
2. Vary Implementations(functionality) keep it in sub classes, that means this method would declare as abstract in abstract class (previous step (1))

Can any please explain?

Regards,

Sankar. s

Sunderam Goplalan
Ranch Hand

Joined: Oct 10, 2011
Posts: 75
Builder and Bridge patterns solve a different purpose. Builder pattern is used when the construction of an Object is more complex than just saying new ....(). Imagine that a house needs to be constructed based on various designs, choices and amenities selected by the customer. In this case, typically you will use Builder pattern to "CONSTRUCT" the house PER CUSTOMER based on various choices selected by her. Hence, the creation of the House object or end product is complex based on external factors.

On the other hand, Bridge pattern is used vary the abstraction and implementation seamlessly. Suppose there is a car demo for, say, Sports car and economy car. You would like to seamlessly switch between the two so that Client code is not affected. You can go through examples from the Web.




SCJP 5.0 , SCEA Java EE 5, TOGAF Certified
 
wood burning stoves
 
subject: Builder and Bridge Pattern