This discussion is archived
1 2 Previous Next 21 Replies Latest reply: Jul 25, 2011 1:55 AM by EJP RSS

question about bridge pattern

fxbird Newbie
Currently Being Moderated
its definition is "decouple an abstraction from its implementation so that the two can vary independently". I don't understand what "abstraction and the implementation vary independently" really mean and how .

Before another question pls see the below class diagram of bridge pattern:
http://images.cnblogs.com/cnblogs_com/zhenyulu/Pic91.gif

My question is whether not using abstraction and just keeping implementation hierarchy can do the same thing? Interface and its implementation itself(polymorphism) can make extending easily and be well subject to open-closed principle,can't they?

Sorry for my bad English.

Edited by: fxbird on 2011-7-17 上午5:13
  • 1. Re: question about bridge pattern
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    It is just another level of abstraction.
    My question is whether not using abstraction and just keeping implementation hierarchy can do the same thing?
    Err...no. By definition, that is exactly what the bridge pattern definition says is not the case.

    However for most cases you do not need to use a bridge so simple abstraction is sufficient.
  • 2. Re: question about bridge pattern
    EJP Guru
    Currently Being Moderated
    I've used it exactly once, in 1997, and I've regretted it ever since.
  • 3. Re: question about bridge pattern
    fxbird Newbie
    Currently Being Moderated
    thank your reply.

    So why bridge also use Abstraction hierarchy? What's the intent behind?
  • 4. Re: question about bridge pattern
    fxbird Newbie
    Currently Being Moderated
    I think it's very common in j2ee development. Since in 3 or above layer architecture , for the bussiness layer, you need to define a bo interface and bo implementation, equal to abstraction hierarchy, for the persistence layer, you need to define dao interface and its implementation, equal to implementator hierarchy. BO layer manipulate the proper dao and keep some reference of dao in order to complete a data persistence function. And client only communicate with bo ,not concrete dao. Isn't it?

    Edited by: fxbird on 2011-7-18 下午7:15

    Edited by: fxbird on 2011-7-18 下午7:15
  • 5. Re: question about bridge pattern
    EJP Guru
    Currently Being Moderated
    So why bridge also use Abstraction hierarchy?
    The side of the bridge that the user sees is an abstraction in the conceptual sense, in that it doesn't really exist. It doesn't have to use 'abstract' in the Java sense. It certainly didn't the way I did it ;-(
  • 6. Re: question about bridge pattern
    fxbird Newbie
    Currently Being Moderated
    EJP wrote:
    So why bridge also use Abstraction hierarchy?
    The side of the bridge that the user sees is an abstraction in the conceptual sense, in that it doesn't really exist. It doesn't have to use 'abstract' in the Java sense. It certainly didn't the way I did it ;-(
    R u saying it uses abstractiong hierarchy in other language sense? say C++.
  • 7. Re: question about bridge pattern
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    fxbird wrote:
    I think it's very common in j2ee development.
    Certainly isn't if someone is using a container.

    If someone is creating a container then I would suspect that such a pattern might be useful.
    However if someone is creating a container then there are going to be a lot of useful patterns. And lot of classes as well.
    And in total of the entire scope of creating a container the bridge would be a very small part.

    So it certainly isn't going to be "common".
  • 8. Re: question about bridge pattern
    EJP Guru
    Currently Being Moderated
    R u saying it uses abstractiong hierarchy in other language sense? say C++.
    A tip for future reference. Whenever I see a question that starts 'so are you saying' I have found that the answer is invariably 'no'. So when you find yourself about to ask such a question, think again.

    In this case it is 'no' because your question is meaningless. 'Abstraction in the C++ sense' is identical to 'abstraction in the Java sense'.

    Possibly I should have said 'abstraction in the OO sense'.

    Or possibly you shouldn't ask meaningless questions.
  • 9. Re: question about bridge pattern
    796440 Guru
    Currently Being Moderated
    EJP wrote:
    R u saying it uses abstractiong hierarchy in other language sense? say C++.
    A tip for future reference. Whenever I see a question that starts 'so are you saying' I have found that the answer is invariably 'no'.
    When I see a question on a forum that starts "R u" instead of "Are you", I almost invariably ignore it, as I can't abide retarded SMS-speak, especially when someone has a full keyboard to work with.
  • 10. Re: question about bridge pattern
    EJP Guru
    Currently Being Moderated
    So r u saying that I should have ignored it? :-|
  • 11. Re: question about bridge pattern
    796440 Guru
    Currently Being Moderated
    : - )
  • 12. Re: question about bridge pattern
    fxbird Newbie
    Currently Being Moderated
    jschell wrote:
    fxbird wrote:
    I think it's very common in j2ee development.
    Certainly isn't if someone is using a container.

    If someone is creating a container then I would suspect that such a pattern might be useful.
    However if someone is creating a container then there are going to be a lot of useful patterns. And lot of classes as well.
    And in total of the entire scope of creating a container the bridge would be a very small part.

    So it certainly isn't going to be "common".
    Hello jschell , what do you mean by 'container'? In my previous reply, the architecture I mentioned is ss(spring+struts2.x),the pattern I mentioned is a standard way. Actual I've not been understood why it's used this way---define business interface, from my perspective, it doesn't have to define it, simply writing a business class and calling dao method is enough. I assume bo interface thing is a bridge pattern.
  • 13. Re: question about bridge pattern
    fxbird Newbie
    Currently Being Moderated
    EJP wrote:
    R u saying it uses abstractiong hierarchy in other language sense? say C++.
    A tip for future reference. Whenever I see a question that starts 'so are you saying' I have found that the answer is invariably 'no'. So when you find yourself about to ask such a question, think again.

    In this case it is 'no' because your question is meaningless. 'Abstraction in the C++ sense' is identical to 'abstraction in the Java sense'.

    Possibly I should have said 'abstraction in the OO sense'.

    Or possibly you shouldn't ask meaningless questions.
    If 'R u ...' is a implite manner ,I would like apoligize , cause I'm not from a English-speaking country, though I've been studied English, sometime I still can't express what I really want to say as exactly. If that's not the reason, I want to say, I'm here to ask for helps, I'm not gonna ask meaningless questions, I do not want to waste time of anybody. So I can't agree with you about what you said. How do you think that's a meaningless question? Your reply was so short that I just can't understand . Maybe you could give me some advices about how to ask meaningful question kindly.
  • 14. Re: question about bridge pattern
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    fxbird wrote:
    jschell wrote:
    fxbird wrote:
    I think it's very common in j2ee development.
    Certainly isn't if someone is using a container.

    If someone is creating a container then I would suspect that such a pattern might be useful.
    However if someone is creating a container then there are going to be a lot of useful patterns. And lot of classes as well.
    And in total of the entire scope of creating a container the bridge would be a very small part.

    So it certainly isn't going to be "common".
    Hello jschell , what do you mean by 'container'?
    You phrased your comment about J2EE. A common idiom is to refer to a J2EE (actually newer name is JEE) server as a JEE container. Not sure why specifically that word is used but maybe because such servers are said to 'contain' applications.
    In my previous reply, the architecture I mentioned is ss(spring+struts2.x),the pattern I mentioned is a standard way.
    You either do not understand what I said or you do not understand what happens in those implementations.

    If I have 100,000 classes and 3 of them are implementing the bridge pattern then it is not "common".
    If I have 100,000 classes and 3,000 of them implement many bridge patterns (and not generated) then one could say it is "common".

    And having done some JEE applications I seriously doubt there is an implicit need to use the bridge pattern.
    The bridge pattern is intended to deal with a complex situation. Since there are more simple JEE applications than complex ones then it seems unlikely that there is a "common" need for it in JEE applications.
    Actual I've not been understood why it's used this way---define business interface, from my perspective, it doesn't have to define it, simply writing a business class and calling dao method is enough. I assume bo interface thing is a bridge pattern.
    I don't know why they would use the bridge pattern nor even if they really do. I wouldn't be surprised that it is used and I can also suppose that the use would be a good idea. Although it is quite possible as well that it is used incorrectly in some places.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points