The Coffee Machine

Java & Eclipse tips blog

  • Categories

  • Archives

  •  

    December 2009
    M T W T F S S
    « Sep    
     123456
    78910111213
    14151617181920
    21222324252627
    28293031  

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 »