0% found this document useful (0 votes)
38 views24 pages

Lab 3

This document discusses class diagrams and object diagrams in UML. It defines class diagrams as diagrams that show the structure of a system through classes, attributes, operations, and relationships. It also defines object diagrams as instance-level diagrams that show the state of objects and their relationships at a point in time. The document provides details on the notation for classes, attributes, operations, and different types of relationships in class diagrams, including aggregation, composition, inheritance, and associations. It includes an example of a class diagram for an order system. Finally, it contrasts class diagrams, which show general structure, from object diagrams, which illustrate specific object states and values.

Uploaded by

Reem Haitham
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)
38 views24 pages

Lab 3

This document discusses class diagrams and object diagrams in UML. It defines class diagrams as diagrams that show the structure of a system through classes, attributes, operations, and relationships. It also defines object diagrams as instance-level diagrams that show the state of objects and their relationships at a point in time. The document provides details on the notation for classes, attributes, operations, and different types of relationships in class diagrams, including aggregation, composition, inheritance, and associations. It includes an example of a class diagram for an order system. Finally, it contrasts class diagrams, which show general structure, from object diagrams, which illustrate specific object states and values.

Uploaded by

Reem Haitham
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/ 24

OBJECT ORIENTED

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

1. Shows static structure of classifiers in a system


2. Diagram provides a basic notation for other structure diagrams prescribed by UML
3. Helpful for developers and other team members too
4. Business Analysts can use class diagrams to model systems from a business perspective
• A UML class diagram is made up of:
• A set of classes and
• A set of relationships between classes
WHAT IS A CLASS

• 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

• In object-oriented design, there is a notation of visibility for attributes and


operations. UML identifies four types of visibility: public, protected, private,
and package.
• The +, -, # and ~ symbols before an attribute and operation name in a class
denote the visibility of the attribute and operation.
• + denotes public attributes or operations
• - denotes private attributes or operations
• # denotes protected attributes or operations
• ~ denotes package attributes or operations
RELATIONSHIP TYPE

• Inheritance (or Generalization):


• Represents an "is-a" relationship.
• An abstract class name is shown in italics.
• SubClass1 and SubClass2 are specializations of Super Class.
• A solid line with a hollow arrowhead that point from the child to the parent class
CLASS RELATIONSHIPS

• 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 !

You might also like