The Coffee Machine

Java & Eclipse tips blog

  • Categories

  • Archives

  •  

    November 2009
    M T W T F S S
    « Sep    
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  

Archive for the ‘Design Patterns’ Category

The Visitor Pattern

Posted by ObLiB on August 25, 2008

Design PatternsFor my work I needed to browse a “tree” to retrieve some data and make operations with it. To manage this, I made some research and I found a design pattern that I didn’t know yet: The Visitor Pattern.

To spread a hierarchy of classes, normally you simply add methods which provide desired behavior. It can happen however that this behavior is not consistent with the logic of the existent object model. It is also possible that you do not have access to existent code. In such situations, it can be impossible to spread the behavior of hierarchy without changing his classes. The Visitor Pattern precisely allows the developer of a hierarchy to insert a support for cases where other developers would like to spread his behavior.

Read the rest of this entry »

Posted in Design Patterns | Tagged: | Leave a Comment »