18.10.2014 Views

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

20 <strong>Software</strong> design<br />

2.3.1 The car as an object<br />

A car is made up of many components or objects. From a user’s perspective some of the major objects that make<br />

up a car are:<br />

• The shell or body of the car.<br />

• The eng<strong>in</strong>e.<br />

• The gearbox.<br />

• The clutch.<br />

• The battery that provides electric power.<br />

We can th<strong>in</strong>k of the body or shell of the car as a conta<strong>in</strong>er for all the other objects, that when comb<strong>in</strong>ed, form a<br />

work<strong>in</strong>g car. These other objects are hidden from the driver of the car. The driver can, however, <strong>in</strong>teract with<br />

these objects by us<strong>in</strong>g the external <strong>in</strong>terfaces that form part of the car shell. This arrangement of objects is<br />

expressed diagrammatically us<strong>in</strong>g the UML notation <strong>in</strong> Figure 2.1.<br />

Car body<br />

1<br />

1<br />

1<br />

1 1<br />

1 1 1<br />

Eng<strong>in</strong>e<br />

Gearbox<br />

Clutch<br />

Battery<br />

Figure 2.1 <strong>Object</strong>s that make up a car.<br />

In Figure 2.1 the follow<strong>in</strong>g style of notation is used:<br />

Eng<strong>in</strong>e<br />

Denotes an object. In this specific case the car eng<strong>in</strong>e.<br />

Eng<strong>in</strong>e<br />

1<br />

4<br />

Piston<br />

Denotes aggregation. The eng<strong>in</strong>e conta<strong>in</strong>s 4 pistons.<br />

Note:<br />

A<br />

A<br />

B<br />

Denotes aggregation, the component B is<br />

conta<strong>in</strong>ed <strong>in</strong> the conta<strong>in</strong>er A.<br />

B<br />

Denotes composition, <strong>in</strong> addition the<br />

component B is created and destroyed by the<br />

conta<strong>in</strong>er A.<br />

By us<strong>in</strong>g this notation, we can express the ‘part of’ relationship between objects. The eng<strong>in</strong>e, gearbox, clutch<br />

and battery are ‘part of’ a car.<br />

© M A Smith - May not be reproduced without permission

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

Saved successfully!

Ooh no, something went wrong!