Object-oriented Design - PowerPoint PPT Presentation

About This Presentation
Title:

Object-oriented Design

Description:

... decreasing then the controller awaits further signals, otherwise the controller ... The controller awaits further signals Andrew Ireland. Software Design F28SD2 ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 33
Provided by: CalumW8
Category:

less

Transcript and Presenter's Notes

Title: Object-oriented Design


1
Object-oriented Design
Andrew Ireland School of Mathematical Computer
Sciences Heriot-Watt University Edinburgh
2
Outline
  • Characteristics of OOD
  • Basic Ingredients of OOD Methods
  • An example of OOD

3
Characteristics OOD
  • Abstraction Objects provide a useful and natural
    abstraction for many engineered artefacts and
    real-world systems
  • Encapsulation Hiding within an Object those
    details which are not essential to an abstraction
  • Modularity Separation of concerns (often merged
    with encapsulation)
  • Hierarchy Ranking between abstractions class
    structure, includes,

4
Many OOD Methods!
  • The Booch Method
  • The Coad Yourdon Method
  • The Rambaugh Method
  • The Wirfs-Brock Method

5
OOD Common Ingredients
  • Identification of objects (classes), e.g.
  • Use cases
  • Grammatical analysis
  • Class-Responsibility-Collaborator modelling
  • Identification of static perspective, e.g.
  • Class diagrams
  • Identification of dynamic perspective, e.g.
  • Communication diagrams
  • Activity diagrams
  • State machine diagrams

6
Grammatical Analysis
  • Nouns suggest objects
  • Verbs suggest operations
  • Example
  • An ATM will allow a customer to withdraw funds
    and display their account balance. Account
    details are held centrally. An account can be
    credited or debited. In addition, the bank can
    request for an account to be frozen at anytime.

7
Grammatical Analysis
  • Nouns suggest objects
  • Verbs suggest operations
  • Example
  • An ATM will allow a customer to withdraw funds
    and display their account balance. Account
    details are held centrally. An account can be
    credited or debited. In addition, the bank can
    request for an account to be frozen at anytime.

8
Grammatical Analysis
ATM
customer
account
bank
withdraw display
credit debit freeze
Note that the analysis only provides a starting
point
9
Class-Responsibility-Collaborator
  • Class-Responsibility-Collaborator (CRC) modelling
    provides a simple mechanism for identifying and
    organizing classes
  • A CRC model contains a collection of index
    cards
  • Class name
  • Class type, e.g. device, property, role,
  • Class characteristics, e.g. atomic, tangible,
    persistence, integrity, concurrent,
  • Responsibilities, i.e. attributes operations
  • Collaborations, i.e. where interaction with other
    classes is required

10
Guidelines for Responsibility
  • System intelligence should be evenly distributed
    promotes cohesion
  • Each responsibility should be stated as generally
    as possible promotes the use of inheritance and
    polymorphism
  • Information and the behaviour is related to it
    should reside within the same class promotes
    encapsulation/modularity

(WIR 90)
11
Guidelines for Collaborations
  • A responsibility that can not be met internally
    (attributes operations) will require
    collaboration with other classes
  • Identify generic relationships between classes
  • is-part-of relationship, e.g.
  • brake is-part-of control-system
  • has-knowledge-of, e.g.
  • ATM has-knowledge-of customer-credit-limit
  • depends-upon, e.g.
  • If A provides C with X and C provides B with X
    then B depends-upon A

(WIR 90)
12
Automatic Train Protection (ATP)
13
Automatic Train Protection (ATP)
  • The Ladbroke Grove rail disaster (London) took
    place on Oct 5, 1999
  • 31 people were killed 520 injured as a result
    of a 2 train collision
  • The collision was caused by a Signal Passed At
    Danger (SPAD)
  • An ATP system would have prevented this disaster

14
ATP Requirements
  • The ATP controller is switched on via the
    drivers control panel
  • The ATP controller is switched off via the
    control panel, and results in the brakes being
    activated
  • When a train passes a track-side signal, signal
    sensors mounted on the train relay the signal
    aspect (proceed, caution, danger) to the
    controller
  • If a proceed signal is reported then no action
    takes place
  • If a caution signal is reported then an audio
    alarm is enabled. If the driver presses an
    acknowledgement button on the control panel
    within 5secs then the alarm is disable, otherwise
    a timeout occurs and the controller activates the
    trains brakes. If the alarm is disabled in time
    then the controller assesses the trains speed via
    speed sensors. If the trains speed is decreasing
    then the controller awaits further signals,
    otherwise the controller activates the trains
    brakes
  • If a danger signal is reported then the
    controller activates the brakes

15
ATP Requirements
  • Sensing will be performed by majority vote, e.g.
    if 2 signal sensors report caution, while the
    remaining sensor reports proceed, then a
    caution signal will be reported to control

Sensor 1
Calculate majority
Sensor 2
caution
signal
Sensor 3
16
Object Identification
17
Use Cases
ATP
start system
driver
stop system
ltltincludesgtgt
auto brake
track-side signal sensors
ltltextendsgtgt
react to sensors/ driver
enable/disable alarm
speed sensors
ltltincludesgtgt
18
Use Case Specification
  • USE CASE ATP
  • GOAL React to caution signal when speed
    deceasing
  • ACTORS Driver, Track-side Signal Sensors, Speed
    Sensors
  • MAIN SUCCESS SCENARIO
  • The controller is informed of a signal aspect
  • If a caution signal is reported then the
    controller enables the alarm
  • If the driver presses the acknowledge (alarm)
    button within 5secs then the controller will
    disables the alarm
  • The controller then requests the trains speed
    from the speed sensors, if the speed is
    decreasing then no action is taken
  • EXTENSIONS
  • 3a. If driver does not acknowledge alarm with
    5secs then enable automatic brakes
  • 4a. If speed is not decreasing then enable
    automatic brakes

