You are on page 1of 17

Identifying Object Relationships,

Attributes and Methods


Identifying Relationships

• There are three types of relationships that may exists in


between any two objects
– Association

– Super-Sub Structure

– Aggregation (A special case of association)


Association
• Represents a physical or conceptual connection between
two objects
Identifying Associations
• Analyzing the interactions between classes
• The following questions are answered for identification of
associations
– Is the class capable of fulfilling the required task by itself?
– If not, what does it need?

– From what other class can it acquire what it needs?


Guidelines for identifying association
• A dependency between two or more classes may be an
association. Association often corresponds to a verb or
prepositional phrase such as part-of, next-to, works-for,
etc.,
• A reference from one class to another is an association.
Some associations are implicit or taken from general
knowledge

Choose the association names carefully. Add role


name where appropriate.
Common association Patterns
• Location Association -
next-to, part-of, contained-in, etc.,

Cheese Soup
Part of

• Communication Association -
talk-to, order-to, etc.,

Customer Operator
Order-to
Eliminate Unnecessary associations
• Implementation Association -
The implementation specific association should be concentrated
only in the design phase. So eliminate them
• Ternary Association -
They are very complicated. Hence decompose them into simple
binary associations
• Directed Association -
Directed or derived associations are one which can be defined in
terms of other associations. Since they are redundant, avoid them.

John Ken
Grandparent of

John David Ken


Parent of Parent of
Super-Sub relationships
• Represents the inheritance relationship between related
classes
• This is also called as generalization hierarchy.
• The top level class – more general – called as base, super
class or ancestor
• The bottom level class – more specific – called as derived,
sub class or successor
Guidelines for identifying super-sub relation
• Top-down
Look for the noun phrases composed of various adjectives in a class
name. E.g.., A tall man and a short man

• Bottom-up
Look for the classes with similar attributes or methods. The commons
are grouped into super class

• Reusability
Move the attributes and behaviors to the top-level of the hierarchy.
Don’t create specialized class in the top-level.
• Multiple Inheritance
Avoid using multiple inheritance. Since they are very
complicated in implementation point of view. Use only the
class that is more appropriate as super class and define the
other class’s attributes here also.
Aggregation
• Represents the situation where a class consists of several
component classes

Properties of Aggregation
• Transitivity
If A is a part-of B and B is a part-of C. Then A is a
part-of C.
• Antisymmetry
If A is a part-of B. Then B is Not a part-of A.
Identifying Aggregation
• The following questions are answered for identification of
aggregation
– Does the part class belong to the problem domain?
– Is the part class within the system’s responsibilities?
– Does the part class capture more than a single value? If single
value then set it as an attribute.
– Does it provide a useful abstraction in dealing with problem
domain?
Aggregation Relationship Patterns
• Assembly -
An assembly is constructed from its parts.
E.g.., Coffee is assembly of Coffee powder, water
• Container -
The container contains, not constructed from the parts.
E.g.., House contains furniture and other appliances.
• Collection member -
Collection of conceptual or physical parts.
E.g.., Cricket team is a collection of players
Identifying Attributes

• The attributes are identified from scenario testing.

• Hence by analyzing the use-cases, sequence, collaboration,


state chart, activity diagrams, the classes responsibilities
are identified.
Guidelines for identifying attributes
• Attributes are usually corresponds to nouns, phrases,
adjectives and adverbs.
• Keep the class simple. State only enough attributes.
• Attributes are less defined in the problem statement. It is
obtained by general knowledge.
• Omit derived attributes
• Don’t waste much time in finding attributes. This can be
done in successive iterations.
Identifying Methods and Messages

• Methods are the services provided by the objects

• They are responsible to manage the value of the attributes.


Identifying methods by analyzing UML diagrams
• The sequence diagram says about the events that occur
between two objects.
• This event is considered to be an action that transmits
information between two objects
• These actions are the methods that the object should
perform.
• For each class the methods are defined by analyzing the
sequence diagram of all the related use-cases
• For E.g.., for “account” class, the methods are identified
by analyzing the sequence diagrams of the following use-
cases.
– Deposit Checking
– Deposit Savings
– Withdraw Checking
– Withdraw more from Checking
– Withdraw Savings
– Withdraw Savings denied
– Checking Transaction History
– Savings Transaction History

You might also like