Professional Documents
Culture Documents
Model
Dr Kristin Stock
Where
are we
up to?
Behavioural
models next time.
Outline
More on class diagrams:
Different types of associations
Association classes
Classes
In a class diagram, the objects in the system
(concepts in the conceptual model) are
represented as classes.
A class is a group of individual objects.
E.g. the class road, person, customer, cake.
In UML, we create class diagrams to show the
classes involved in a system, and their
interactions.
Challenge Questions
Is it important that the business track this class?
e.g. Do you actually keep track of your customers?
Attributes
Characteristics of a class.
Often in a textual descriptions, they
are adjectives (the red car, the
chocolate cake, the fast delivery).
It is not always clear whether
something should be modelled as
an attribute or a class:
Make it a class if it has other
attributes or operations of its own,
otherwise an attribute.
camelCase, singular
Attribute Appendages
Attributes can be derived
Preceded with a slash (/)
e.g., age is derived from date of birth
Visibility of an attribute:
Restricts access to attributes to ensure consistency
Public attributes (+): visible to all classes
Private attributes (-): visible only to an instance of the class in which
they are defined
Protected attributes (#): visible only to an instance of the class in
which they are defined and its descendants
Example
House
Street
+streetNumber
-houseType
-buildDate
+/age
-owner
#rebuild
#renovate
DetachedHouse
is in
0..*
streetType
oneWay
suburb
Operations
Operation Types
Common operations are not shown
Create or delete an instance
Return or set a value
Types of operations:
Constructorcreates an object
Querymakes information about the state of an object
available
Updatechanges values of some or all of an objects attributes
Destructordeletes or removes an object
Relationships
Associations between classes.
Indicate some link or dependency.
There are many kinds of associations, usually they
can be described with a verb (has, contains, is part
of, etc).
Should be able to read through the diagram with
classes and associations.
is in
house
is in
street
city
Example
House
streetNumber
houseType
buildDate
owner
rebuild
renovate
Street
is in
0..*
streetType
oneWay
suburb
Multiplicities
Department
1
Child
Zero or more:
An employee has zero to
many children
Employee
One or more:
A boss is responsible for
one or more employees
0..*
Boss
1
Exactly one:
A department has one and
only one boss
Employee
1
Boss
1..*
Multiplicity Indicator
Meaning
0..1
Zero or one
0..*
Zero or more
1..*
One or more
Exactly n, as in 4
a..b
Types of Relationships in
UML
Dependency
Association:
Generalisation
Aggregation
Composition
Dependencies
Indicates that one class uses the other.
This is the most general type of relationship
better to be more specific if possible, with an
association (including name and multiplicity),
generalisation, composition or aggregation.
More common in some other types of diagrams
Associations
Binary Associations
An object of one class is related to an object (or objects)
of a different class
e.g. each Case object is associated with Payment
objects
Example
House
streetNumber
houseType
buildDate
owner
Street
is in
0..*
streetType
oneWay
suburb
rebuild
renovate
intersects with
What kind of multiplicity might the
intersects with association have?
Redundant Associations
A shortcut that associates two classes that have
an indirect association is redundant
These are usually best removed
Unless they specify a different business rule to the
indirect association
Customer
is billed
Invoice
purchases
is for
Product
Generalization Associations
Generalisation means:
is a
is a type of
subclass
subtype
Example
House
Street
+streetNumber
-houseType
-buildDate
+/age
-owner
is in
0..*
streetType
oneWay
suburb
subtypes
inherit
attributes
and
operation
s
#rebuild
#renovate
ResidentialCollec
tor
DetachedHouse
ResidentialAcce
ss
SuburbanCollec
tor
Modeling Generalization
Why model generalization?
Reduced redundancy in the requirements
Generalized classes can be reused for future specialized
classes
Rules:
The specialized class inherits all the attributes, operations
and relationships of the generalized class
The specialized class may add attributes, operations and
relationships
The specialized class may have polymorphic methods
Multiple inheritance is possible (but not supported by all
languages)
FundAccount
and
CashAccount
would inherit
all the features
of
InternalAccoun
t
InternalAccount
FundAccount
Generalized
Class
CashAccount
Specialized
classes
Inventory
Product
Company
Order
LineItem
VehiclePart
Composite Structure
Diagram
Another way of showing composition from UML 2
This example shows component parts in a vehicle
whole
Vehicle
attached to
Wheel
2
Axle
1
Generalisation vs Aggregation vs
Composition vs Association
For generalisation, it must make sense to say x is
a type of y
For aggregation and composition, it must make
sense to say x is a part of y
If x can survive without y, it is aggregation,
otherwise composition.
Which is which?
Leg Body
Knee Leg
Leg Limb
Kneecap Knee
Cracked Kneecap
Kneecap
Cyclone Natural
Disaster
Cyclone Bush Fire
Cyclone Casualties
Cyclone Storm
Soldier - Army
Generalisation
Association
Aggregation
Composition
Association Classes
Common in many-to-many relationships
Used when attributes about the relationship between two
classes needs to be recorded
Students are related to courses; a Grade class provides an attribute
to describe this relationship
Illnesses are related to symptoms; a Treatment class provides an
attribute to describe this relationship
Example
House
Street
+streetNumber
-houseType
-buildDate
+/age
-owner
#rebuild
#renovate
is in
0..*
1..3
streetType
oneWay
suburb
HouseInStreet
What
might
go
here?
Object Diagrams
Class diagrams with instantiated classes
Example: instead of a Doctor class, create an
actual doctor, say Dr. Smith
Place values into each attribute
Account
Transfer
debited from
+sendingAccount
debited from
fromAccount:Account
credited to
toAccount:Account
Products and
Services
Events/
Transactions
CallReturn
Application Schema
HDM_Surv eys
+ CoreElements
+ SurveyObservations
+ FeatureTypeCatalogue
import
import
+ MetadataProfile
+ SurveyPlans
import
Application Schema
HDM_PlaceNames
+ HeightDatum
import
+ DisplayPoint
import
+ PlaceName
Application Schema
HDM_Geodesy
import
import
Application Schema
HDM_Topography
Application Schema
HDM_StreetAddresses
+ GeneralFeature
Application Schema
HDM_RightsRestrictionsResponsibilities
+ Address
access
+ AddressGeocode
+ AnticipatedLifecycleStage
+ GeocodeType
+ Interest
+ Easement
+ TopographicFeature
+ InterestRelationship
+ TopoPointElement
+ InterestRelationshipType
+ TopoSimpleCurveElement
+ InterestType
import
+ TidalInterface
+ TopoCompCurveElement
+ InterestHolderType
+ CoexistingEstate
+ TidalHeight
+ Road
+ Tank
+ InterestHolder
Application Schema
HDM_Cadastre
+ TidalGaugeMetadata
+ Railway
+ RouteSegment
+ InterestGeometry
access
+ InlandWaterFeature
+ Route
+ InterestFunction
+ CoexistingEstateType
import
Application Schema
HDM_TidalRealm
+ EarthSurface
+ TopoSurfaceElement
+ LegalDocument
+ Utility
+ LifecycleStage
+ RelationshipTypeExists
+ PrimaryEstate
+ PrimaryEstateType
+ SecondaryInterest
import
+ SecondaryInterestLifecycle
import
+ SecondaryInterestType
import
+ Title
+ CadastralLite
+ Property
import
Application Schema
HDM_Nativ eTitle
+ IndigenousLandUseAgreements
+ NativeTitleFutureActs
Application Schema
HDM_Admininstrativ eInterests
+ NativeTitleApplications
+ AdmininstrativeInterest
+ NativeTitleDeterminations
+ AdministrativeInterestType
+ NativeTitleTenureOpinions
Application Schema
HDM_Env ironmentalInterests
+ EnvironmentalInterest
+ EnvironmentalInterestType
pkg PackageDependencies
Application Schema
HDM_RightsRestrictionsResponsibilities
Leaf
Nativ eTitleApplications
+ AnticipatedLifecycleStage
+ Interest
+ ApplicationDocument
+ InterestFunction
+ ApplicationLifecycle
+ InterestGeometry
+ ApplicationType
+ InterestHolder
+ InterestHolderType
+ RegisterOfNativeTitleClaimsRegistrationLifecycle
+ Application
Leaf
IndigenousLandUseAgreements
import
+ InterestRelationship
+ InterestRelationshipType
import
+ IndigenousLandUseAgreementLifecycle
+ IndigenousLandUseAgreement
+ Surrender
+ InterestType
+ LegalDocument
+ LifecycleStage
+ RelationshipTypeExists
access
Leaf
Nativ eTitleDeterminations
import
(from ICSM)
+ DeterminationType
+ NationalNativeTitleRegisterLifecycle
import
import
+ Determination
+ NativeTitleInterest
+ NativeTitleAbsence
Leaf
Nativ eTitleFutureActs
+ DeterminedNativeTitleRight
+ DeterminationOutcome
+ FutureActLifecycle
access
+ FutureAct
+ RightToNegotiate
+ CompulsoryAquisition
Leaf
Nativ eTitleTenureOpinions
+ AssessmentOrExtinguishmentCategory
+ NativeTitleExtinguishmentOpinionLifecycle
+ NativeTitleExtinguishmentOpinion
Derived Attributes
Can be derived from other parts of the model
Important not to store values that should be calculated to
avoid data integrity problems
e.g. an age attribute should be derived
Attribute Notation
The full notation for an attribute in UML follows the form
attributeName:attributeType [multiplicity] = default
Attribute Types
These may be any of the following:
User defined value type
e.g. PhoneNumber
A generic, complex data type (has its own attributes)
Not an association with a business object (entity class)
A unit of measurement
e.g. Kilometre (spelling to match coding guidelines!)
Can be assumed at the analysis stage
Will need to be defined more specifically at design time
Boolean
True/False, yes/no
Character
A single (Unicode) character
String
Text any string of characters
Date / Timestamp
A specific date and time
158.225 Systems Analysis and Design 2014
51
Meta-Attributes
Attributes of attributes
Verification rules and other attribute properties
Meta-Attribute Examples
Required (not null)
Does the attribute always have to have a value?
Uniqueness
Does an attribute have to have a unique value, like a primary key?
Accuracy
e.g. rounding of floating point values
Length
e.g. the maximum size of a text (String) attribute
Attributes of a Class
BankAccount
Derived attribute
accountNumber : Integer
accountName : String {not null}
balance : Money = 0
/availableBalance : Money
overdraftLimit : Money
openedOn : Date
constraint
Default value
Is It An Attribute?
If a concept is not represented as a number
or text in the real world, it is probably a
class, not an attribute
Are these all attributes?
Qualification
level : Integer
name : String
institution : String
Operations
An activity that pertains to a class and is consistent
across use cases
e.g. a CashAccount class might have a WithdrawFunds
operation
Operation Notation
The full notation for an operation in UML follows the form
operationName(argument1:argument1Type,
argument2:argument2Type,) : ReturnType
Operation Examples
Examples of operations might be
withdrawCash(amount:Money)
getAge() : Integer
calculateInterest(principal:Money, Interest:Double,
Period:Integer) : Money
getEnrolmentDetails(id : StudentID) : Enrolment
isEnrolled() : Boolean
Lookup Tables
We create lookup tables for controlled lists of
values for an attribute
e.g. sets of codes that are used
Users can add/edit the list themselves.
But:
If overused, they are meaningless because people
just add codes for everything
If underused, makes search more difficult, data is
messy and difficult to analyse
INSPIRE
INSPIRE
European Directive.
http://inspire.ec.europa.eu/
Develops standards and processes to share data
across 34 themes important for environmental
management, among 28 member states.
Protected Sites
Convened thematic experts from around
Europe.
Had workshops to identify relevant classes
and attributes.
Also several existing domain models in use
around Europe.
Summary
Structural Models
Classes, Attributes, Operations, Associations.
More detail on these next time.