Sie sind auf Seite 1von 8

F452 Essential Revision Notes

AS Computing
Programming Constructs
Statement
A single instruction which can be executed
Variable
An identifer/name associated with a particular memory location used to store (and
manipulate) data which can be changed while the program is running.
Allows the algorithm to be written even when the data is not yet known
Procedure
A section of code which is given an identifer. It can be called from the main program
or from another procedure. hen the procedure is called the called the code in the
procedure is executed and then control is passed back to where the procedure was
called from. It can return a value but doesn!t have to.
A global variable is declared at the beginning of a program and is available
throughout the program
A local variable is declared within a subprogram/procedure/function/block of code
and is only available within that section of code and is destroyed/deleted when the
subprogram exits
A local variable can override a global variable (with the same name)
Constant
hen a constant is declared it must be given a value. "he value cannot be changed
while the program is running.
If the value needs to be changed then only one change needs to be made (where the
constant is declared). "his updates the value throughout the program.
Sequence
All instructions are executed once in the order in which they appear
Selection
A condition is used to determine which of the statements (if any) will be executed as a
result some instructions may not be executed. #election is $ither I% or &A#$
statement. A nested I% statement is where I% statements are within each other.
Iteration
A group of instructions is repeated for a set number of times or until a condition is met
Parameter
A variable which holds an item of data which is supplied/passed to a
subroutine/procedure/function
It is given an identifer when the subroutine is defned
It is substituted by an actual value when the subroutine is called
Function
A subroutine which can return a single value
It can be called using its identifer as part of an expression
Watford Boys Grammar School
Recursion
hen a function/procedure/subroutine calls itself until it reaches a base case.
Loops
'I($ loop (&ondition controlled)
"he condition is tested before each iteration and the statements in the loop will
be executed if the condition is true.
"he statements in the loop may not be executed (if the condition is initially
false)
)$*$A" loop (&ondition controlled)
"he &ondition is tested after each iteration. Instructions will be executed at
least one.
%+) loop (&ount controlled)
"he number of iterations is fxed according to start and end values of a variable
set at the beginning. ,ou need a for loop to access the element number within
an array.
Advantage of using iteration instead of recursion
-ses only one set of variables (which are updated on each loop)/ recursion
creates new variables for each call therefore more e.cient use of memory and
can be faster less likely to run out of stack space...
Disadvantages
Algorithm may be more di.cult to follow/trace using recursion because
variables are being reused
,ou need to be careful to get the conditions of loops correct (given current state
of variables)
File Types
Serial
"he data is stored chronologically/in the order in which it is entered
/ew data always added to the end of the fle
,ou need to read each preceding item to reach an item you are searching for
Sequential fle
)ecords are ordered logically according to a feld in the record
Allows the data to be displayed in the correct order
#earched easily as in the correct order.
Inde Sequential
)ecords are arranged in order of a primary key
An index is kept which is used to 0ump to groups/blocks of records
"he index must be in the same order as the records
1iven the large number of records accessing a specifc record is faster as you do not
have to search se2uentially from the beginning.
Random
Allow data to be stored in any order. A hashing algorithm is performed on a feld in the
record to fnd the record. 3ery useful for very large databases where individual records
are often looked up individually.
Rapid !pplication Development
Watford Boys Grammar School
)A4 is a method for designing software where a *rototype design with reduced
functionality is produced then tested and evaluated to refne the design of the next
prototype. "his is repeated (with a more refned prototype each time) until *rototype is
accepted by the end user and fnal product is produced.
*rototypes are tested/evaluated with the end user. "he outcome is used to inform the
next prototype. "his process is repeated/iterative development.
Watford Boys Grammar School
)ole of $nd -ser
5ore involved
&hange the re2uirements as product becomes clearer.
#ee a working prototype sooner
Involved in the design
In6uence the direction the program is taking.
+verall development time is shorter reducing development costs.
!rrays
A data structure / set of data items of the same data type.
1rouped under one identifer.
$ach item can be addressed using its index.
/eed to declare the following..
/ame of array
o allow individual data items to be accessed.
5aximum number of elements
o enable contiguous locations in memory to be reserved.
4ata type of contents eg. integer
o allow correct variables/to determine rules for manipulation.
/umber of 4imensions
o to allow position in array to have meaning
Advantages of using an array..
&ode is easier to manage as there are fewer variables.
Initialising an array example7
%+) count89 "+ 9: do
array (count)8:
/$;" count
Top Do"n#$odular Design
*roblem is split into smaller sub<problems which= in turn= are split into smaller sub<
problems until each is one element of the algorithm. $ach module is a small part of
the problem/focuses on a small sub<task. "his is called step"ise refnement.
!dvantages
#maller problems are easier to solve/understand and easier to test/debug.
4evelopment can be shared between a team of programmers according to individual
strengths
&ode can be reused.
*roblems are easy to solve and test/debug
4evelopment can be shared between a team of programmers so program developed
faster
$asy to maintain/update a part of the system
)educes the amount of code that needs to be produced because code can be reused
or standard library modules can be used reducing time of development
Disadvantage
5odules must be linked
*rogrammers must ensure that cross<referencing is done
Interfaces between modules must be planned
"esting of links must be carried out
Watford Boys Grammar School
Code "riting tec%niques
-se of sensible variable names/procedures/functions to allow others to understand
scope of variables
Indentation of code/spacing of code
!nnotate code
comments that are not used by the computer so that others can understand
reasons for code/structures
!dvantages
&ode can easily be read by other programmers / at a future date
Indentation clearly shows structure of code
5eaningful identifers make code easier to read / understand
*rogram is less error prone
o internally documented and is easier to trace / debug
Variable &aming
"he variables/procedures should be given descriptive names using consistent
conventions making it easier to tell what the variable represents.
-se CamelCase#underscores as most translators do not allow spaces in identifer
names
'ey"ord#reserved "ords in the language should be avoided
Declare constants and use these in the code where possible
o if the value changes= you only need to change it in the declaration of the
constant instead of looking for every instance of the variable
Variables#constants s%ould be declared as local wherever possible
o reducing the scope/lifetime of the variable to the minimum necessary and
avoiding errors due to clashing variable names in di>erent parts of the
program
Initialise variables when declared
o this ensures that a suitable value is in the variable at the start of your
algorithm
Declarations s%ould be made obvious within the code
o using comments with explanations of their purpose or separating them
from code with blank lines so that they can easily be found
()I Design
!dvantages
$asier to learn
%amiliar layout
1ood use of online help
ill be intuitive
%ewer mistakes will be made when using the program
Input will be faster
-se of 1-I ob0ects such as drop downs/option buttons
4ialogue boxes to alert on validation errors
/o information overload / sensitive to the needs of the user
Is very processor/memory intensive.
Watford Boys Grammar School
Testing
White Bo !esting
Tests the algorithm/actual code it works as intended.
Blac" Bo !esting
#uitable inputs are tested against the expected output (according to the design)
without considering how the program works
!lp%a Testing
"esting is carried out by the programmer(s)/ software company playing the role
of the end user to fnd bugs in the program.
!cceptance Testing
"he program is tested to prove to the end user that the program works
correctly.
5eets the original ob0ectives
$nd user will pay if satisfed
"he programmer demonstrates the working program to the client. "he aim is to
show that the program meets all the re2uirements of the client.
*eta+Testing
"he nearly complete program is given to a select group of users to test under
normal operating conditions.
"he aim is to fnd any bugs which the programmer has overlooked
"he users report back any errors= bugs or compatibility issues.
-sers may also report desirable improvements.
"he system is tested by real users in real world environment ? gives
programmer more useful feedback.
&onse2uently fnal version will be more robust.
Installation Routine
"he program is copied to a designated folder on the target computer
Any necessary data fles are copied
Any necessary library fles are copied and registered
#hortcut / icon created to run the program easily
-ser has the opportunity to confgure program / run settings
&onfguration is saved in a fle / registry
*rograms may need extracting from a compressed fle
Debugging Tools
4ebugging tools and facilities available in programming languages= which can be used
to identify and correct errors
Translator Diagnostics
*ick up syntax errors and informs the programmer who can then correct the
error
*rea, Points
&ause the program to halt in execution at strategic points current values of
variables can then be checked
-atc%es
&ause the program to halt in execution if a condition is met such as a variable
changing
Watford Boys Grammar School
Stepping
$xecuting the code one statement at a time observing path of execution and
changes to variables. &an be used with break points or watches
Watford Boys Grammar School
Validation
Input data is checked by the computer against a set of rules to ensure that it is
reasonable/sensible
Presence c%ec,
that a data item has been entered.
Lengt% c%ec,
data item should be a maximum or minimum number of characters long
C%aracter c%ec,
check that it is an uppercase characters or digit/space
Format c%ec,
$.g. a postcode should consist of one or two letters= one or two digits then a
space followed by one digit and two letters.
.istence c%ec,#loo,+up c%ec,/
"hat a data item exists within a database/list
.rrors
Synta .rror
Statement has been written in the program that breaks the rules of the language.
Logic .rror
4oes not perform the algorithm intended by the programmer
4etected when program produces incorrect result
Run+time error
#tatement in the code cannot be executed < e.g. division by :
4etected when the program crashes
Watford Boys Grammar School

Das könnte Ihnen auch gefallen