programming techniques

7
A2 Computing F453 Advanced Computing Theory Programming Techniques Definitions | Tiju Thomas PARAMETER A value that can be passed to a subroutine, either a procedure or a function. Can be passed by value which means that the actual value is passed across and the old value remains when the subroutine is finished. It can be passed by reference which means it is passed as the contents of an address, so if the subroutine changes it, the old value is essentially rubbed out.

Upload: tiju-thomas

Post on 24-Mar-2016

212 views

Category:

Documents


0 download

DESCRIPTION

Programming Techniques

TRANSCRIPT

Page 1: Programming Techniques

A2 Computing F453 Advanced Computing Theory Programming Techniques

Definitions | Tiju Thomas

PARAMETER

A value that can be passed to a subroutine, either a procedure or a

function.

Can be passed by value which means that the actual value is passed

across and the old value remains when the subroutine is finished.

It can be passed by reference which means it is passed as the

contents of an address, so if the subroutine changes it, the old

value is essentially rubbed out.

Page 2: Programming Techniques

A2 Computing F453 Advanced Computing Theory Programming Techniques

Definitions | Tiju Thomas

LOCAL VARIABLE

Only exists in the subroutine in which it is declared.

Page 3: Programming Techniques

A2 Computing F453 Advanced Computing Theory Programming Techniques

Definitions | Tiju Thomas

GLOBAL VARIABLE

A single variable that is available throughout the program.

Page 4: Programming Techniques

A2 Computing F453 Advanced Computing Theory Programming Techniques

Definitions | Tiju Thomas

USING FUNCTIONS AND PROCEDURES TO DEVELOP A PROGRAM

Each module can be written as a functional procedure, which can

be tested individually.

The use of library routines, as code is reusable.

Main program consists of calls to functions/procedures which may

be nested.

Page 5: Programming Techniques

A2 Computing F453 Advanced Computing Theory Programming Techniques

Definitions | Tiju Thomas

USING GLOBAL VARIABLES, LOCAL VARIABLES AND PARAMETERS

Local Variables

o A variable defined within one part of the program and is only

accessible in that part.

o Data contained is lost when execution of that part of the

program is completed.

o The same variable names can be used in different modules.

Global Variables

o A variable that is defined at the start of a program and exists

throughout the program including functions and procedures.

o Allows data to be shared between modules.

o Overridden by local variables with the same name.

Parameters

o Information about an item of data supplied to a function or

procedure.

o Can be passed by reference or value.

o Used as a local variable.

Page 6: Programming Techniques

A2 Computing F453 Advanced Computing Theory Programming Techniques

Definitions | Tiju Thomas

BINARY SEARCHING VS SERIAL SEARCHING

Usually faster because half of the data set is discarded at each step.

Therefore fewer items have to be checked.

Page 7: Programming Techniques

A2 Computing F453 Advanced Computing Theory Programming Techniques

Definitions | Tiju Thomas

BACKUS NAUR FORM

To unambiguously define the syntax of a computer language.