Modelling Software Internals: Static Structure: Module 3 - Objectives Module 3 - Objectives (Continued)
Modelling Software Internals: Static Structure: Module 3 - Objectives Module 3 - Objectives (Continued)
This material has been reproduced and communicated to you by or on behalf of Monash University pursuant to Part VB of the Copyright Act 1968 (the Act). The material in this communication may be subject to copyright under the Act. Any further reproduction or communication of this material by you may be the subject of copyright protection under the Act. Do not remove this notice.
www.monash.edu.au
2
Module 3 Objectives
On completion of this session you should have a conceptual understanding of: Classes and Objects Attributes and Operations Associations and Links Multiplicities Dependencies The UML notations for UML class and object diagrams
Overview of Object-Orientation
www.monash.edu.au
Objects - Overview
object instances & classes attributes operations associations
information hiding:
restriction of the interface which an object offers to others object displays some properties in a public interface object hides others and all internal details
Objects
Entities with individual identity Individual properties, behaviours For example: A Person Object
Properties name (not necessarily unique) weight, height, address, tax file number, etc Behaviours eat, drink, groom, grow, heal, dress
Objects .
have a distinct identity even if it is indistinguishable from others of its class require no specific identifier in the object model
do include identifying attributes if they are part of the data
events or incidents
payment, EFTPOS, collision
roles
employee, analyst, insurer
interactions
employment, authentication
11
12
Objects
Object Classes
A class is derived from groups of objects Reduce complexity of a system Generalised from a few specific cases Grouped on common features of instances Special cases can invoke more specialised behaviours.
13
14
Object Classes
group objects into classes based on
common attributes common behaviour common relationships to other objects common semantics
Objects
grouping depends on the system & its purpose classification is inherently subjective
many different models may be correct. statement of assumptions becomes essential object instance - one thing
15
16
Objects
Objects
object class
- generic features shared by a set of object instances
17
18
Objects
Attributes
attributes describe properties of an object represented as the data values
e.g. CAR - make, model-year, colour, weight,
Data Process
19
20
Operations may have arguments (parameters), and could return a value. A Method is the implementation of an operation in code
21
22
[Arlow]
24
Levels of Scope
Instance Scope attributes and operations which belong to or operate on specific objects
Must be accessed via an instance Each instance has its own version of the attributes Such operations influence the particular object
Class Scope attributes and operations which belong to or operate on the whole class of objects
Can access/use without needing an instance Such attributes can be considered as shared. Such operations do not influence a particular object
Example:
A Bank object could send the message Withdraw $150 to an Account object, but only if it has a link to that account object
27
28
The Static view considers the structure/organisation of elements that make up a system
E.g. Class diagrams
Association
Associations are relationships between classes For a link to occur between two objects, there must be an association defined between their classes
A link is an instance of an association
37
38
Multiplicity
One of the constraint mechanisms of UML Multiplicity constrains the number of objects that can be involved in a particular relationship at every point in time Given as a range: min..max Examples:
1 1..5 0..1 1..* 1..3,7..9 * only one at least one, and at most five maybe one, maybe none any number, but at least one either 1, 2, 3, 7, 8, or 9, but never any other number any number, possibly none
Effect of multiplicities
Note there are 2 distinct/separate associations between Person and Bank Account.
39
40
Reflexive Associations
Class Diagram:
Navigability
Navigability indicates that objects of one class know about objects of another, and can traverse the link to reach the other object.
Indicated by arrows showing direction of permitted traversal A cross indicates that traversal in that direction is not permitted If no navigability is shown, assume navigable (although strict UML means navigability has not yet been defined for that direction)
Object Diagram:
[Source: Arlow]
41 42
43
44
Association Class
An Association Class is an association that is also a class
Defines a set of features (attributes, operations, even associations) that belong to the association
Qualified Associations
A qualified association reduces multiplicity from n-tomany to an n-to-one association, by specifying a unique object from the many by stating a key the qualifier
Means that there can only be one link between two particular objects at any given point in time.
Analysis Classes
Classes which map to real-world business concepts
FIT2005 Software Analysis, Design & Architecture
Analysis model should only contain Analysis classes not any design classes
Examples of design classes are classes that compose user interfaces, classes to manage collections, classes for network communication, etc.
48
Abstraction
The act of identifying the essential characteristics of a thing that distinguish it from all other kinds of things and omitting details that are unimportant from a certain viewpoint. Abstraction involves looking for similarities across sets of things by focusing on their essential common characteristics. An abstraction always involves the perspective and purpose of the viewer; different purposes result in different abstractions for the same things. All modelling involves abstraction, often at many levels for various purposes. The higher the level of abstraction, the less detail included.
[Rumbaugh 2005]
Abstraction
Example: An abstraction of a Cat. It just shows the typical shape of all cats. We can see that a cat has a belly, a face and two ears Things which in reality are quite different, are treated as being essentially equivalent
49
50
51
52
Finding Classes
There is no simple way to find the right classes Several techniques available:
Noun/Verb Analysis CRC Analysis RUP Stereotypes Archetype patterns (covered in a module later in semester)
Be aware that some classes may be implicit, and not found in the text.
53 54
Object diagrams
Show example possible configurations of objects and links
Project Glossary
Defines key concepts for the project Each class should be included (example template on next page) Alphabetically sorted for quick reference
57
58
Readings
Arlow: Chapters 7, 8 and 9
Attributes:
Operations:
59
60