Uploaded by zinhlemkhize373

Intro Classes

advertisement
Classes
Chapter 4
To produce a domain
model class diagram
using UML
What is Class in an UML
Diagram?
 A Class in UML diagram
is a blueprint used to create an object or set of
objects.
 It is a template to create various objects and
implement their behaviour in the system.
 It defines what an object can do

 A Class in UML is represented by a rectangle
that includes rows with class names,
attributes, and operations: in three
compartments.
2
What is Class Diagram?
 A Class Diagram in Software engineering is
a static structure that gives an overview of a
software system by displaying classes,
attributes, operations, and their relationships
between each other.
 Class Diagram helps construct the code for
the software application development.
 Analysis  Design  Implementation
3
Benefits of Class Diagram
 Illustrates data models for even very complex
information systems
 It provides an overview of how the application is
structured before studying the actual code. This
can easily reduce the maintenance time
 It helps for better understanding of general
schematics of an application.
 Allows drawing detailed charts which highlights
code required to be programmed
 Helpful for developers and other stakeholders.
4
Essential elements of A UML
class diagram
•Public, private, protected and package are the four visibilities which are
denoted by +, -, #, or ~ signs respectively.
•Visibility describes the accessibility of an attribute of a class.
•Attributes must have a meaningful name that describes the use of it in a
class.
5
“Relationships”
 Associations
 Association Class
 Dependencies
 Generalizations
 Whole-Part
 Multiplicity
 “Role”
6
Association
7
Association Class
 Example:
Courses may be offered as many CourseSections
 A student may enrolls in many Course-Sections
 A Course-Section may be taken by many students
 A course is described by

 Course ID, Description, Credit hours

Course Section
 Section no, times, venue

Student:
8
Course Enrolment:

Where is each student’s grade remembered in this model?


Each section has many grades and each grade is association with a student
Each student has many grades and each grade is association with a section
9
Association Class cont.
 There is a M:N association between Course
Section and Student
 Problem:
Sometimes M:N associations involve additional
data that are important and must be stored
 Where must the Grade that each student
receives for the course-section be stored?

 Solution: Association Class
10
Introducing Association Class

Association class— an association that is treated as a class in a
many to many association because it has attributes that need to be
remembered, such as grade
11
Generalization
Italics
It’s natural to classify objects in categories (a TYPE of; Kinds of) and to
organize categories into subcategories. If you look for a place to live, you
find yourself categorizing a dwelling unit as a house, apartment,
townhouse, mansion, etc.
As you define classes, you may notice that some classes have the same
attributes or the same operations. When this is the case, you place these
common features (attributes, operations, and so on) in a more generic
class called the superclass. The classes that share the common features 12
are known as subclasses of the superclass.
Generalization/Specialization
 The idea that people classify “things” ito
similarities and differences
13
Whole-Part
 Aggregation:

In aggregation, the contained classes are never
totally dependent on the lifecycle of the container
 Composition:

It denotes strong ownership between two
classes when one class is a part of another class.
 Key words: it belongs too; it is part of; it ‘has’
14
15
Examples
 A customer has many accounts, and an
account belongs to a customer
 My pc consists of one CPU, a CPU is found
in a pc.
 A vehicle can be a sedan or a truck.
16
Dependency
 A dependency means the relation between
two or more classes in which a change in one
may force changes in the other.
 However, it will always create a weaker
relationship. Dependency indicates that one
class depends on another.
17
Download