Thread: Polymorphism - Can't Articulate Problem

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Quote Originally Posted by Daved
    I like that option the best. You might actually want to make do_draw private instead of protected. There shouldn't be any do_draw-ing happening outside of the draw() function.
    Right. Too much Java on my part. I forgot that it can still be overridden if private.
    Although you could perhaps make a case that private functions are an implementation detail of the class itself that subclasses shouldn't know about - how then can they know to override it?

    Quote Originally Posted by Mario F.
    Could you elaborate on that CornedBee?
    Sure. I looked it up at Wikipedia and the article is just confusing me. It starts in the introduction:
    The bridge pattern is useful when not only the class itself varies often but also what the class does.
    I think what the author meant is "when not only what the class does changes often but also how it does it." Although this should be the other way round: if what the class does changes often, then its interface is incomplete and thus flawed. Whereas changes in how it does it are the whole point of polymorphism.

    The article then goes on to first describe interaction of shapes and drawing systems, and then cars and roads. In both cases, the impression I get is that here are two distinctly separate hierarchies (in the first case a hierarchy of shapes and a hierarchy of drawing engines, and in the second case a hierarchy of cars and a hierarchy of roads) that interact through their well-defined interfaces like the very basics of object-oriented design dictate. Yet the article makes the claim that there is a special pattern here because of the road somehow being an implementation detail of the car, or the GFX one of the shape, and that separating these into two hierarchies is a pattern.

    That's nonsense IMO. It's just separation of concerns. It may be a pattern, but it's such a fundamental part of OOD that giving it yet another name is pointless, as I see it.
    Last edited by CornedBee; 11-13-2006 at 04:50 PM.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    Registered User
    Join Date
    Jan 2005
    >> That's nonsense IMO.
    Most design patterns are actually really simple and fundamental parts of OOD or other types of programming design. Giving it a name makes it easier to discuss and refer to, assuming both sides of the conversation understand what the patterns are.

    In this case, I don't see how the Bridge Pattern applies at all, but there's nothing wrong with it having a name.

  3. #18
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Right. I was under the impression it could be applied since it transfers the implementation concerns to another hierarchy. But a second look at it shows it is designed to address another issue.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Polymorphism Problem
    By ltanusaputra in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2007, 11:36 AM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM