Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Builder and Bridge Pattern

 
Shankar sanjay
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic