0% found this document useful (0 votes)
9 views

Class Diagrams

The document explains about class diagrams used in OOAD

Uploaded by

hawkinsopagala
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Class Diagrams

The document explains about class diagrams used in OOAD

Uploaded by

hawkinsopagala
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Class diagrams

Class Diagrams
• Class diagrams are the most common UML diagrams found in modeling
object- oriented systems. Because they can directly be mapped onto
object oriented languages
• This diagram describes the types of objects in the system and
various kinds of static relationships which exist between them.
• A class diagram shows a set of classes, interfaces, and collaborations
and their relationships.
• You use class diagrams to model the static design view of a system.
• Employee id, name, DOA, DOB, join(),retire(), changedetails
Domain Class model
• Domain model is a visual representation of conceptual
classes or real situation objects in a domain.
• The domain models are also called conceptual, domain
object or analysis models
• Domain models focus on explaining the core things and the
products of the business domain
• In UML modelling, the domain model can be represented
using a class diagram but in these diagrams there is no
operation that is defined.
• The domain model therefore represents the domain objects
or conceptual classes AND association or relationship
Attributes of conceptual classes
• Bank(name, branch, city
• Customer ( name address ac)
• Account (status,cno.)
Example: domain model
Design class models

• Can be generated from the source code thru reverse engineering to


visualize static structure of the system
• Attributes
• Operations….the operations are defined….
• Visibility
• Multiplicity
Visibility
• Denotes the mode of accessibility of attributes
• Either public, private or protected
• Private means visibility hides information from anything outside the
class…items not available outside the class they are defined in
• Public allow all other classes to view the marked information
• Protected allows child classes to access information they inherited
from parent class…. items available to that class and all sub classes
of that base class.
Finding conceptual classes:
• The four alternative approaches for identifying classes:
• 1. The noun phrase approach.
• 2. The common class patterns approach.
• 3. The use-case driven, sequence/collaboration modeling approach.
• 4. The classes, responsibilities and collaborators (CRC) approach.
Common Class Patterns Approach
• This approach is based on the knowledge-base of the common classes
that have been proposed by various researchers.
Candidate Classes - Events
• These are points in time that must be recorded and remembered.
• Things happen, usually to something else, at a given date and time,
or as a step in an ordered sequence.
• For example order which is an event that must be remembered.,
sale, registration, payment, booking
Candidate Classes - Organization
• The organizational units that people belong to.
• For example, accounting department might be considered as a
potential class., team, school,
Candidate Classes - People and Person (Roles
and Roles Played)
• The different roles users play in interacting with the
application….doctor, lecturer, customer, sales agent, employee, clerk
Candidate Classes - People (Con’t)
• It can be divided into two types (Coad & Yourdon):
• Those representing users of the system, such as an operator, or a
clerk;
Candidate Classes - People (Con’t)
• Those people who do not use the system but about
whom information is kept.
• Some examples are Client, Employee, Teacher,
Manager.
Candidate Classes - Places

• These are physical locations, such as buildings, stores, sites or offices


that the system must keep information about room
Candidate Classes - Tangible Things and
Devices
• Physical objects, or group of objects, that are tangible, and devices
with which the application interacts.
• For example, cars, pressure sensors, bar code reader,
Candidate Classes - Concepts
• Concepts are principles or
ideas not tangible but used to
organize or keep track of
business activities and/or communications.
Booking, reservation, registration,
Conceptual classes
Types of relationships
• A relationship is a connection/link among things.
• In object-oriented modelling, the three most important relationships
are
• Associations....refers to relationships between instance types (a person
works for a company, a company has a number of offices.)
• Generalization,
• Aggregation...A form of object composition
• Composition...a strong form of object composition. and
• Dependency,
• Reflexive
Association
• An association is a structural relationship that specifies that
objects of one thing are connected to objects of another
• Possible in both directions

• A kind of relationship between instances of classes

• The multiplicity of the association denotes the number of


objects/classes that can participate in then relationship.

• For example, an Order object can be associated to only one


customer, but a customer can be associated to many orders.
Generalization
• A generalization is a relationship between a general thing (called
the superclass or parent) and a more specific kind of that thing
(called the subclass or child).
• Generalization is sometimes called an " is-a-kind-of " relationship
Aggregation
• A type of association where one object is the owner of another object
• A child class can exist independently
• A plain association between two classes represents a structural
relationship between peers, meaning that both classes are
conceptually at the same level, no one more important than the other.

• ‘Has a’ type of a relationship


Composition
• A container relationship// contained in another object/class …..Strong
structural relationship between classes
• Child cannot exist independently….destroy container class

• Enables code reusability

• Parts cannot be detached from the owner.


• Their lives are the same (one is part of the other); once owner destroyed,
the parts are also destroyed.
• Owns a
Dependency:
• A dependency is a using relationship that states that a change in
specification of one thing (for example, class Event) may affect
another thing that uses it (for example, class Window), but not
necessarily the reverse.

• Reflexive…..relationship within a single class ie between the


instances of a class…is married by, is chairman
Example….
• One customer makes one or many orders. Each order has order
details(composition relationship)
• Each order includes a payment procedure. The customer can pay card, cheque
or credit
• An item is contained in zero or more order details

• Abstract class cannot be instantiated…..provides a base for subclasses to


extend and implement the abstract methods and override or use the
implemented methods in abstract class
Examples:
• Draw a class diagram representing a book defined by the following
statement: “A book is composed of a number of parts, which in turn
are composed of a number of chapters. Chapters are composed of
sections.” Focus only on classes and relationships. [2 Marks]

• A teacher teaches 1 to 3 courses /subjects. Each course is taught by


only one teacher. A student can take between 1 to 5 courses. A course
can have 10 to 300 students. Illustrate with a suitable diagram, how
the above scenario can be modelled using UML [6 Marks]
Assignment 3
You are required to develop an information system for a school. The
requirements specification is as follows. A school has one or more
departments. Each department has a lecturer who is a department chair.
A lecturer can be the chair of no more than one department. Every
student may attend any number of courses and every course may have
any number of students. For every course there is at least one lecturer.
Each lecturer may teach any number of courses. Draw a class diagram
which consists of all classes in your system, their attributes and
operations, relationships between the classes and multiplicity
specifications. [10 Marks
ASSIGNMENT 3 DUE 22ND NOVEMBER 2024 SCO208OOAD

You are required to develop an information system for a school. The


requirements specification is as follows. A school has one or more
departments. Each department has a lecturer who is a department chair.
A lecturer can be the chair of no more than one department. Every
student may attend any number of courses and every course may have
any number of students. For every course there is at least one lecturer.
Each lecturer may teach any number of courses. Draw a class diagram
which consists of all classes in your system, their attributes and
operations, relationships between the classes and multiplicity
specifications. [10
Marks]

You might also like