SlideShare a Scribd company logo
1 of 53
Download to read offline
Visitor
                  Steve Hayes
                Cogent Consulting




 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
The Problem



 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Show me everything in a consistent manner...




             Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
            Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Show me everything in a consistent manner...

      ... and send it to my friend via email




             Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
            Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Show me everything in a consistent manner...

      ... and send it to my friend via email

   oh, and send it to her phone as well...




             Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
            Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Show me everything in a consistent manner...

      ... and send it to my friend via email

   oh, and send it to her phone as well...

                                                                 and print it.....




             Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
            Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Some analysis music please...




              Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
             Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Commonality is in the eye of the beholder




         Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
        Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
With a little casual application of
        polymorphism...




     Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
    Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Does this look bad to you?




             Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
            Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
The solution



 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Visitors



    Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
   Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
ā€œRepresent an operation to be performed
 on the elements of an object structure.
 Visitor lets you deļ¬ne a new operation
   without changing the classes of the
     elements on which it operatesā€

                                 -- GOF


         Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
        Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
A solution to a problem in a context




      Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
     Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Headings, Details, ...




 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
and the Iterator




 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Letā€™s show it in code!




 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Time for visitors...




          Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
         Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Melbourne Pushes Boundaries

The Wolves in the Wall

Redhill Consulting Pty Ltd - Ruby on Rails Plugins

Let's talk about tests, baby...




            Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
           Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Melbourne Pushes Boundaries
Tim Colebatch
Melbourne is experiencing its biggest growth surge
since the 1960's

The Wolves in the Wall
12.06

Redhill Consulting Pty Ltd - Ruby on Rails Plugins
Here are some Ruby on Rails plugins we've developed...

Let's talk about tests, baby...
Some long babbling about test naming heuristics
           Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
          Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Cool!



   Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
  Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
When?



 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
ā€œan object structure contains many classes
  of objects with differing interfaces, and
you want to perform operations on these
  objects that depend on their concrete
                  classesā€



          Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
         Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
ā€œmany distinct and unrelated operations
  need to be performed on objects in an
 object structure, and you want to avoid
    ā€˜pollutingā€™ their classes with these
operations.Visitor lets you keep unrelated
 operations together by deļ¬ning them in
  one class. When the object structure is
shared by many applications, use Visitor to
 put operations in just those applications
              that need themā€
         Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
        Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Show me everything in a consistent manner...

      ... and send it to my friend via email

   oh, and send it to her phone as well...

                                                                 and print it.....




             Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
            Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
ā€œthe classes deļ¬ning the object structure
    rarely change, but you often want to
deļ¬ne new operations over the structure.
   Changing the object structure classes
   requires redeļ¬ning the interface to all
  visitors, which is potentially costly. If the
object structure classes change often, then
       itā€™s probably better to deļ¬ne the
           operations in those classesā€

          Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
         Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Consequences



 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Visitor makes adding new operations easy




         Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
        Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
A visitor gathers related operations and
        separates unrelated ones




        Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
       Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Adding new ConcreteElement classes is
               hard




       Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
      Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Visitors can cross object hierarchies




      Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
     Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Visitors can accumulate state




   Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
  Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Visitors may compromise encapsulation




       Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
      Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
Discussion



 Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au)
Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.

More Related Content

More from melbournepatterns

Code Contracts API In .Net
Code Contracts API In .NetCode Contracts API In .Net
Code Contracts API In .Net
melbournepatterns
Ā 
Abstract Factory Design Pattern
Abstract Factory Design PatternAbstract Factory Design Pattern
Abstract Factory Design Pattern
melbournepatterns
Ā 
Extract Composite Talk Andy
Extract Composite Talk AndyExtract Composite Talk Andy
Extract Composite Talk Andy
melbournepatterns
Ā 
Move Accumulation To Collecting Parameter
Move Accumulation To Collecting ParameterMove Accumulation To Collecting Parameter
Move Accumulation To Collecting Parameter
melbournepatterns
Ā 
Mpg Dec07 Gian Lorenzetto
Mpg Dec07 Gian Lorenzetto Mpg Dec07 Gian Lorenzetto
Mpg Dec07 Gian Lorenzetto
melbournepatterns
Ā 
Mpg Feb08 Gian Lorenzetto
Mpg Feb08 Gian Lorenzetto Mpg Feb08 Gian Lorenzetto
Mpg Feb08 Gian Lorenzetto
melbournepatterns
Ā 
Command Pattern Geoff Burns 2006 Nov
Command Pattern Geoff Burns 2006 NovCommand Pattern Geoff Burns 2006 Nov
Command Pattern Geoff Burns 2006 Nov
melbournepatterns
Ā 

More from melbournepatterns (20)

