0% found this document useful (0 votes)
58 views11 pages

5.class Diagram

The document discusses class diagrams and terms related to classes. It defines what a class is and describes the key components of a class including the name, attributes, operations, and stereotypes. It also discusses class names, attributes, and operations in more detail providing examples.

Uploaded by

Santa claus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views11 pages

5.class Diagram

The document discusses class diagrams and terms related to classes. It defines what a class is and describes the key components of a class including the name, attributes, operations, and stereotypes. It also discusses class names, attributes, and operations in more detail providing examples.

Uploaded by

Santa claus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Agenda

• 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

The name of the class is the only required tag in the


ClassName graphical representation of a class. It always
appears in the top-most compartment.

attributes

operations
Class Attributes

Person

An attribute is a named property of a


name : String class that describes the object being modeled.
address : Address In the class diagram, attributes appear in
birthdate : Date the second compartment just below the
ssn : Id name-compartment.
Class Attributes (Cont’d)

Person

Attributes can be:


+ public
+ name : String
# protected
# address : Address
- private
# birthdate : Date
/ derived
/ age : Date
- ssn : Id
Class Operations

Person

name : String
address : Address
birthdate : Date
ssn : Id

Operations describe the class behavior


Eat () and appear in the third compartment.
Sleep ()
Work ()
Play ()
Class Operations (Cont’d)

PhoneBook

newEntry (n : Name, a : Address, p : PhoneNumber, d : Description)


getPhone ( n : Name, a : Address) : PhoneNumber

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)

You might also like