830 likes | 1.07k Views
Sequence Enumeration A technique for specifying software intensive systems. Specifying a System. If the systems planners and customer do not Specify what is expected in all types of interactions with the system, i.e. the behavior of the system, someone else will. That someone else is most
E N D
Sequence EnumerationA technique for specifying software intensive systems
Specifying a System If the systems planners and customer do not Specify what is expected in all types of interactions with the system, i.e. the behavior of the system, someone else will. That someone else is most likely the programmer when he or she is coding the ELSE option of some IF statement. There is a very low probability that the programmer’s guesses as to the expected behavior will be what The customer expects. -- James Kowal, “Behavior Models: Specifying User’s Expectations”
Set of behaviors Requirements Specifications Program Software design is deductive Progressive reasoning from the general (user requirements to the specific (software design)
Complete, consistent, correct • “Complete” All possible stimulus histories have been mapped to their corresponding responses. • “Consistent” No history has been mapped to more than one response or one set of responses. • “Correct” The domain, range, and mapping have been properly specified in the judgement of the domain experts.
Two Sets B A b w x d a c z y e A X B = { <a,b> | a A, b B } = <a,x>, <a,w>, <a,y>, <a,z>, <b,x>, <b,w>, <b,y>, <b,z>, <c,x>, <c,w>, <c,y>, <c,z>, <d,x>, <d,w>, <d,y>, <d,z>, <e,x>, <e,w>, <e,y>, <e,z>
A relation between two sets B A b w x d a c z y e
A relation between two sets that qualifies as a function B A b x d a w c z y x
A complete function B A b x d a w c z y e
A Mapping Rule mapping rule All possible results (co-domain) All possible scenarios of use (domain) Correct results (range)
Specification Steps • Behavior • Shows relationship between input and output • State • Shows how stimulus history affects the output • Implementation • Shows how the state box information is implemented
Behavior view • Defines required external behavior for all possible circumstances of use • Receives stimulus, S, from environment and produces response, R to environment • Response depends on current stimuli and history of stimuli received so far • No knowledge of internal behavior • State free and procedure free • Mathematically, SH R
The Black Box; Behavior view Description may be mathematical or a Natural language Description of functionality SH R SH R
A calculator example • What is the effect of pressing 6 ? • It depends • Stimulus history 1 • SH: Clear 7 1 3 • S: 6 • Response: Display 7136
A calculator example • What is the effect of pressing 6 ? • It depends • Stimulus history 2 • SH: Clear 7 1 3 * • S: 6 • Response: Display 6
State view • Defines the state space • Encapsulate stimulus history as state data (procedure free) • (old state, stimulus) (new state, response) • Preserves black box specification • Several possible state implementations of the black box
Invent State Data; data view state machine S R black box ( OS, S ) ( NS, R )
State machine description of the Calculator 0..9/add digit to display 0..9/add digit to display clear +,-,*,/ store operand1 store op; clear display store operand 2 display operand1 op operand2
The Clear Box view • Defines processing required to implement the defined state behavior • Computer program that accepts stimulus, S, and, using the state data defined, produces response, R • Several possible implementations • (old state, stimulus) (new state, response), by procedure
Implementation; A Clear box view state machine R S ( OS, S ) ( NS, R ) by procedure
Sequence-based Specification Process • Stepwise construction of complete, consistent, correct specifications • All possible sequences of stimuli are enumerated systematically in strict order • Stimulus sequences of length zero, length one, length two, etc • Each sequence mapped to its correct response
Sequence-based Specification Process • Equivalent sequences identified by applying a reduction rule • Enumeration process terminates when the system has been defined completely and consistently • Makes a tractable problem of the large number of use cases arising from the combinatorial use of S/W
Steps to Defining Behavior • Tagged requirements • System boundary definition • Sequence enumeration • Canonical sequence analysis
Tagged requirements • Requirements are tagged for use in verifying the correctness of each element of subsequent work products • Methodical consideration of sequences in the enumeration process forces exposure of ambiguities and omissions in the requirements
System Boundary Definition • Determines which components are inside and outside the system • Entities outside are sources of stimuli and destination of responses • Identification begins are the atomic level • Abstractions invented to simplify the enumeration process • Used to hide well-known details • Reflect natural partitions in the product • Reduce a large set of elements to a smaller set
Sequence Enumeration • Sequences are enumerated in order of length and evaluated; • Sequences that are impossible are marked “illegal”, not considered further • Correct response traced to requirement or a “derived” requirement formed • Two sequences are “equivalent” if their responses to further stimuli are identical (only extend the shorter)
Sequence Enumeration • Enumeration stops when all sequences of a given length are illegal or equivalent to a shorter sequence • Completed enumeration is mathematically complete (all sequences mapped to a response) and consistent (each sequence mapped to only one response)
Canonical Sequence Analysis • Legal sequences in the enumeration that are not equivalent to any previous sequence are canonical • Represent unique conditions of system usage • Analysis reveals the state space for the system (at current level of abstraction) • Variables invented to encapsulate conditions in each sequence of stimuli • Can represent state data for the system
1 2 3 Example – Specification of a Security Alarm SET 4 5 6 7 8 9 CLEAR
Security Alarm Stimuli • Trip, Set, Clear are atomic stimuli • GoodDigit and BadDigit are abstractions • Represent correct and incorrect behavior of digits in a three-digit code • Abstraction serves the purpose of hiding well understood atomic level details (whether a digit is good or bad)
software system System Boundary Diagram Trip Light On Set Light Off Clear Alarm On GoodDigit BadDigit Alarm Off
Security Alarm Responses • Two additional responses used in sequence enumeration • Null response; occurs when there is no external system response • System ignoring stimuli • System accumulating stimuli • Illegal response; sequence is impossible (e.g. stimuli presented before invocation)
Sequence Enumeration Carry to Next level
Sequence Length Five Each entry has an equivalence – Therefore we can stop enumerating!!!
Sequence-based Specification Process • A sequence represents a scenario of use • Sequence enumeration reveals; • Possible scenarios • Impossible scenarios • Intended uses • Erroneous use • Reducible sequences • Irreducible sequences
Irreducible Sequences • Canonical sequences; basis for precise specification of software behavior; • Mathematically correct; literal enumeration of sequences – all combinations mapped to response • Consistent; orderly enumeration of sequences ensures that a given scenario of use only appears once • Traceable correct; every element of sequence based specification traced to requirements origin
Enumeration complete • Every scenario has been mapped to a response (complete) • Every scenario has been mapped to only one response (set), (consistent) • Requirements can now confirm that assumptions and derived requirements are correct
Canonical Sequence Analysis • State data encapsulates and retains the components of stimulus history that must be preserved for the system to produce the correct response • Canonical sequence; sequences that are not equivalent to any previous sequence • Invent state variables to represent the canonical sequences
Canonical S tate Value Value sequence Variables before after current current stimulus stimulus Empty N/A S; The user has Device OFF ON pressed the Set button to activate the device S T; The device Device ON ON has been set and the trip Alarm OFF ON signal has occurred, setting off the alarm S B; The device Device ON ON has been set the user has Code NONE ERROR entered an invalid digit