Page 45 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 45
Unit 4: Advanced Class Modelling – I
advanced objects and classes, association ends, n-ary association. An object is a something (a Notes
thing or a concept) that has a well-defined role in the application domain. Advanced object and
class concepts include instantiation, Class Attributes and Operations, Attribute Multiplicity
which specifies the possible number of values for an attribute, Candidate Keys for Classes
which uniquely identifies the object, domains, etc. Also we will discuss the concept of n-ary
association and aggregation.
4.1 Advanced Object and Class Concepts
Various concepts of advanced objects and classes are discussed below:
4.1.1 Instantiation
Instantiation is the relationship between an object and its class. The notation for instantiation is
a dashed line from the instance to the class with an arrow pointing to the class; the dashed line
is labeled with the legend instance enclosed by guillemets («»). Figure 4.1 shows this notation
for City and its two instances Bombay and Prague. Making the instantiation relationship between
classes and instances explicit in this way can be helpful in modeling complex problems and in
giving examples.
Figure 4.1: Instantiation Relationships
4.1.2 Class Attributes and Operations
A class attribute is an attribute whose value is common to a group of objects in a class rather than
peculiar to each instance. Class attributes can be used to store default or summary data for
objects. A class operation is an operation on a class rather than on instances of the class. The most
common kind of class operations are operations to create new class instances. You can denote
class attributes and class operations with an underline. Our convention is to list them at the top
of the attribute box and operation box, respectively.
In most applications class attributes can lead to an inferior model. We discourage the use of class
attributes. Often you can improve your model by explicitly modeling groups and specifying
scope.
Example: The upper model in Figure 4.2 shows class attributes for a simple model of
phone mail. Each message has an owner mailbox, date recorded, time recorded, priority, and
message contents, indicating if it has been received. A message may have a mailbox as the
source or it may be from an external call. Each mailbox has a phone number, password, and
recorded greeting. For the PhoneMessage class we can store the maximum duration for a message
and the maximum days a message will be retained. For the PhoneMailbox class we can store the
maximum number of messages that can be stored.
The upper model is inferior, however, because the maximum duration, maximum days retained,
and maximum message count has a single value for the entire phone mail system. In the lower
model these limits can vary for different kinds of users, yielding a phone mail system that is
more flexible and extensible.
LOVELY PROFESSIONAL UNIVERSITY 39