19
Grammatical Analysis
  • The ATP controller is switched on via the
    drivers control panel
  • The ATP controller is switched off via the
    control panel, and results in the brakes being
    activated
  • When a train passes a track-side signal, signal
    sensors mounted on the train relay the signal
    aspect (proceed, caution, danger) to the
    controller
  • If a proceed signal is reported then no action
    takes place
  • If a caution signal is reported then an audio
    alarm is enabled. If the driver presses an
    acknowledgement button on the control panel
    within 5secs then the alarm is disable, otherwise
    a timeout occurs and the controller activates the
    trains brakes. If the alarm is disabled in time
    then the controller assesses the trains speed via
    speed sensors. If the trains speed is decreasing
    then the controller awaits further signals,
    otherwise the controller activates the trains
    brakes
  • If a danger signal is reported then the
    controller activates the brakes

20
Grammatical Analysis
  • The ATP controller is switched on via the
    drivers control panel
  • The ATP controller is switched off via the
    control panel, and results in the brakes being
    activated
  • When a train passes a track-side signal, signal
    sensors mounted on the train relay the signal
    aspect (proceed, caution, danger) to the
    controller
  • If a proceed signal is reported then no action
    takes place
  • If a caution signal is reported then an audio
    alarm is enabled. If the driver presses an
    acknowledgement button on the control panel
    within 5secs then the alarm is disable, otherwise
    a timeout occurs and the controller activates the
    trains brakes. If the alarm is disabled in time
    then the controller assesses the trains speed via
    speed sensors. If the trains speed is decreasing
    then the controller awaits further signals,
    otherwise the controller activates the trains
    brakes
  • If a danger signal is reported then the
    controller activates the brakes

21
Grammatical Analysis
  • The ATP controller is switched on via the
    drivers control panel
  • The ATP controller is switched off via the
    control panel, and results in the brakes being
    activated
  • When a train passes a track-side signal, signal
    sensors mounted on the train relay the signal
    aspect (proceed, caution, danger) to the
    controller
  • If a proceed signal is reported then no action
    takes place
  • If a caution signal is reported then an audio
    alarm is enabled. If the driver presses an
    acknowledgement button on the control panel
    within 5secs then the alarm is disable, otherwise
    a timeout occurs and the controller activates the
    trains brakes. If the alarm is disabled in time
    then the controller assesses the trains speed via
    speed sensors. If the trains speed is decreasing
    then the controller awaits further signals,
    otherwise the controller activates the trains
    brakes
  • If a danger signal is reported then the
    controller activates the brakes

22
Classes
Alarm
Panel
SigSen
enable disable
Brakes
SpdSen
Ctrl
on off ack sig_update time_out
activate
read_speed
23
CRC for ATP Controller
Class name Ctrl Class type device Class
characteristics tangible, atomic
  • Responsibilities
  • decide if alarm should be
    enabled/disabled
  • maintain record of speed
  • decide if brakes should be activated
  • manage timeouts
  • Collaborators
  • signal sensor
  • speed sensor
  • alarm
  • brakes

24
Static Perspective
25
Class Diagrams
Alarm
Panel
SigSen
disable
sig_update
enable
on
off ack
activate
read_speed
Brakes
SpdSen
Ctrl
26
Class Diagrams
Sensor
  • calc_majority
  • read_sensors

SigSen
SpdSen
- read_sensors
- read_sensors
27
Dynamic Perspective
28
Sequence Diagrams
SigSen
Panel
Alarm
SpdSen
Ctrl
Brakes
1. pass_signal
1.1 sig_update
1.2 enable
2 press_ack_button
2.1 ack
2.1.1 disable
2.1.2 read_speed
Caution signal received along with an
acknowledgement and a speed reduction
2.1.3 chk_speed
29
Sequence Diagrams
SigSen
Panel
Alarm
SpdSen
Ctrl
Brakes
1 pass_signal
1.1 sig_update
1.2 enable
2 press_ack_button
2.1 ack
2.1.1 disable
2.1.2 read_speed
Caution signal received along with an
acknowledgement but, no speed reduction
2.1.3 chk_speed
2.1.4 activate
30
Communication Diagrams
1 pass_signal
SpdSen
SigSen
2.1.2 read_speed
1.1 sig_update
1.2 enable
2.1.1 disable
Alarm
Ctrl
2.1 ack 3.1 on 4.1 off
2.14 activate
2.13 chk_speed
Panel
Brakes
2 press_ack_button
3 press_on_button
4 press_off_button
31
State Machine Diagrams
proceed signal
speed check speed decreasing
caution signal
driver ack
proceed state
caution state I
caution state II
time_out
speed check speed not decreasing
danger signal
danger state
32
Summary
  • Learning outcomes
  • Basic ingredients of an OOD method
  • Object identification
  • Structural perspective
  • Dynamic perspective
  • Recommended reading
  • D. Budgen, Software Design, Addison-Wesley 2003
  • I. Sommerville, Software Engineering,
    Addison-Wesley 2007
  • R. Wirfs-Brock, B. Wilkerson, L. Weiner,
    Deigning Object-Oriented Software,
    Prentice-Hall 1990
Write a Comment
User Comments (0)
About PowerShow.com