Lab 3
Lab 3
SOFTWARE
DEVELOPMENT
LAB 3
CLASS DIAGRAM
WHAT IS CLASS DIAGRAM?
• In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of
static structure diagram that describes the structure of a system by showing the system's
classes, their attributes, operations (or methods), and the relationships among objects.
PURPOSE OF CLASS DIAGRAMS
• A description of a group of objects all with similar roles in the system, which consists of:
• Structural features (attributes) define what objects of the class "know"
• Represent the state of an object of the class
• Are descriptions of the structural or static features of a class
• Behavioral features (operations) define what objects of the class "can do"
• Define the way in which objects may interact
• Operations are descriptions of behavioral or dynamic features of a class
CLASS NOTATION
• A class notation consists of three parts:
1. Class Name
1. The name of the class appears in the first partition.
2. Class Attributes
1. Attributes are shown in the second partition.
2. The attribute type is shown after the colon.
3. Attributes map onto member variables (data members) in code.
3. Class Operations (Methods)
1. Operations are shown in the third partition. They are services the class provides.
2. The return type of a method is shown after the colon at the end of the method
signature.
3. The return type of method parameters is shown after the colon following the
parameter name.
4. Operations map onto class methods in code
• The graphical representation of the class - MyClass as shown above:
• MyClass has 3 attributes and 3 operations
• Parameter p3 of op2 is of type int
• op2 returns a float
• op3 returns a pointer (denoted by a *) to Class6
VISIBILITY OF CLASS ATTRIBUTES AND
OPERATIONS
• Simple Association:
• A structural link between two peer classes.
• There is an association between Class1 and Class2
• A solid line connecting two classes
CLASS RELATIONSHIPS
• Aggregation:
• A special type of association. It represents a "part of" relationship.
• Class2 is part of Class1.
• Many instances (denoted by the *) of Class2 can be associated with Class1.
• Objects of Class1 and Class2 have separate lifetimes.
• A solid line with an unfilled diamond at the association end connected to the
class of composite
CLASS RELATIONSHIPS
• Composition:
• A special type of aggregation where parts are destroyed when the whole is destroyed.
• Objects of Class2 live and die with Class1.
• Class2 cannot stand by itself.
• A solid line with a filled diamond at the association connected to the class of composite
MULTIPLICITY
• How many objects of each class take part in the relationships and multiplicity can be
expressed as:
• Exactly one - 1
• Zero or one - 0..1
• Many - 0..* or *
• One or more - 1..*
• Exact Number - e.g. 3..4 or 6
• Or a complex relationship - e.g. 0..1, 3..4, 6.* would mean any number of objects other than
2 or 5
CLASS DIAGRAM EXAMPLE: ORDER SYSTEM
OBJECT DIAGRAM
WHAT IS OBJECT DIAGRAM?
• Object is an instance of a class in a particular moment in runtime that can have its own state
and data values. Likewise a static UML object diagram is an instance of a class diagram; it
shows a snapshot of the detailed state of a system at a point in time, thus an object diagram
encompasses objects and their relationships which may be considered a special case of a
class diagram or a communication diagram.
PURPOSE OF OBJECT DIAGRAM
• The use of object diagrams is fairly limited, mainly to show examples of data structures.
• During the analysis phase of a project, you might create a class diagram to describe the
structure of a system and then create a set of object diagrams as test cases to verify the
accuracy and completeness of the class diagram.
• Before you create a class diagram, you might create an object diagram to discover facts about
specific model elements and their links, or to illustrate specific examples of the classifiers that
are required.
BASIC OBJECT DIAGRAM SYMBOLS AND
NOTATIONS
• Object Names:
• Every object is actually symbolized like a rectangle, that offers the name from the object
and its class underlined as well as divided with a colon.
• Object Attributes:
• Similar to classes, you are able to list object attributes inside a separate compartment.
However, unlike classes, object attributes should have values assigned for them.
• Links:
• Links tend to be instances associated with associations. You can draw a link while using
the lines utilized in class diagrams.
CLASS DIAGRAM VS. OBJECT DIAGRAM
THANK YOU !