Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 20

UNIT- II

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

2. Class Responsibility in-


– Identifying Attributes
– Identifying Methods

3. Guidelines for-
– Identifying Attributes Of Classes
– Identifying Methods Of Classes

4. So Far What We Learnt (SUMMARY)


5. Final Class Diagram- ATM

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.

ii. An assembly-part situation physically exists;

iii. For example- a French Onion Soup is an assembly of onion +


butter + flour + wine + French bread + cheddar cheese + so on…

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.

• Identifying attributes and methods is based on our creativity,


that is, thinking our real world.

• The use cases and other UML diagrams will be our guide for
identifying attributes, methods, and relationships among classes.

• That is, the Class Responsibility can be identified by analyzing the


use cases, sequence/collaboration, activity and state diagrams.

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.

• Attributes also may correspond to adjectives of


adverbs.

• Attributes are less likely to be fully described in the


problem statement. You must draw on your knowledge
of the application domain and the real world to find
them.
11-FEB-14 K. INDHU 10
GUIDELINES FOR:-
IDENTIFYING ATTRIBUTES OF CLASSES
• Omit derived attributes. For example, don't use age as an attribute
since it can be derived from date of birth. Derived attributes should be
expressed as a method like findAge();

• 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

• Methods and messages are the work horses of


object-oriented systems.

• In O-O environment, every piece of data, or object, is


surrounded by a rich set of routines called methods.

• Sequence diagrams can assist us in defining the


services the objects must provide.

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.

• Methods are responsible for managing the value of


attributes such as query, updating, reading and writing.

• CRUD on Objects can be used as -> Methods

• CRUD-> Create Read Update Delete-> IMPORTANT

11-FEB-14 K. INDHU 14
GUIDELINES FOR:-
IDENTIFYING METHODS OF CLASSES
• For example, we need to ask the following
questions about soup class:-

• What services must a soup class provide?

• And, What information (from domain knowledge) is


soup class responsible for storing?

• Or, what information does the soup class store into?

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.

• Now we need to add methods that can maintain these


attributes.

• For example, we need a method to change a price of a soup and


another operation to query about the price of soup.

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

• The hierarchical relation allows the sharing of properties or inheritance.


• A reference from one class to another is an association.
• The A-Part-of Structure is a special form of association.

• Every class is responsible for storing certain information from domain


knowledge.-> ATTRIBUTES

• Every class is responsible for performing operations necessary upon that


information.-> METHODS

11-FEB-14 K. INDHU 18
FINAL CLASS DIAGRAM- ATM

11-FEB-14 K. INDHU 19
HAPPY LEARNING!!!

You might also like