Professional Documents
Culture Documents
Day 17
Day 17
CHAPTER IN BOOK- 8
DAY- 17
-K. Indhu
SYLLABUS COVERED HERE
• Aggregation – II
• Identifying Attributes and Methods
• Object Responsibility
11-FEB-14 K. INDHU 2
GOALS
1. Aggregation
– Properties of Aggregation
– A-Part-Of Relationship Patterns
– ATM with A-Part-Of Relationship
3. Guidelines for-
– Identifying Attributes Of Classes
– Identifying Methods Of Classes
11-FEB-14 K. INDHU 3
A-PART-OF RELATIONSHIP- AGGREGATION
• Two major properties of a-part-of relationship are:
1. Transitivity:-
• If A is part of B and B is part of C, then A is part of C.
• For example, a carburetor is part of an engine and an engine
is part of a car; therefore, a carburetor is part of a car.
2. Anti-Symmetry:-
• If A is part of B, then B is not part of A.
• For example, an engine is part of a car, but a car is not part
of an engine.
11-FEB-14 K. INDHU 4
A-PART-OF RELATIONSHIP PATTERNS
• To identify a-part-of structures from a-whole, Coad and
Yourdon provide following guidelines:-
1) ASSEMBLY
2) CONTAINER
3) COLLECTION–MEMBER
1. Assembly:-
i. An assembly is constructed from its parts.
11-FEB-14 K. INDHU 5
A-PART-OF RELATIONSHIP PATTERNS
2. Container:-
i. A physical whole encompasses (contains) but is not constructed
from physical parts;
ii. For example- a house can be considered as a container for furniture
and appliances.
3. Collection-Member:-
i. A conceptual whole encompasses (contains) parts that may be
physical or conceptual.
ii. For example- a football team is a collection of players.
11-FEB-14 K. INDHU 6
EXAMPLE- ATM WITH A-PART-OF
RELATIONSHIP
11-FEB-14 K. INDHU 7
CLASS RESPONSIBILITY: IDENTIFYING
ATTRIBUTES AND METHODS
• Identifying attributes and methods, like finding classes, is a
difficult activity.
• The use cases and other UML diagrams will be our guide for
identifying attributes, methods, and relationships among classes.
11-FEB-14 K. INDHU 8
CLASS RESPONSIBILITY: IDENTIFYING
ATTRIBUTES AND METHODS
• Responsibility is the key issue.
• Imagine yourself as an object and ask below
questions in an object oriented environment;
– How am I going to be used?
– How am I going to collaborate with other classes?
– How am I described in the context of this system's
responsibility?
– What do I need to know?
– What state information do I need to remember over time?
– What states can I be in?
11-FEB-14 K. INDHU 9
GUIDELINES FOR:-
IDENTIFYING ATTRIBUTES OF CLASSES
• Attributes usually correspond to nouns followed by
prepositional phrases such as cost of the soup.
• Do not carry discovery of attributes to excess. You can always add more
attributes in the subsequent iterations.
• Keep the class simple; only state enough attributes to define the object
state.
• For example, LibraryMember class need not have attributes- (i) Weight,
(ii) Height which are not relevant to the Library System’s Borrowing /
Returning Books.
11-FEB-14 K. INDHU 11
GUIDELINES FOR:-
IDENTIFYING METHODS OF CLASSES
11-FEB-14 K. INDHU 12
GUIDELINES FOR:-
IDENTIFYING METHODS OF CLASSES
11-FEB-14 K. INDHU 13
GUIDELINES FOR:-
IDENTIFYING METHODS OF CLASSES
• Methods usually correspond to queries about
attributes (and sometimes association) of the objects.
11-FEB-14 K. INDHU 14
GUIDELINES FOR:-
IDENTIFYING METHODS OF CLASSES
• For example, we need to ask the following
questions about soup class:-
11-FEB-14 K. INDHU 15
GUIDELINES FOR:-
IDENTIFYING METHODS OF CLASSES
• Let's first take a look at soup’s attributes which are:-
1. name
2. preparation,
3. price,
4. preparation time and
5. oven temperature.
11-FEB-14 K. INDHU 16
GUIDELINES FOR:-
IDENTIFYING METHODS OF CLASSES
• FINAL LIST OF METHODS FOR SOUP CLASS:-
1. setName()
2. getName()
3. setPreparation()
4. get Preparation()
5. setCost()
6. getCost()
7. setOvenTemperature()
8. getOvenTemperature()
9. setPreparationTime()
10.getPreparationTime()
11-FEB-14 K. INDHU 17
SO FAR WHAT WE LEARNT…
• We learned how to identify three types of object relationships:
1. Association
2. Super-sub Structure (Generalization Hierarchy)
3. A-part-of Structure
11-FEB-14 K. INDHU 18
FINAL CLASS DIAGRAM- ATM
11-FEB-14 K. INDHU 19
HAPPY LEARNING!!!