The Coffee Machine

Java & Eclipse tips blog

  • Categories

  • Archives

  •  

    August 2008
    M T W T F S S
        Sep »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031

Archive for August 25th, 2008

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 »