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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

connectedTo<br />

*<br />

Lamp<br />

*<br />

Weight<br />

Sensor<br />

Traffic Light<br />

*<br />

*<br />

1<br />

1<br />

*<br />

*<br />

*<br />

1<br />

* *<br />

1<br />

Controller<br />

Visual<br />

Sensor<br />

coordinatedBy<br />

Central Control<br />

1<br />

1<br />

Computer<br />

1<br />

*<br />

*<br />

Console<br />

Figure 17.16: Example composites<br />

A class may define a pattern of objects <strong><strong>an</strong>d</strong> links that are part of it <strong><strong>an</strong>d</strong> that exist whenever the class<br />

is inst<strong>an</strong>tiated. Such a class is called a composite. It is a class that contains <strong>an</strong> object diagram. It may be<br />

thought of as <strong>an</strong> extended form of aggre gation where the relationships among the parts are valid only<br />

within the composite. A composite is a kid of pattern or macro that represents a conceptual clustering<br />

for a given purpose. Composition is shown by drawing a class box around its embedded components (as<br />

illustrated in Figure 17.16) which are prototypical objects <strong><strong>an</strong>d</strong> links. That is, a composite defines a<br />

context in which references to classes <strong><strong>an</strong>d</strong> associations, defined elsewhere, c<strong>an</strong> be used.<br />

17.5 Packages<br />

Packages a re used to group associated modeling elements such as classes in the object model (or<br />

subsystems in component diagrams). They are drawn as tabbed folders as illustrated in Figure 17.17.<br />

Figure 17.17 actually illustrates four packages called clients, Business model, Persistent store, B<strong>an</strong>k<br />

<strong><strong>an</strong>d</strong> Network. In this particular diagram the contents of Clients, Persistent Store, B<strong>an</strong>k <strong><strong>an</strong>d</strong> Network have<br />

been suppressed (by convention these packag es have their names placed in their body) with only<br />

Business Model being shown in detail (with its name in the top tab). This package possesses two classes<br />

Customer <strong><strong>an</strong>d</strong> Account as well as a nested package B<strong>an</strong>k. The dashed lines between the packages<br />

illustrate dependencies between packages. For example, the package Clients directly depends on the<br />

packages Business Model <strong><strong>an</strong>d</strong> Network (this actually me<strong>an</strong>s that at least one element in the package<br />

Clients relies on at least one element in the other two packages).<br />

Clients<br />

Business Model<br />

Customer<br />

B<strong>an</strong>k<br />

Account<br />

Network<br />

Persistent Store<br />

Figure 17.17: Packages with Dependencies<br />

Classes may belong to exactly one package but references may be made to classes in other packages.<br />

Such references have the package name foll owed by the class name (separated by two colons), for<br />

example: Business Model :: Customer.<br />

145

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

Saved successfully!

Ooh no, something went wrong!