Chapter 5 – System Modeling
Lecture 2
Chapter 5 System modeling 1
3. Structural Models
● Structural models of software display the organization
of a system in terms of the components and their
relationships.
● Structural models may be static models, which show the
structure of the system design, or dynamic models,
which show the organization of the system when it is
executing.
● Structural models are created when discussing and
designing the system architecture.
Chapter 5 System modeling 2
Class Diagrams
● Class diagrams are used when developing an object-oriented
system model to show the classes in a system and the
associations between these classes.
● An association is a link between classes that indicates that
there is some relationship between these classes.
● When you are developing models during the early stages of
the software engineering process, objects represent
something in the real world, such as a patient, a
prescription, doctor, a device, etc.
● We have spoken in terms of 'nouns' or 'things.'
Chapter 5 System modeling 3
UML classes and association
Here we are also showing multiplicity: one object of type Patient is related to one object of type Patient Record
Chapter 5 System modeling 4
Classes and Associations in the MHC-PMS
Notice that this is s Static Model
Notice the associations are labeled
Notice the multiplicity.
Chapter 5 System modeling 5
The Consultation Class (There are all kinds of
classes: domain / entity classes; software
classes, and many 'levels' of these!
This is a high level class – perhaps
a first or second cut at class definition.
Notice much is missing, such as
parameters, returns, etc. from the
methods.
These are ‘software classes’ because
they contain methods (that is, how the
attributes will be used / manipulated.)
Finer levels of granularity are needed
to address the shortcomings of this
class.
But this is a very good way to start your
analysis and class definition, especially
when trying to develop classes from
use cases, where nouns (Consultation)
and verbs (new, prescribe….) will be
found in the use case itself.
Chapter 5 System modeling 6
Generalization
● Generalization is an everyday technique that we use to
● Rather than learn the detailed characteristics of every entity that
we experience, we place these entities in more general classes
(animals, cars, houses, etc.) and learn the characteristics of these
classes.
● This allows us to infer that different members of these classes
have some common characteristics e.g. squirrels and rats are
rodents.
● In programming, we refer to this as 'inheritance.'
● Base class and derived classes, or super class
and derived class.... parent and child.... many terms for
capturing these important relationships.
Chapter 5 System modeling 7
Generalization
● In modeling systems, it is often useful to examine the classes in a system to
see if there is scope for generalization.
● In object-oriented languages, such as Java, generalization is implemented
using the class inheritance mechanisms built into the language.
● In a generalization, the attributes and operations associated with higher-level
classes are also associated with (inherited by) the lower-level classes.
● The lower-level classes are subclasses inherit the attributes and operations
from their superclasses. These lower-level classes then add more specific
attributes and operations.
Chapter 5 System modeling 8
Relationships: Generalization
A relationship among classes where one class shares the
structure and/or behavior of one or more classes
Defines a hierarchy of abstractions in which a subclass
inherits from one or more superclasses
Single inheritance
Multiple inheritance
Generalization is an “is-a-kind of” relationship, or simply,
“is_a” relationship.
Example: Single Inheritance
One class inherits from another
Account
balanc
Superclass n
e am
ne umbe
(parent) r
Withdraw(
)CreateStatement(
) Generalization Relationship
Subclasses inherit both
attributes and methods from
base (parent) class.
Checkin Saving
g s
Subclasses Withdraw( GetInterest(
) )Withdraw(
)
Descendents
Example: Multiple Inheritance
A class can inherit from several other classes
FlyingThin Animal
g
multiple
inheritance
Airplan Helicopte Bird Wolf Hors
e r e
Use multiple inheritance only when needed, and
always with caution !
What Gets Inherited?
A subclass inherits its parent’s attributes, operations,
and relationships
A subclass may:
Add additional attributes, operations, relationships
Redefine inherited operations (use caution!)
Common attributes, operations, and/or relationships
are shown at the highest applicable level in the
hierarchy
Inheritance leverages the similarities among classes
Example: What Gets Inherited
GroundVehicle
owner Person
Superclass weigh
(parent) tlicenseNumbe 0..* 1
r
register( )
generalization
Car Truck Trailer
Subclass size tonnage
getTax( )
Object class aggregation models
● An aggregation model shows how classes that are
collections are composed of other classes.
● Aggregation models are similar to the part-of relationship
in semantic data models.
Chapter 5 System modeling 14
Relationships
Association
Aggregation
Composition
Dependency
Generalization
Realization
Relationships: Association
Models a semantic connection among classes
Association Name
Professor Works for University
Association
Role Names
Class University
Professor
Employee Employer
Relationships: Aggregation
A special form of association that models a whole-part
relationship between an aggregate (the whole) and
its parts
Whole Part
Student Schedule
Aggregation
This is sometimes
called a ‘has_a’
relationship
Relationships: Composition
A form of aggregation with strong ownership and
coincident lifetimes
The parts cannot survive the whole/aggregate
Whole Part
Student Schedule
Aggregation
Association: Multiplicity and Navigation
Multiplicity defines how many objects participate in a
relationships
The number of instances (that is, ‘objects’) of one
class related to ONE instance of another class
Specified for each end of the association
Associations and aggregations are bi-directional by
default, but it is often desirable to restrict navigation to
one direction
If navigation is restricted, an arrowhead is added to
indicate the direction of the navigation
Association: Multiplicity
Unspecified 1
Exactly one
Zero or more (many, unlimited) 0..*
*
One or more 1..*
Zero or one
Specified range 0..1
Multiple, disjoint ranges 2..4
2,
4..6
Example: What Gets Inherited
GroundVehicle
owner Person
Superclass weigh
(parent) tlicenseNumbe 0..* 1
r
register( )
generalization
Car Truck Trailer
Subclass size tonnage
getTax( )