29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

edisplay()<br />

Controller<br />

window<br />

A<br />

Window<br />

P<br />

(window)<br />

1: displayPositions(window)<br />

1.1.3.1: add(self)<br />

wire<br />

A<br />

A<br />

new contents<br />

1.1 *(1=n): drawSegment(i)<br />

(self)<br />

S<br />

Wire<br />

1.1.2: create(r0,r1)<br />

1.1.3: display(window)<br />

temp (line)<br />

A<br />

*<br />

new Line<br />

1.1.1a: r0 := position()<br />

1.1.1b: r1 := position()<br />

A<br />

Bead<br />

A<br />

Bead<br />

Figure 18.3: An example collaboration diagram<br />

<strong>Object</strong>s which are created during the collaboration are indicated by the label new before the obje ct<br />

name. For example the Line object in Figure 18.3. Links between objects are <strong>an</strong>notated to indicate their<br />

type (e.g. perm<strong>an</strong>ent or temporary existing for this particular collaboration). These adornments are<br />

placed in boxes on the ends of the links <strong><strong>an</strong>d</strong> c<strong>an</strong> have the following values:<br />

A - association (or perm<strong>an</strong>ent) link<br />

F - <strong>Object</strong> field (the target object is part of the source object)<br />

G - global variable<br />

L - local variable<br />

P - Procedure parameter<br />

S - self reference<br />

Role names c<strong>an</strong> also be added to distinguish links (e.g. self, wire <strong><strong>an</strong>d</strong> window in Figure 18.3). Role<br />

names in brackets indicate a temporary link, i.e. one that is not <strong>an</strong> association.<br />

The messages which are sent along links are indicated by labels next to the links. One or more<br />

messages c<strong>an</strong> be sent along a link in either or both directions. The format of the messages is defined by<br />

the following (some of which are optional):<br />

1. A comma-separated list of sequence numbers in brackets: [seqno, seqno]. The sequence numbers<br />

indicate messages from other threads of control that must occur before the current message c<strong>an</strong><br />

occur. This element is only needed with concurrency.<br />

2. A sequence number containing a list of sequence elements separated by full stops (periods).<br />

These represent the nested procedural calling sequence of the message in the overall tr<strong>an</strong>saction.<br />

Each element section has the following parts:<br />

• A letter (or name) indicating a concurrent thread. All letters at the same level of nest ing<br />

represent threads that execute concurrently e.g. 1.2a <strong><strong>an</strong>d</strong> 1.2b are concurrent. Omitting the<br />

letter entirely is equivalent to <strong>an</strong>other dummy letter <strong><strong>an</strong>d</strong> usually indicates the main<br />

sequence.<br />

• An integer number. The numbers show the sequential position of th e current message<br />

within its thread. For example, message 2.1.4 is part of the procedure invoked by message<br />

2.1 <strong><strong>an</strong>d</strong> follows message 2.1.3 within that procedure.<br />

• An iteration indicator. This is a star (*), optionally followed by <strong>an</strong> iteration expression in<br />

parentheses. Iteration indicates that several messages of the same form are sent either<br />

sequentially (to a single target) or concurrently (to the elements of a set). If there is <strong>an</strong><br />

iteration expression, it shows the values that the iterator or iterators assume, such as<br />

“(i=1..n)”; otherwise the details of the iteration must be specified in text or simply deferred<br />

to the code.<br />

149

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!