AG VLSI Design and Architecture

SFB 501 - Project D1: Application System "Buildings"

PSiGene

Pattern Catalog

[PSiGene]

4.4 Pattern Traversal

Intent

Traverse the class structure to find all connected objects. An explicit path from the source class to targets doesn't have to be specified.

Also Known As

See also: the Demeter Project ( http://www.ccs.neu.edu/research/demeter/ )

Motivation

Applicability

Structure

Participants

Objects
Methods
Interfaces
Relations
Expressions

Collaborations

Consequences

Example:

Traversal
bind: 'target' to: 'Room'; 
bind: 'operation' to: 'printAll'; 
bind: 'remoteOperation' to: 'print';
bind: 'relation' to: '#(#LeftWalls #controlOfRoom)'.

This example will generate a method printAll which will call a print method on all connected LeftWalls and Controls. The Pattern takes care of the cardinality of the relations. The generated method in Smalltalk might look like this:

printAll
"follow all relations."

"1:n relation."
self LeftWalls connections do:
    [   :anObject|
        anObject print
    ].
"1:1 relation."
self controlOfRoom instance notNil ifTrue: 
[ self controlOfRoom instance print ].

Implementation

The Pattern uses code synthesis techniques to generate its code. Depending on the "unique " paramter, the Pattern FollowRelation (unique = false) or FollowRelationAndCollectObjects is dynamically (during the generation) aggregated for each relation that should be traversed. Additionally the Pattern MethodCall is aggregated once to call the generated follow methods.

Related Patterns

FollowRelation , FollowRelationAndCollectObjects , MethodCall .

PEdit description

Pattern Traversal Category indirection
    ObjectType use from
    ObjectType use to
    SingleMethod implement operation
    SingleMethod use optional remoteOperation at to
    Expression  implement optional avoidingRelations
    Expression  implement optional usingRelations
    Expression  implement optional avoidingClasses
    Expression  implement optional usingClasses
    Expression  implement preset oneWay
    Expression  implement preset unique
    Expression  implement optional parameter
End

previous page next page up   Table of Contents PSiGene