October 2004 J. B. Wordsworth J4ISDSPE 1
Information Systems Development
Specification
October 2004 J. B. Wordsworth J4ISDSPE 2
ObjectivesDescribe the structure of a specification document for the API process.
Understand the role of sets, state, invariant, initialisation, and functional interface in the specification of an API.
Understand what is meant by validating an initialisation.
Describe the format and significance of the parts of the abstract specification of an operation.
Use pseudocode to explain the use of an API for solving application problems.
Use a use case definition to validate a pseudocode implementation of a use case.
October 2004 J. B. Wordsworth J4ISDSPE 3
Specification document• Specification of the API
– Specify the sets, state, invariant, and initialisation.– Validate the initialisation.– Specify the functions of the API.
• Syntax, inputs, precondition, postcondition, outputs
– Validate the functions.
• Justification of the API – Use pseudocode to illustrate the use cases.– Validate the pseudocode by comparing it with the use
case specifications.
October 2004 J. B. Wordsworth J4ISDSPE 4
Abstract specifications
• Precise definition of state and function
• Verification and validation opportunities
• Not biased towards any implementation
October 2004 J. B. Wordsworth J4ISDSPE 5
Sets
• Identify the different types of information:– Checkout numbers– Line numbers– Prices– Descriptions– Stock levels
• Used to build up a data model of the state.
October 2004 J. B. Wordsworth J4ISDSPE 6
State• Subsets
– checkout_set – line_set
• Functions – price_function– stock_function– description_function– bill_line_function
• Relations• Sequences• Numbers• Strings
October 2004 J. B. Wordsworth J4ISDSPE 7
CheckoutNumber Sequence of LineNumber
c1 c2
c3c4
c5
c6 c7
c8< >
<n1>
<n2>
<n1, n2>
<n2, n1>
checkout_set
October 2004 J. B. Wordsworth J4ISDSPE 8
n1 n2
line_set
LineNumber
Integer
591998
20
-5
0
Description
d5d6
d7
d4
d3d2
d1
October 2004 J. B. Wordsworth J4ISDSPE 9
Invariants
• (B1) The domain of description_function is line_set.
• (B2) The domain of price_function is line_set.
• (B3) The domain of stock_function is line_set.
• (B4) The domain of bill_line_function is a subset of checkout_set.
• (B5) The range of every sequence in the range of bill_line_function is a subset of line_set.
October 2004 J. B. Wordsworth J4ISDSPE 10
Initialisation
• checkout_set is empty.
• line_set is empty.
• description_function is empty.
• price_function is empty.
• stock_function is empty.
• bill_line_function is empty.
October 2004 J. B. Wordsworth J4ISDSPE 11
Operations
• Syntax: – Output-value-list <-- function ( input-value-list )
• Precondition– Assumptions about the inputs and the current state
• Postcondition– partitioned according to situation
• Validation– Check that the change of state respects the invariants.
October 2004 J. B. Wordsworth J4ISDSPE 12
c1
c2
c3
c4
c5
c6 c7
c1
c2
c3
c4
c5
c6 c7
CheckoutNumber
checkout_set
CheckoutNumber
checkout_set
October 2004 J. B. Wordsworth J4ISDSPE 13
CheckoutNumber Sequence of LineNumber
c1
c2
c3 c4c5
c6 c7
c8 < >
<n1><n2>
<n1, n2><n2, n1>
CheckoutNumber Sequence of LineNumber
c1
c2
c3 c4c5
c6 c7
c8 < >
<n1><n2>
<n1, n2><n2, n1>
October 2004 J. B. Wordsworth J4ISDSPE 14
CheckoutNumber Sequence of LineNumber
c1
c2
c3 c4c5
c6 c7
c8 < >
<n1><n2>
<n1, n2><n2, n1>
CheckoutNumber Sequence of LineNumber
c1
c2
c3 c4c5
c6 c7
c8 < >
<n1><n2>
<n1, n2><n2, n1>
October 2004 J. B. Wordsworth J4ISDSPE 15
A pseudocode function
BEGIN status <-- addCheckout (checkout_number) ; IF status = 0 THEN write "Checkout added." ELSE write "Checkout number already in use." END END