Development life cycle
Analysis: a process of investigation, leading to the specification of what a program is required to do
abstraction, decomposition of the problem, identification of the problem and
requirements
Abstraction – a method used in the analysis stage of the program development life cycle;
the key elements required for the solution to the problem are kept and any unnecessary
details and information that are not required are discarded.
Design: uses the program specification from the analysis stage to show to how the program should
be developed
decomposition, structure diagrams, flowcharts, pseudocode
Decomposition – a complex problem is broken down into smaller parts, which can then be
sub divided into even smaller parts that can be solved more easily.
Decomposing a problem
Inputs – the data used by the system that needs to be entered while the system is active.
Processes – the tasks that need to be performed using the input data and any other
previously stored data.
Outputs – information that needs to be displayed or printed for the users of the system.
Storage – data that needs to be stored in files on an appropriate medium for use in the
future.
Coding: the writing of the program or suite of programs
writing program code and iterative testing
Testing: systematic checks done on a program to make sure that it works under all conditions
testing program code with the use of test data
Sub-systems
▪ Top-down design is the decomposition of a computer system into a set of sub-systems.
▪ The process of breaking down into smaller sub-systems is called stepwise refinement.
Different methods to design and construct a solution to a problem
– Flowcharts: A diagram that shows the steps required for a task (sub-system) and the order in which
the steps are to be performed. A graphical representation used to represent an algorithm.
– Pseudocode: Pseudocode is a simple method of showing an algorithm; it describes what the
algorithm does by using English key words that are very similar to those used in a high-level
programming language but without the strict syntax rules.
– Structure diagrams: A structure diagram shows the hierarchy of a system.
1
Top-Down Design
The breaking down of a computer system into a set of sub-systems, then breaking each subsystem
down into a set of smaller sub-systems, until each sub-system just performs a single action.
Benefits of Top-Down Design
▪ Breaking a problem down into smaller parts/tasks make it far easier to understand, solve and
manage.
▪ Top-down design allows several programmers or teams to work on the same project, without
getting in each other’s way.
▪ Each module of code to be tested separately.
Variable: A variable is a storage location. It is a named value that contains data that can be changed
throughout the execution. E.g: Total
Constant: A constant is also a storage location. It is a named location that contains a value that we
don’t want to change during the running of the program. E.g: CONSTpi 3.142
Array: An array is a data structure containing several elements of the same data type and stored under
a single name. To reduce the number of variables used. Any item can be found using an index number.
Data Type
Char: A single character. Eg: A / # /
String: A sequence of characters. E.g: Hello World / #123?
Boolean: A data type with two possible values. E.g: True / False
Integer: A positive or negative whole number. E.g: 12 / -23
Real: A positive or negative number with a fractional part. E.g: 23.05 / - 24.56
Algorithm – an ordered set of steps to solve a problem.
Sequence and Selection
▪ Sequence is the concept of one statement being executed after another whereas selection
decides which statements are to be executed depending upon the result of a question.
Sequence:
PRINT X
PRINT Y
2
Selection
IF X > Y THEN PRINT X ELSE PRINT Y
Conditional Statement
▪ IF …. THEN …. ELSE
A conditional statement with different outcomes for true and false.
▪ CASE .. OF .. OTHERWISE .. ENDCASE
A conditional statement to deal with many possible outcomes.
Purpose of a Conditional Statement
▪ To allow different routes through a program
▪ Dependent on meeting certain criteria
LOOPING
FOR …. TO …. NEXT
Fixed number of repetitions. A loop that will always iterate a set number of times.
REPEAT …. UNTIL
Always executed post condition test. The loop is continued when the criteria has been met. A
loop that will always iterate at least once.
WHILE …. DO …. ENDWHILE
Pre-condition test that means condition is placed at the start of the loop. The loop is continued
when the criteria have not been met.
Iteration
– count-controlled loops (FOR.. TO.. NEXT)
– pre-condition loops (WHILE … DO … ENDWHILE)
– post-condition loops (REPEAT … UNTIL)
Subroutine is sub program, it is not the whole program to perform a frequently used operation with a
program. That can be called when needed and reused by another program. Eg: Procedure and Function
A procedure is a set of programming statements grouped together under a single name that can be
called to perform a task at any point in a program.
A function is a set of programming statements grouped together under a single name that can be
called to perform a task at any point in a program. In contrast to a procedure, a function will return a
value back to the main program.
Parameters are the variables that store the values of the arguments passed to a procedure or function.
Some but not all procedures and functions will have parameters.
3
Counting is used with repetition with the counter increased by 1 every time the loopis repeated.
Count Count + 1
Totalling is used with repetition with the total updated every time the loop is repeated.
Total Total + Number
A global variable can be used by any part of a program – its scope covers the whole program.
A local variable can only be used by the part of the program it has been declared in – its scope is
restricted to that part of the program.
Errors
Syntax Error
▪ Syntax Error occurs when a programmer does not follow the rules or structure of the language
they are writing in.
Logic Error
▪ A logic error is an error in the code that causes the program to do something it should not.
Validation – Automated checks carried out by a program that data is reasonable before it is accepted
into a computer system.
Validation is an automatic check to ensure that data entered is sensible and feasible.
Range check – a check that the value of a number is between an upper value and a lower value.
E.g: Number will be 1 to 5
Length check – a method used to check that the data entered is a specific number of characters
long or that the number of characters is between an upper value and a lower value.
E.g: 8 characters in password
Type check – a check that the data entered is of a specific type.
E.g: Email Address, ID-Number
Presence check – a check that a data item has been entered.
E.g: Enter nothing.
Format check – a check that the characters entered conform to a pre-defined pattern.
Check digit – an additional digit appended to a number to check if the entered number is error-
free; check digit is a data entry check and not a data transmission check.
Verification – checking that data has been accurately copied from another source and input into a
computer or transferred from one part of a computer system to another. Verification is
a way of preventing errors when data is copied from one medium to another.
4
Double Entry: Data is entered twice and the computer checks that they match up.
Eg: Enter password:
Re enter password:
Visual check: The user manually reads and compares the newly inputted data against the original
source to ensure they match.
Set of test data – all the items of data required to work through a solution.
Normal data – data that is accepted by a program.
Abnormal data – data that is rejected by a program.
Extreme data – the largest/smallest data value that is accepted by a program.
Boundary data – the largest/smallest data value that is accepted by a program and the corresponding
smallest/largest rejected data value.
Difference between Extreme Data and Boundary Data
▪ Extreme data is the largest/smallest acceptable value.
▪ Boundary data is the largest/smallest acceptable value and the corresponding smallest/largest
rejected value.
Linear search – an algorithm that inspects each item in a list in turn to see if the item matches the
value searched for.
Bubble sort – an algorithm that makes multiple passes through a list comparing each element with
the next element and swapping them. This continues until there is a pass where no more swaps are
made.
Concept of string handling
– length: finding the number of characters in the string
– substring: extracting part of a string
– upper: converting all the letters in a string to uppercase
– lower: converting all the letters in a string to lowercase
The first character of the string can be position zero or one.
Library routines: Library routines that are ready to incorporate into a program.
MOD – returns remainder of a division.
DIV – returns the quotient (i.e. the whole number part) of a division
ROUND – returns a value rounded to a given number of decimal places.
RANDOM – returns a random number
5
ARRAY
▪ An Element is an individual data location in an array.
▪ Each of the individual items in an array is called an element.
▪ The index indicates the position of the element within the array
▪ The dimension of an array is the number of indices needed to select an element.
▪ A one-dimensional array can be referred to as a list.
▪ A two-dimensional array can be referred to as a table, with rows and columns.
Advantage and Disadvantage of Array
▪ In an array, accessing an element is very easy by using the index number.
▪ The search process can be applied to an array easily.
▪ Array size is fixed: The array is static, which means its size is always fixed. The memory which
is allocated to it cannot be increased or decreased.
Purpose of storing data in a file
▪ Data stored in RAM will be lost when the computer is switched off, when data is saved to a file
it is stored permanently.
▪ Data stored in a file can thus be accessed by the same program at a later date or accessed by
another program.
▪ Data stored in a file can also be sent to be used on other computer(s).
▪ The storage of data in files is one of the most used features of programming.
▪ Data can be backed up or archived.
Create a maintainable program
Including appropriate use of:
– meaningful identifiers
– the commenting feature provided by the programming language
– procedures and functions
– relevant and appropriate commenting of syntax
Use meaningful identifiers for:
– variables
– constants
– arrays
– procedures and functions