Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bridge pattern doubt

 
Madhu Juneja
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the bridge structural pattern, the Bridge interface maintains a reference of the Implementor (page 154 GOF)
For example :
interface Window
{
Operation() // this returns an Implementor object
}
class Implementor implements Window
{}
My doubt is if you compile Window.java it expects Implementor class and if you compile Implementor.java it expects a Window class. How does one solve this problem ? Is there anything in Java like in C++ called forward referencing. That is one can just declare a class prior to the Window defining as :
class Implementor;
Or am I missing something ?
 
Avijeet Dash
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked the book and my understanding is
you need a Window abstract class and windowImpl classes.
Window class has composed impl classes.
I didn't see and need for 2 way dependencis.
but your question still stands valid, i think the forward reference thing is not possible in java.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic