5.class Diagram
5.class Diagram
• Class Diagrams
– Introduction To Classes
1
Terms and Concepts
• A class is ...
– The most important building block of any object-oriented
system.
– A description of a set of objects that share the same attributes
and behaviors.
– A blueprint for creating an object.
– An abstraction (simplification) of reality.
– A representation of a software thing, a hardware thing, or even
a conceptual thing.
– Graphically represented as a rectangle.
2
Terms and Concepts
• All classes have …
– Names - Used to distinguish one class from another. A class
must have a name.
– Attributes - Member data.
– Operations (behaviors) - Member functions.
– Stereotypes - Documentation used to categorized class
members.
• Attributes and operations are the most important
features of a class definition.
• A class usually collaborate with other classes.
3
Terms and Concepts
• Class names are …
– Extracted from the problem domain (statement).
– Nouns or noun phrases.
– Concise and descriptive.
• Class attributes are …
– Usually nouns or noun phrases.
– Extracted or inferred from the problem statement.
– Used to represent properties of the enclosing class.
– Determine the state of an object.
4
Terms and Concepts
• Class operations (behaviors) are …
– Verbs or verb phrases.
– Inferred from the problem statement.
– Provide a requested service.
5
Class Names
attributes
operations
Class Attributes
Person
Person
Person
name : String
address : Address
birthdate : Date
ssn : Id
PhoneBook
You can specify an operation by stating its signature: listing the name, type, and
default value of all parameters, and, in the case of functions, a return type.
A Class in Design has Greater Details in the
Three Parts of its Definition
Stereotype
Class Name <<entity>>
PATIENT
Initial Value
Attributes
- Sno : INT := 0;
- Name : CHAR;
Visibility - Address: CHAR; Attribute Type
(private)
- Date-of-birth: DATE
Operations / Signature
Methods
+ getName (): BOOL; including
+ getSerialNumber(): BOOL; Return Value
Visibility
+ changeAddress(): BOOL;
(public)
Parameter List
(place for)