0% found this document useful (0 votes)
2 views16 pages

Week 5

Class diagrams are static structure diagrams that depict the classes, attributes, operations, and relationships in a system, serving as the foundation of object-oriented modeling. Key relationship types include associations, multiplicity, generalization, aggregation, and composition, each defining different interactions between classes. Examples illustrate the application of these concepts in contexts such as educational institutions and online shopping systems.

Uploaded by

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

Week 5

Class diagrams are static structure diagrams that depict the classes, attributes, operations, and relationships in a system, serving as the foundation of object-oriented modeling. Key relationship types include associations, multiplicity, generalization, aggregation, and composition, each defining different interactions between classes. Examples illustrate the application of these concepts in contexts such as educational institutions and online shopping systems.

Uploaded by

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

Software

Engineering 1
Week 5
Class Diagram
1.Class diagrams are 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.
2.The class diagram is the main building block of object-
oriented modeling.
3. Classes represent an abstraction of entities with common
characteristics.
• Relationship Types

1- Associations
• Associations represent static relationships between classes
2- Multiplicity

o Place multiplicity notations near the ends of an association. These symbols indicate the
number of instances of one class linked to one instance of the other class.
For example, one company will have one or more employees, but each employee works for
one company only.
3- Generalization

Generalization is another name for inheritance or an "is a" relationship.


It refers to a relationship between two classes where one class is a
specialized version of another.
For example, Honda is a type of car. So, the class Honda would have
a generalization relationship with the class car.
4- Aggregation
o A special type of association.
o It represents a "part of" relationship.
o Class2 is part of Class1.
Aggregation implies a relationship where the child can exist independently
of the parent
Example: CAR (Parent) and WHEEL (Child). So, if you delete the CAR,
the WHEEL still exist.
5- Composition:

• A special type of aggregation where parts are destroyed when the whole
is destroyed.
• Class2 cannot stand by itself.
• Composition display relationship where the child will never exist independent of
the parent. Example: House (parent) and Room (child).
8
Example 1:
This is a simple UML class diagram example that shows the use of various
UML relationships in a class diagram.

§ School has one or more Departments.


§ Department offers one or more Subjects.
§ A particular subject will be offered by only one department.
§ Department has instructors and instructors can work for one or more
departments.
§ Student can enroll in up to 5 subjects in a School.
§ Instructors can teach up to 3 subjects.
§ The same subject can be taught by different instructors.
§ School has one or more Departments.
§ Department offers one or more Subjects.
§ A particular subject will be offered by only one department.
§ Department has instructors and instructors can work for one or more departments.
§ Student can enroll in up to 5 subjects in a School.
§ Instructors can teach up to 3 subjects.
§ The same subject can be taught by different instructors.
Example

• Draw a class diagram for a graphic editor, which supports the concept of
grouping.
• Assuming that a document has several pages, every page contains the
following graphic objects: text, geometrical objects, and groups.
Geometrical objects are e.g. circles, ellipses, rectangles, lines and squares.

A group is simply a set of graphic objects, which can contain further groups
for its part.
A group has to contain at least two graphic objects. A graphic object can be
a direct member of at most one group
Example
•UML class diagram which shows a domain model for online shopping. The purpose of the diagram is to
introduce some common terms, "dictionary" for online shopping - Customer, Web User, Account,
Shopping Cart, Product, Order, Payment, etc. and relationships between. It could be used as a common
ground between business analysts and software developers.
• Each customer has unique id and is linked to exactly one account. Account owns shopping cart and
orders. Customer could register as a web user to be able to buy items online. Customer is not required
to be a web user because purchases could also be made by phone or by ordering from catalogues. Web
user has login name which also serves as unique id. Web user linked to a shopping cart. Shopping cart
belongs to account.

• Account owns customer orders. Customer orders are sorted and unique. Each order could refer to
several payments, possibly none. Every payment has unique id and is related to exactly one account.
Both order and shopping cart have line items linked to a specific product. Each line item is related to
exactly one product. A product could be associated to many line items or no item at all.

You might also like