CPL - Chalmers Publication Library
| Utbildning | Forskning | Styrkeområden | Om Chalmers | In English In English Ej inloggad.

The visitor pattern as a reusable, generic, type-safe component

Bruno C D S Oliveira ; Meng Wang (Institutionen för data- och informationsteknik (Chalmers)) ; Jeremy Gibbons
ACM SIGPLAN Notices (0362-1340). Vol. 43 (2008), 10, p. 439-456.
[Artikel, refereegranskad vetenskaplig]

The VISITOR design pattern shows how to separate the structure of an object hierarchy from the behaviour of traversals over that hierarchy. The pattern is very flexible; this very flexibility makes it difficult to capture the pattern as anything more formal than prose, pictures and prototypes. We show how to capture the essence of the VISITOR pattern as a reusable software library, by using advanced type system features appearing in modern object-oriented languages such as Scala. We preserve type-safety statically and modularly: no reflection or similar mechanisms are used and modules can be independently compiled. The library is generic, in two senses: not only is it parametrised by both the return type and the shape of the object hierarchy, but also it allows a number of implementation choices (internal versus external control, imperative versus functional behaviour, orthogonal aspects such as tracing and memoisation) to be specified by parameters rather than fixed in early design decisions. Finally, we propose a generalised datatype-like notation,on top of our visitor library: this provides a convenient functional decomposition style in object-oriented languages.

Nyckelord: algebraic datatypes, design patterns, program extensibility, software components, traversal, visitor pattern

Den här publikationen ingår i följande styrkeområden:

Läs mer om Chalmers styrkeområden  

Denna post skapades 2013-07-31.
CPL Pubid: 180410


Läs direkt!

Länk till annan sajt (kan kräva inloggning)

Institutioner (Chalmers)

Institutionen för data- och informationsteknik (Chalmers)


Informations- och kommunikationsteknik

Chalmers infrastruktur