dr. andy seddon staffordshire university school of computing code design (the use of pseudo code for...

25
Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Upload: hilary-campbell

Post on 01-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Code Design

(The use of pseudo codefor Elementary Process Descriptions)

Page 2: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

What are mini specifications?

A process descriptor provides a detailed explanation of the internal processing policy of a

functional primitive that transforms input data into output data

Page 3: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Documenting a process

Various means and tools include pseudo code (structured English) decision trees decision tables action diagrams mathematical algorithms

Page 4: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Documenting the policy

Need only specify the processing policies necessary to transform data or simply provide data.When stating policy, only specify what rather than how with regard to processing data.Try to specify data transformations from the user’s vantage point.

Page 5: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

A process descriptor...

must exist for every functional primitive in a DFD

must state the ways in which data flowing into the process are transformed into output flows

must state the policy that governs the transformation, not the method to do so

should seek to control redundancy should use a small set of constructs

Page 6: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Additional process descriptor information

As well as logic the process descriptor should mention

processor requirements security requirements time requirements processing requirements performance requirements safety requirements

Page 7: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Specifying logic (1)

Sequence

Repetition

A B

A

A

Do While Repeat Until

Page 8: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Specifying logic (2)

Selection

A

A B A CB

IF IF THEN ELSE CASE

Page 9: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Pseudo code/structured English

Programming Design Language (PDL) by Caine and Gordon, a ‘pidgin’ language that

uses the vocabulary of one language (i.e. English) and the overall syntax of another (i.e. a structured programming language)

Tom DeMarco defines structured English asa specification language that uses a limited

vocabulary and a limited syntax

Page 10: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Structured English vocabulary

The vocabulary consists of imperative English-language verbs terms defined in the data dictionary certain reserved words for logic formulation

The structured English minimal set can now be defined

Page 11: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Syntax and variables

Data flows, data stores, common processing routines: upper case hyphenated words (define in data dictionary)

Local variables: upper case hyphenated words (do not define in data dictionary)

Commands, primitive functions, sources/sinks: lower case first letter capitalised

Prepositions/verbs: lower case

Page 12: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Assignment statements

Assign values to single variables with

VARIABLE = Value / Literal / Expression

VARIABLE Value / Literal / Expression

Set VARIABLE to Value / Literal / Expression

Compute VARIABLE = Expression

Page 13: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Operators (1)

Arithmetic expressions Results are numeric Operators are: addition (+)

subtraction (-)multiplication (*)division (/)exponentiation (**)

Page 14: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Operators (2)

Boolean expressions Results are either True or False Logical operators And, Or and Not Relational operators: less than (<)

less than or equal (<=)equal (=)not equal (< >)greater than (>)greater than or equal (>=)

Page 15: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Sequence of execution

All commands are intended to be executed in a forward sequential order as written unless the logic or command indicates otherwise.

It is helpful to establishindentation rules to helpidentify computationalunits.

Page 16: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Repetition statements (1)

Do While statement

While condition Do

:

statements

:

EndWhile

condition

statements

False

True

Page 17: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Repetition statements (2)

Repeat Until statement

Repeat

:

statements

:

Until condition

condition

statements

TrueFalse

Page 18: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Decision statements

If...Then...Else

If condition then

:

statements1

:

else

:

statements2

:

endif

condition

statements1 statements2

True False

Page 19: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Input/output statements

Various ways of designating flow of data into and out of a functional primitive process are acceptable

Input OutputAccept SendGet PutRead Write or Print

Page 20: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

File manipulation

These commands not absolutely necessaryCreate data-entry in data-store-name

Delete data-entry from data-store-nameSearch data-store-name for conditionLocate data-element(s) in data-store-name for conditionMatch data-element-1 to data-element-2 in data-store-nameMerge data-store-name-1 into data-store-name-2

Page 21: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Case statements

Allows several alternative sets of processing logic to be distinguished without the need for multiple If..Then..Else statements

Case 1 (condition)statements1

Endcase 1Case 2 (condition)

statements2Endcase 2:Else statements (n+1)Endcases

Page 22: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Common processing routines (1)

Defined in the data dictionary Can be called more than once in the system CALL statement lists the parameters needed

by the called process to perform its tasks. The calling process receives the output data

elements from the called routine

CALL common-processing-routine-name (parameter list)

Page 23: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Common processing routines (2)

7.1.1Validate currencyexchange

7.1.3Calculatecommission fee

7.1.2Calculate currencyvalue

Determine currentexchange rate

Currency Type

ExchangeRate

Currencydetails

Converted currency

Exchange request

Total currency

Page 24: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Common processing routines (2)

Calculate Currency Exchange descriptor 7.1.2

Input Currency details from Validate currency exchange:

Call Determine current exchange rate(Currency Type, Exchange Rate)

Multiply Currency Value by Exchange Rate:

Output Total currency to Calculate commission feeStop

Page 25: Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)

Dr. Andy Seddon

StaffordshireUNIVERSITY

Schoolof

Computing

Suspension, termination & comments

It may be necessary at times to halt processing temporarily:

– to allow a passage of timeOutput Request-For-Info-Msg to CustomerWAITInput Customer-Info from Customer

– to wait to be reactivated by another processOutput Customer-Rec to Master-FileWAIT