Exforsys
+ Reply to Thread
Results 1 to 4 of 4

Design Patterns - Maze Examples

This is a discussion on Design Patterns - Maze Examples within the Software Patterns forums, part of the Testing category; Hi, I just started reading design patterns (by Gamma, Helm, Johnson, Vlissides ) and looking at the Lexi example. I'm ...

  1. #1
    yb Guest

    Design Patterns - Maze Examples

    Hi,

    I just started reading design patterns (by Gamma, Helm, Johnson,
    Vlissides ) and looking at the Lexi example. I'm very new to this so
    please bear with me.

    I understand the Decorator pattern, but a bit confused by the Maze
    example used for creational patterns. Is this example a bit contrived?
    I would have thought a decorator pattern would make more sense instead
    of deriving mazes with different attributes.

    Anyway, just seemed to me the example is not good practice but just
    made to illustrate the point on how to apply creational patterns??
    hope my question makes sense.




  2. #2
    iscy Guest

    Re: Design Patterns - Maze Examples

    The example using the Maze is good. May be, it's not the best, but it
    makes a lot of sense. However, I don't really see what you mean by the
    Maze and the decorator, because they are not used togheter.

    If you get troubles with the decorator, try to get information from the
    pattern called "Wrapper". It's the same thing. If you want to get a
    good example but a bit different, there is the wrapper facade in POSA1,
    but it's quite different from the decorator itself

    iscy




  3. #3
    Simon Smith Guest

    Re: Design Patterns - Maze Examples


    >
    >Hi,
    >
    >I just started reading design patterns (by Gamma, Helm, Johnson,
    >Vlissides ) and looking at the Lexi example. I'm very new to this so
    >please bear with me.
    >
    >I understand the Decorator pattern, but a bit confused by the Maze
    >example used for creational patterns. Is this example a bit contrived?
    > I would have thought a decorator pattern would make more sense instead
    >of deriving mazes with different attributes.
    >
    >Anyway, just seemed to me the example is not good practice but just
    >made to illustrate the point on how to apply creational patterns??
    >hope my question makes sense.
    >


    Contrived? Maybe....too many of the examples have GUI uses for my money,
    but a bit of thought can find other uses.
    For Decorator, think of a file you have to send to possibly many places
    via many methods. The basis method is to move file from place A to file
    path B. You may also need to email it to someone: make an EmailDecorator.
    If you need to FTP it anywhere, add an FtpDecorator.
    And so on.


    Simon
    Simon dot s at ghytred dot com





  4. #4
    iscy Guest

    Re: Design Patterns - Maze Examples

    > For Decorator, think of a file you have to send to possibly many places
    > via many methods. The basis method is to move file from place A to file
    > path B. You may also need to email it to someone: make an EmailDecorator.
    > If you need to FTP it anywhere, add an FtpDecorator.
    > And so on.


    This example is closer to a strategy than to a decorator. Don't forget
    something. The decorator is a strutural pattern, not a behavioral
    pattern as your example describes.

    In other words, the decorator allows you to add responsabilities to an
    object dynamically. There is a base class that your object will know
    that will be called the 'decorator' itself. That will let you inherit
    this base class to create child classes having different
    responsabilities. The main difference with the strategy, is that you
    can attach more than one decorator to an object. That means, you are
    using multiple decorators at the same time. In other words, your
    dispatching the responsabilites of something through several objects.
    The is the job of the object that is using the base class to iterator
    through all of them and notify them.




    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...