Code Contracts API In .Net
Code Contracts API In .NetCode Contracts API In .Net
Code Contracts API In .Net
Ā 
LINQ/PLINQ
LINQ/PLINQLINQ/PLINQ
LINQ/PLINQ
Ā 
Gpu Cuda
Gpu CudaGpu Cuda
Gpu Cuda
Ā 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
Ā 
Phani Kumar - Decorator Pattern
Phani Kumar - Decorator PatternPhani Kumar - Decorator Pattern
Phani Kumar - Decorator Pattern
Ā 
Composite Pattern
Composite PatternComposite Pattern
Composite Pattern
Ā 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
Ā 
Prototype Design Pattern
Prototype Design PatternPrototype Design Pattern
Prototype Design Pattern
Ā 
Factory Method Design Pattern
Factory Method Design PatternFactory Method Design Pattern
Factory Method Design Pattern
Ā 
Abstract Factory Design Pattern
Abstract Factory Design PatternAbstract Factory Design Pattern
Abstract Factory Design Pattern
Ā 
A Little Lisp
A Little LispA Little Lisp
A Little Lisp
Ā 
State Pattern in Flex
State Pattern in FlexState Pattern in Flex
State Pattern in Flex
Ā 
Active Object
Active ObjectActive Object
Active Object
Ā 
Extract Composite Talk Andy
Extract Composite Talk AndyExtract Composite Talk Andy
Extract Composite Talk Andy
Ā 
Selenium Interpreter
Selenium InterpreterSelenium Interpreter
Selenium Interpreter
Ā 
Move Accumulation To Collecting Parameter
Move Accumulation To Collecting ParameterMove Accumulation To Collecting Parameter
Move Accumulation To Collecting Parameter
Ā 
Mpg Dec07 Gian Lorenzetto
Mpg Dec07 Gian Lorenzetto Mpg Dec07 Gian Lorenzetto
Mpg Dec07 Gian Lorenzetto
Ā 
Mpg Feb08 Gian Lorenzetto
Mpg Feb08 Gian Lorenzetto Mpg Feb08 Gian Lorenzetto
Mpg Feb08 Gian Lorenzetto
Ā 
Dynamic Vs Static
Dynamic Vs StaticDynamic Vs Static
Dynamic Vs Static
Ā 
Command Pattern Geoff Burns 2006 Nov
Command Pattern Geoff Burns 2006 NovCommand Pattern Geoff Burns 2006 Nov
Command Pattern Geoff Burns 2006 Nov
Ā 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
Ā 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
Ā 

Recently uploaded (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Ā 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
Ā 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Ā 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Ā 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
Ā 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
Ā 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
Ā 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Ā 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Ā 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
Ā 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Ā 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Ā 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Ā 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Ā 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
Ā 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Ā 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
Ā 

Visitor Pattern By Steve Hayes

  • 1. Visitor Steve Hayes Cogent Consulting Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 2. The Problem Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 3. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 4. Show me everything in a consistent manner... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 5. Show me everything in a consistent manner... ... and send it to my friend via email Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 6. Show me everything in a consistent manner... ... and send it to my friend via email oh, and send it to her phone as well... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 7. Show me everything in a consistent manner... ... and send it to my friend via email oh, and send it to her phone as well... and print it..... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 8. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 9. Some analysis music please... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 10. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 11. Commonality is in the eye of the beholder Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 12. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 13. With a little casual application of polymorphism... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 14. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 15. Does this look bad to you? Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 16. The solution Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 17. Visitors Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 18. ā€œRepresent an operation to be performed on the elements of an object structure. Visitor lets you deļ¬ne a new operation without changing the classes of the elements on which it operatesā€ -- GOF Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 19. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 20. A solution to a problem in a context Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 21. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 22. Headings, Details, ... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 23. and the Iterator Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 24. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 25. Letā€™s show it in code! Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 26. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 27. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 28. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 29. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 30. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 31. Time for visitors... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 32. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 33. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 34. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 35. Melbourne Pushes Boundaries The Wolves in the Wall Redhill Consulting Pty Ltd - Ruby on Rails Plugins Let's talk about tests, baby... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 36. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 37. Melbourne Pushes Boundaries Tim Colebatch Melbourne is experiencing its biggest growth surge since the 1960's The Wolves in the Wall 12.06 Redhill Consulting Pty Ltd - Ruby on Rails Plugins Here are some Ruby on Rails plugins we've developed... Let's talk about tests, baby... Some long babbling about test naming heuristics Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 38. Cool! Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 39. When? Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 40. ā€œan object structure contains many classes of objects with differing interfaces, and you want to perform operations on these objects that depend on their concrete classesā€ Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 41. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 42. ā€œmany distinct and unrelated operations need to be performed on objects in an object structure, and you want to avoid ā€˜pollutingā€™ their classes with these operations.Visitor lets you keep unrelated operations together by deļ¬ning them in one class. When the object structure is shared by many applications, use Visitor to put operations in just those applications that need themā€ Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 43. Show me everything in a consistent manner... ... and send it to my friend via email oh, and send it to her phone as well... and print it..... Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 44. ā€œthe classes deļ¬ning the object structure rarely change, but you often want to deļ¬ne new operations over the structure. Changing the object structure classes requires redeļ¬ning the interface to all visitors, which is potentially costly. If the object structure classes change often, then itā€™s probably better to deļ¬ne the operations in those classesā€ Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 45. Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 46. Consequences Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 47. Visitor makes adding new operations easy Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 48. A visitor gathers related operations and separates unrelated ones Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 49. Adding new ConcreteElement classes is hard Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 50. Visitors can cross object hierarchies Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 51. Visitors can accumulate state Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 52. Visitors may compromise encapsulation Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.
  • 53. Discussion Copyright Cogent Consulting Pty Ltd (http://www.cogentconsulting.com.au) Licensed under a Creative Commons Attribution-Noncommercial 3.0 License.