Results 1 to 3 of 3
  1. #1
    jomypgeorge is offline Member
    Join Date
    May 2010
    Posts
    90
    Rep Power
    0

    Default strategy pattern and bridge pattern

    i am confused with two design patterns, strategy pattern and bridge pattern.
    i have read that strategy comes under behavioral where bridge comes under structural patterns.

    But in both we have an interface , more than one class implement it and define methods in their own way.
    In strategy pattern we have a context class which holds a reference of interface. On invoking context method, context call corresponding method in using this reference.

    In bridge pattern context is an abstract class. each subclass of context holds a reference of its implementer. and invoke the method using that reference.

    Only difference i found is in bridge context is abstract and many concrete context classes exists there. but in strategy only one context class, and client set its implementer.

    i am sure there is some big difference between them as they are existing as two design patterns

    can anyone let me know what is that?
    thanks in advance......

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    There's a thread at stackoverflow.com that looks at the difference in terms of structure (bridge) vs behaviour (strategy).

  3. #3
    jomypgeorge is offline Member
    Join Date
    May 2010
    Posts
    90
    Rep Power
    0

    Default

    so if the implementation is selected in user class itself it is bridge pattern.
    and if client has the facility to choose one implementer, then it is strategy.
    so in strategy pattern implementer is chosen dynamically.
    in bridge pattern it is chosen at compile time itself.

    am i right?

    waiting for more suggestions......

Similar Threads

  1. Class pattern to generate following pattern:-
    By vxs in forum New To Java
    Replies: 5
    Last Post: 07-15-2010, 12:15 AM
  2. Replies: 2
    Last Post: 03-24-2009, 06:02 PM
  3. Strategy Pattern
    By mew in forum New To Java
    Replies: 0
    Last Post: 01-25-2008, 08:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •