Learner Guide
Learner Guide
LEARNER GUIDE
SAQA: 14918
1|Page
Learner Information:
Details Please Complete this Section
Name & Surname:
Organisation:
Unit/Dept:
Facilitator Name:
Date Started:
Date of Completion:
Copyright
All rights reserved. The copyright of this document, its previous editions and any
annexures thereto, is protected and expressly reserved. No part of this
document may be reproduced, stored in a retrievable system, or transmitted, in
any form or by any means, electronic, mechanical, photocopying, recording or
otherwise without the prior permission.
2|Page
Key to Icons
The following icons may be used in this Learner Guide to indicate specific
functions:
This icon means that other books are available for further
information on a particular topic/subject.
Books
References
3|Page
An important aspect of learning is through workplace
experience. Activities with this icon can only be completed
Workplace once a learner is in the workplace
Activities
This icon indicates practical tips you can adopt in the future.
Tips
4|Page
Learner Guide Introduction
About the Learner This Learner Guide provides a comprehensive overview of the
Guide… Describe the principles of Computer Programming,and forms part
of a series of Learner Guides that have been developed for
FURTHER EDUCATION AND TRAINING CERTIFICATE: INFORMATION
TECHNOLOGY: SYSTEMS DEVELOPMENT ID 78965 LEVEL 4 –
CREDITS 165The series of Learner Guides are conceptualized in
modular’s format and developed FURTHER EDUCATION AND
TRAINING CERTIFICATE: INFORMATION TECHNOLOGY: SYSTEMS
DEVELOPMENT ID 78965 LEVEL 4 – CREDITS 165 They are designed
to improve the skills and knowledge of learners, and thus
enabling them to effectively and efficiently complete specific
tasks. Learners are required to attend training workshops as a
group or as specified by their organization. These workshops are
presented in modules, and conducted by a qualified facilitator.
5|Page
To qualify To qualify and receive credits towards the learning programme,
a registered assessor will conduct an evaluation and assessment
of the learner’s portfolio of evidence and competency
Range of Learning This describes the situation and circumstance in which
competence must be demonstrated and the parameters in
which learners operate
Responsibility The responsibility of learning rest with the learner, so:
Be proactive and ask questions,
Seek assistance and help from your facilitators, if required.
6|Page
Describe the principles of Computer
1
Programming
Learning Unit
Open.
The credit value of this unit is based on a person having the prior knowledge and skills to:
Demonstrate an understanding of fundamental mathematics (at least NQF level 3)
Demonstrate PC competency skills (End User Computing unit standards up to Level 3).
7|Page
SESSION 1.
Learning Outcomes
The description provides an appreciation of the steps and techniques of program
maintenance.
The description identifies different problem analysis techniques (at least 2).
The description identifies different programming design techniques.
8|Page
structured programming in the 1960�s and 70�s brought with it the concept of
Structured Flow Charts. In addition to a standard set of symbols, structured flow charts
specify conventions for linking the symbols together into a complete flow chart. The
structured programming paradigm evolved from the mathematically proven concept
that all problems can be solved using only three types of control structures:
Sequence, Decision (or Selection),Iterative (or looping).
The definition of structured flow charts used in this document and software further
defines:
3 types of sequential structures: Process, Input/Output, and Subroutine Call
3 types of decision structures: Single Branch, Double Branch, and Case.
4 types of iterative structures: Test at the Top, Test at the Bottom, Counting, and User
Controlled Exit.
A comment structure.
The SFC program is designed to aid the programmer in designing and presenting
structured flow charts.
The description identifies different problem analysis techniques (at least 2).
Top-down and bottom-up are both strategies of information processing and knowledge
ordering, used in a variety of fields including software, humanistic and scientific theories
and management and organization. In practice, they can be seen as a style of thinking
and teaching.
A top-down approach (also known as stepwise design or deductive reasoning, and in
many cases used as a synonym of analysis or decomposition) is essentially the breaking
down of a system to gain insight into its compositional sub-systems. In a top-down
approach an overview of the system is formulated, specifying but not detailing any first-
level subsystems. Each subsystem is then refined in yet greater detail, sometimes in
many additional subsystem levels, until the entire specification is reduced to base
elements. A top-down model is often specified with the assistance of "black boxes",
these make it easier to manipulate. However, black boxes may fail to elucidate
elementary mechanisms or be detailed enough to realistically validate the model. Top
9|Page
down approach starts with the big picture. It breaks down from there into smaller
segments.
A bottom-up approach (also known as inductive reasoning,[1] and in many cases used
as a synonym of synthesis) is the piecing together of systems to give rise to grander
systems, thus making the original systems sub-systems of the emergent system. Bottom-
up processing is a type of information processing based on incoming data from the
environment to form a perception. Information enters the eyes in one direction (input),
and is then turned into an image by the brain that can be interpreted and recognized
as a perception (output). In a bottom-up approach the individual base elements of the
system are first specified in great detail. These elements are then linked together to form
larger subsystems, which then in turn are linked, sometimes in many levels, until a
complete top-level system is formed.
Modularity
10 | P a g e
Modularity is designing a system that is divided into a set of functional units (named
modules) that can be composed into a larger application. A module represents a set of
related concerns. It can include a collection of related components, such as features,
views, or business logic, and pieces of infrastructure, such as services for logging or
authenticating users. Modules are independent of one another but can communicate
with each other in a loosely coupled fashion. A composite application exhibits
modularity. For example, consider an online banking program. The user can access a
variety of functions, such as transferring money between accounts, paying bills, and
updating personal information from a single user interface (UI). However, behind the
scenes, each of these functions is a discrete module. These modules communicate with
each other and with back-end systems such as database servers. Application services
integrate components within the different modules and handle the communication
with the user. The user sees an integrated view that looks like a single application.
Figure 1 illustrates a design of a composite application with multiple modules.
Module composition
Why Choose a Modular Design?
11 | P a g e
The following scenarios describe why you might want to choose a modular design for
your application:
Simplified modules. Properly defined modules have a high internal cohesion and
loose coupling between modules. The coupling between the modules should be
through well-defined interfaces.
Developing and/or deploying modules independently. Modules can be developed,
tested, and/or deployed on independent schedules when modules are developed
in a loosely coupled way. By doing this, you can do the following:
o You can independently version modules.
o You can develop and test modules in isolation.
o You can have modules developed by different teams.
Loading modules from different locations. A Windows Presentation Foundation (WPF)
application might retrieve modules from the Web, from the file system and/or from a
database. A Silverlight application might load modules from different XAP files.
However, most of the time, the modules come from one location; for example, there
is a specific folder that contains the modules or they are in the same XAP file.
Minimizing download time. When the application is not on the user's local computer,
you want to minimize the time required to download the modules. To minimize the
download time, only download modules that are required to start-up the
application. The rest are loaded and initialized in the background or when they are
required.
Minimizing application start-up time. To get part of the application running as fast as
possible, only load and initialize the module(s) that are required to start the
application.
Loading modules based on rules. This allows you to only load modules that are
applicable for a specific role. An application might retrieve from a service the list of
modules to load.
The description identifies different programming design techniques.
What Is Pseudocode?
12 | P a g e
Pseudocode and flowcharts are both popular ways of representing algorithms.
Pseudocode has been chosen as the primary method of representing an algorithm
because it is easy to read and write, and allows the programmer to concentrate on the
logic of the problem. Pseudocode is really structured English. It is English that has been
formalised and abbreviated to look like the high-level computer languages.
Pseudocode provides another way to represent program logic. The approach is to write
the program in a language similar to the one used for implementation but with an easily
understood shorthand for complex expressions. The idea is to represent the logic but to
ignore many of the syntactic requirements of the programming language. A
pseudocode design description is thus a mixture of human language and programming
constructs. Instead of the complete logic for well-known functions, simple statements
are used. Similarly, the program flow can be represent with traditional conditional
statements, using written expressions to describe the logic. While there are no generally
accepted pseudocode notation standards, it is a good idea to use language
constructs that are similar to those in the high-level language being used. When you do,
the psedocode will look familiar at implementation time and will provide a framework
for implementation. Because pseudocode does not require
the programming language details, it is generally easier and quicker to produce than a
completed source program. While there is no standard pseudocode, once you
understand one version, it is easy to understand other versions. Many programmers use
pseudocode. Abstract versions of it are used to express abstract algorithms. More
language specific versions of it are used to express design for programs in those
languages. Pseudocodes supposed to be clear enough that a human being can
execute it “by hand,” without using a computer and with little or no knowledge
of programming languages. Pseudocode is used to represent the algorithm. The
common characteristics of pseudocode:
13 | P a g e
Statements are written in simple English
Each instructions is written on a separate line
Keywords and indentation are used to signify particular control structures
Each set of instructions is written from top to bottom, with only one entry and one
exit
Groups of statements may be formed into modules, and the module given a name
Pseudocode is an English-like nonstandard language that lets you state your solution
with more precision than you can in plain English but with less precision than is required
when using a formal programming language. Pseudocode permits you to focus on the
program logic without having to be concerned just yet about the precise syntax of a
particular programming language. However, pseudocode is not executable on the
computer.
Documenting the Program
Documenting is an ongoing, necessary process, although, as many programmers are,
you may be eager to pursue more exciting computer-centered activities.
Documentation is a written detailed description of the programming cycle and specific
facts about the program. Typical program documentation materials include the origin
and nature of the problem, a brief narrative description of the program, logic tools such
as flowcharts and pseudocode, data-record descriptions, program listings, and testing
results. Comments in the program itself are also considered an essential part of
documentation. Many programmers document as they code. In a broader sense,
program documentation can be part of the documentation for an entire system.
The wise programmer continues to document the program throughout its design,
development, and testing. Documentation is needed to supplement human memory
and to help organize program planning. Also, documentation is critical to
communicate with others who have an interest in the program, especially other
programmers who may be part of a programming team. And, since turnover is high in
the computer industry, written documentation is needed so that those who come after
you can make any necessary modifications in the program or track down any errors
that you missed.
14 | P a g e
SESSION 2.
Learning Outcomes
The description distinguishes between different numeric data types (at least 3).
The description identifies different logical data types.
The description distinguishes between different internal representations of data
types.
The description identifies different logical operators.
The description distinguishes between different numeric data types (at least 3).
Binary, Decimal, Hexadecimal, Octal.
Numerical Notations: Hexadecimal, Decimal, Octal, and Binary
Since most programming languages accept literal constants in the same decimal
notation that we all learned as children, it is not uncommon for a programmer to
master many of the basic programming techniques and concepts before they ever feel
the need to use an alternate notation. Even assembly languages can be used without
leaving the comfort of decimal notation. While decimal notation is appropriate for
mathematical calculations, it conceals much of the underlying structure implicit in the
way data is stored and handled internally by the computer. For certain tasks,
representing data in hexadecimal or binary notation can provide deeper insights into
exactly what a program is doing. They can also help illuminate some of the limitations of
numerical data types.
Getting out of our own way
Binary, hexadecimal, and octal notations are not difficult to learn. In fact, you already
know the most fundamental concepts required to use the notations. They are all
inspired by the same underlying principle that defines the decimal system, which you
mastered long before you learned the mathematics required to even casually describe
15 | P a g e
it. The most difficult obstacle that many face is the unquestioned assumption that a
number is identical with its representation. To handle data flexibly, we have to realize
the when we write a combination of symbols, such as32, we are using merely a
representation of a number. There is nothing intrinsic about the number thirty-two that
demands that it be represented by those specific symbols. None of its arithmetic or
algebraic properties depend upon the visual symbols 3 and 2. The decimal notation
developed because it was found to be convenient for manipulating the symbols used
to represent numbers and helped provide insight into their mathematical relationships.
It is, however, just one member of an infinite family of similar notation systems. To help us
move past this obstacle, we'll begin by taking a closer look at how decimal notation is
used. This discussion is not intended to be a rigorous mathematical inquiry, and you may
find other descriptions that use an entirely different approach. The goal here is merely
to highlight the salient features of the decimal system that will help us understand
hexadecimal, octal, and binary notations. For simplicity, we are going to focus only on
unsigned whole integer values, and disregard negative values and decimal points.
The Decimal System
Modern decimal notation is a positional system. To understand what this means, lets
review the basic task of counting. To count aloud, we merely recite a list of words in a
specific sequence.
zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen,
fourteen.....
When we want to write this sequence, rather than spell out the spoken representation,
we resort to a compact notation using only ten unique symbols.
0, 1, 2 ,3 ,4, 5, 6, 7, 8, 9
At this point, we have used all ten of our symbols, so to provide a unique representation
of the next highest integer, we need more than one digit. We can rewrite our sequence
as two digit values like this:
00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 , 20, 21, 22, 23....
It may help to envision a mechanical counter like an old style odometer display. Each
position consists of a wheel with the numerals 0 through 9 printed in order on the outer
16 | P a g e
circumference. As each wheel rolls over from 9 to 0, the wheel to the left is advanced
one digit. This step is often called the carry, as in the expression "carry the one".
With two digits, we can continue with this pattern until we reach 99. After that we will
need a third digit.
000, 001, 002, 003, 004, 005, 006, 007, 008, 009,010 ... 098, 099, 100, 101, 102 ... 998, 999
Each digit occupies a position. The position at the furthest right, is position 0. The next
position to the left is position 1, and so on through each position.
The following table shows the position of the digits in the decimal number 2993.
Position 4 3 2 1 0
Digit 0 2 9 9 3
The number, or value, represented by the sequence of digits 2993, is the sum of the
value of each digit, and the value of each digit is determined by the position in which it
appears.
So, with the sequence 2993 we have:
Position Digit Value
0 3 3*1=3
1 9 9* 10 = 90
2 9 9 * 100 = 900
3 2 2 * 1000 = 2000
3 + 90 + 900 + 2000 = 2993
You should notice that each position indicates a power of ten. In position 2, the digit
was multiplied by 102. In position 3, the digit was multiplied by 103.
Also, notice that the maximum value that can be represented by a given number of
digits is one less than a power of ten.
Number of digits Maximum Value
1 101 - 1 = 9
2 102 - 1 = 99
3 103 - 1 = 999
...
10 1010 - 1 = 9999999999
17 | P a g e
In general, the maximum value that can be represented in the decimal notation
when n digits are used is 10n-1. Since the lowest value is 0, this mean that n digits can
represent 10nunique values. The key to making this system work is the use of the
symbol 0as a place holder in any position that does not contribute to the value of the
number represented. Without this place holder, expressing a number such as 202 would
be very difficult. Normally, in the decimal notation, we don't indicate the digits on the
left of a number when they are zero, so instead of 0021, we usually simply write 21.
Conceptually, though, you can imagine an infinite list of zeros preceding any number
written in decimal notation.
Binary
The binary notation works exactly the same way as the decimal notation, but instead of
ten symbols, only two symbols are used: 0 and 1. Whereas decimal is a base 10
positional notation, binary is a base 2 positional notation.
A digit in binary, is usually referred to as a bit.
With one bit, we have two possible values:
0, 1
So, in binary, with one bit, we can count from zero to one. To count higher requires
more bits. With two bits, we can count as high as three.
Decimal: 0, 1, 2, 3
Binary: 00, 01, 10, 11
The same pattern applies here as it did in the decimal notation. When a digit in one
position rolls over from the highest numeral (1) to the lowest (0), the digit to the left
increases. To avoid any confusion it should be explicitly stated here that in binary
notation, 10 represents the number two. It does not represent the number ten. For years,
our minds have associated the combination of symbols 10 with the concept "ten". This
association is so strong that it can be difficult to temporarily put aside. It may help to
realize that the symbols 0 and 1 are merely a convention. If we like, we could adopt
any other two symbols, such as Tand H. Let's say T represents zero, and H represents one.
We can rewrite the above sequence this way:
Decimal: 0, 1, 2, 3
18 | P a g e
Binary: TT, TH, HT, HH
Unfortunately, when we want to express data in a binary notation that our compiler or
interpreter will understand, we must return to the conventional symbols 0 and 1. In
general, with n bits, we can represent the values 0 to 2n- 1. The total number of unique
values we can represent when we have n bits, including 0, is 2n. To convert from the
binary notation to the decimal notation, we can use the same arithmetic that we used
to determine the value of a number in decimal notation.
In binary, the value of a bit is multiplied by 2position. Again, the right most position is
position 0.
So the decimal notation equivalent of the binary 1101 is:
Position Bit Value
0 1 1 * 20 = 1
1 0 0 * 21 = 0
2 1 1 * 22 = 4
3 1 1 * 23 = 8
1 + 4 + 8 = 13
You should notice that value of each bit is either zero or an integral power of two. This is
true because each bit may hold only one of two states: 0 or 1. Given an eight bit binary
number, the resulting value will be the sum of one or more of the decimal values: 1 ,2 ,4,
8, 16, 32, 64, and 128. Given a four bit value, that list is reduced to: 1,2,4, and 8.
Here is an example using the binary value 1001.
(8 * 1 ) + ( 4 * 0 ) + ( 2 * 0 ) + (1 * 1 ) = 8 + 1 = 9
So the decimal equivalent of the binary number 1001 is 9.
The key concept is that these are equivalent representations. They both signify the
same number.
Why use the binary notation?
The binary notation is used to closely represent the way information in physically
implemented by a computer. Since an individual bit can only be in one of two states,
designing machinery or circuitry to manipulate bits is well understood and these designs
can be aggregated to perform operations on collections of bits. In fact, while a
19 | P a g e
computer's memory can be visualized as a very long sequence of individual bits, most
microprocessors are not designed to perform operations on one bit at a time. Instead,
the processor's architecture defines the least number of contiguous bits which it may be
addressed and manipulated during one machine instruction. This least number of bits
that a processor may manipulate at one time is called a BYTE. In the past, the size of a
BYTE varied from one design to another, but over time, most designs have settled on a
BYTE size of 8 bits. This is the BYTE used by processors that implement the Intel x86
architecture, which is the architecture on which most modern PC processors are based.
The original version of the x86 architecture provided means to work with a single BYTE
and with a pair of bytes called a WORD. A WORD, being composed of two BYTEs, is a 16
bit wide field. With extensions to the architecture, the ability to work directly upon 32 bit
double words (DWORD) was added, and on some machines 64 bit quadruple words
(QWORD) may be handled by a single instruction.
This gives us the following common primitive data types:
BYTE 8 bits
WORD 16 bits
DWORD 32 bits
QWORD 64 bits
At the source code level, binary notation is rarely used to represent numerical data.
Decimal notation is much more intuitive, and almost all programming languages
support decimal notation directly in source code. Binary notation is usually only used to
explicitly indicate the specific bits in a data field. The interpretation of such data is, of
course, dependant on the program, but common usages include option flags, data
masks, bit patterns, packed data, etc.When binary notation is used, the value of all bits
in the data field are usually explicitly indicated, including leading zeros. So, to specify
the contents of a single BYTE in binary, all eight bits would be included in the notation.
For example, to indicate that only bit 0 and bit 4 should be "on", it might be written like
this: 00010001. The exact syntax required to specify binary notation depends on the
programming language used. Ansi C, in fact, does not specify any method for giving
literal constants in binary notation.
20 | P a g e
Hexadecimal
Using binary notation can be cumbersome and prone to typing mistakes. If we wanted
to specify a 16 bit value with all bits off except bit 9 in binary notation, it would look
something like this (in FreeBASIC syntax):
&b0000001000000000
If you can verify that the 1 is in the 9th position in less than ten seconds, you deserve a
pat on the back.
The Hexadecimal notation provides a more compact form, but it retains a visual
similarity to the underlying machine representation of a value.
Hexadecimal is a base 16 positional notation. It uses sixteen symbols.
Hexadecimal digit Binary Equivalent Decimal Equivalent
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
A 1010 10
B 1011 11
C 1100 12
D 1101 13
E 1110 14
F 1111 15
Hexadecimal notation is often abbreviated to Hex. Strictly speaking, Hex notation
would refer to a radix 6 system, but the use of such a system is so rare that you can
21 | P a g e
safely assume that Hex stands for Hexadecimal. With one hexadecimal digit, we can
represent the values 0 to F (In decimal: 0 to 15. In binary: 0000to 1111.)
Again, this is a positional notation, so the value of a hexadecimal digit is 16position.
So 0B12, in decimal notation would be:
Position Digit Value
0 2 2 * 160 = 2
1 1 1 * 161 = 16
2 B 11 * 162 = 2816
3 0 0 * 163 = 0
2+16+2816+ 0 = 2833
In practice, converting hexadecimal notation to decimal notation by hand is rare. The
utility of hexadecimal notation consists in the compact manner that it can express an
equivalent value in binary notation. Since sixteen is the fourth power of two, every
hexadecimal digit corresponds to at most four bits. In other words, since four bits can
only represent the values 0 to 15, exactly one hexadecimal digit is sufficient to represent
a four bit binary value. An eight bit BYTE requires no more than two hexadecimal digits.
A sixteen bit WORD requires no more than four hexadecimal digits. This pattern holds for
any bit length that is a multiple of four. Since four bits is half the bit length of a BYTE, four
bits is often called a NIBBLE. So we can say that one hexadecimal digit represents one
NIBBLE.
Converting a four bit binary value to decimal is a relatively simple activity. With a little
practice it can often be done mentally. This makes converting binary to hexadecimal
trivial. Here is a thirty-two bit value generated by flipping a coin with consecutive bits
shown in groups of four with a illustration of a conversion to hexadecimal. When
performed often, this becomes second nature, and the intermediate decimal notation
can usually be skipped.
Coin Tosses: HHTT THTH HHTH THHT HHHT THHT HTHH HHTT
Binary: 1100 0101 1101 0110 1110 0110 1011 1100
Decimal equivalent of each 12 5 13 6 14 6 13 12
nibble:
22 | P a g e
Hexadecimal: C5D6E6DC
To convert this value to decimal by hand would be cumbersome, and the result
depends on whether or not we are using signed or unsigned integer values. In any
event, the decimal equivalent is not simply the decimal equivalent of each NIBBLE
concatenated together. C5D6E6DC is not equivalent to 1251361461312. Using a
calculator to perform the conversion to an unsigned integer, we find that C5D6E6DC is
equivalent to decimal3319195356. Every two hexadecimal digits align neatly on byte
boundaries. This makes the memory layout of hexadecimal data visually obvious.
However, when viewed this way, the "endian-ness" of the system must be considered.
On the x86 architecture, multi-byte values are stored in memory in the little endian
format, which means that less significant bytes are stored at lower addresses, so the
value C5D6E6DC would appear in memory when listed by byte address like this: DC, E6,
D6, C5.
Hexadecimal notation also helps highlight certain prominent bit patterns.
0 all bits clear 0000
F all bits set 1111
even low bit clear xxx0
odd low bit set xxx1
<=7 high bit clear 0xxx
>=8 high bit set 1xxx
The last two patterns, 0xxx and 1xxx, are useful when examining signed integer data
because the hightest bit in the most significant BYTE is used as the "sign bit" and
determines whether or not the value will be regarded as a negative number.
Octal
The octal notation is a base 8 positional notation. Valid digits are 0,1,2,3,4,5,6,7.
Note particularly, that the symbol "8" is not an octal digit.
This notation was much more common before 8 bits became the de facto standard
size of a BYTE. The interesting characteristic of the octal notation is that any
combination of three bits requires at most one octal digit. Following the same method
23 | P a g e
used above, we can determine that the highest unsigned value that n octal digits can
represent is 8n-1.
Numerical Notation Syntax
The lexical conventions for specifying different numerical notations differs from one
programming language to another. Some languages support more than one
convention. Some languages do not support certain notations at all. This table
demonstrates the representation of the ASCII character code for a blank space in a
number of different languages.
Language Hexadecimal Decimal Octal Binary
Ansi C 0x20 32 040 N/A
FreeBASIC &h20 32 &o40 &b00100000
Gas ( GNU assembler) 0x20 32 040 0b00100000
Nasm (Netwide Assembler) 20h 32d 40o 00100000b
20x 32t 40q 00100000y
0x20 0t32 0q40 0y00100000
0h20 0d32 0o40 0b00100000
$20 32
ECMAscript (Javascript) 0x20 32 n/a n/a
Python 0x20 32 0o40 0b00100000
040
Displaying values in different notations:
24 | P a g e
12
45
1274
1000000
-3
-5735
Real Numbers
Any number that you could place on a number line is a real number. Real numbers
include whole numbers (integers) and numbers with decimal/fractional parts. Real
numbers can be positive or negative.
Examples
1
1.4534
946.5
-0.0003
3.142
You might see this data type referred to as 'single', 'double' or 'float'.
Currency
25 | P a g e
Currency refers to real numbers that are formatted in a specific way. Usually currency is
shown with a currency symbol and (usually) two decimal places.
Examples
£12.45
-£0.01
€999.00
$5500
Percentage
Percentage refers to fractional real numbers that are formatted in a specific way - out
of 100, with a percent symbol. So, the real value 0.5 would be shown as 50%, the
value 0.01 would be shown as 1% and the number 1.25 would be shown as 125%
Examples
100%
25%
1200%
-5%
Inside the computer the 50% is stored as a real number: 0.5, But when it is displayed it is
shown formatted as a percentage
Alphanumeric (Text) Data
26 | P a g e
Alphanumeric (often simply called 'text') data refers to data made up of
letters (alphabet) and numbers (numeric). Usually symbols ($%^+@, etc.) and spaces
are also allowed.
Examples
DOG
“A little mouse”
ABC123
Text data is often input to a computer with speech marks (". . .") around it:
"MONKEY"
These tell the computer that this is text data and not some special command.
Date and Time Data
Date (and time) data is usually formatted in a specific way. The format depends upon
the setup of the computer, the software in use and the user’s preferences.
Date Examples
25/10/2007
12 Mar 2008
10-06-08
Time Examples
11am
15:00
3:00pm
17:05:45
27 | P a g e
With inputting dates particular care has to be taken if the data contains American style
dates and the computer is setup to expect international style dates (or vice-versa)...
The date 06/09/08 refers to 6th September 2008 in the international system, but would
be 9th June 2008 in America! Check your computer’s settings.
Boolean (Logical) Data
Boolean data is sometimes called 'logical' data (or in some software, 'yes/no' data).
Boolean data can only have two values: TRUE or FALSE
Examples
TRUE
FALSE
ON
OFF
YES
NO
Note that TRUE and FALSE can also be shown as YES / NO, ON / OFF, or even graphically
as tick boxes(ticked / unticked)
Selecting Data Types
28 | P a g e
When we are presented with data to be input into a computer system, we must analyse
it and select appropriate data types for each value... e.g. For the following data, we
might use the date types shown:
Data Name
Name
Height
Date of Birth
Phone No.
Pay Rate
Tax Rate
Data Type
Text
Real
Date
Alphanumeric
Currency
Percentage
Logical Operators
32 | P a g e
Common Lisp provides three operators on Boolean values: and, or, and not. Of
these, and and or are also control structures because their arguments are evaluated
conditionally. The function not necessarily examines its single argument, and so is a
simple function.
The logical operators are described in the following table:
Operator Usage Description
Logical expr1 &&expr2 Returns expr1 if it can be converted to false; otherwise,
AND returns expr2. Thus, when used with Boolean
(&&) values, && returns true if both operands are true; otherwise,
returns false.
Logical expr1 ||expr2 Returns expr1 if it can be converted to true; otherwise,
OR (||) returns expr2. Thus, when used with Boolean
values, || returns true if either operand is true; if both are
false, returns false.
Logical !expr Returns false if its single operand can be converted to true;
NOT (!) otherwise, returns true.
Fortran has five LOGICAL operators that can only be used with expressions whose results
are logical values (i.e., .TRUE. or .FALSE.). All LOGICAL operators have priorities lower
than arithmetic and relationaloperators. Therefore, if an expression involving arithmetic,
relational and logical operators, the arithmetic operators are evaluated first, followed
by the relational operators, followed by the logical operators.
These five logical operators are
.NOT. : logical not
.AND. : logical and
.OR. : logical or
.EQV. : logical equivalence
.NEQV. : logical not equivalence
33 | P a g e
SESSION 3.
Learning Outcomes
1. The description identifies different algorithmic structures of programming
languages.
2. The description identifies good program documentation principles (at least 3).
3. The description identifies programming quality assurance (QA) principles.
4. The description distinguishes between validation and verification.
5. The description explains the relationship between files, records and fields.
34 | P a g e
All actions must be taken in sequence.
The action elements themselves may be structures
However, it is important to note that one or more of the action elements may
themselves be sequence, selection, or loop structures. If each of the structures that
make up the sequence has only one entry point and one exit point, each such
structure can be viewed as a single action element in a sequence of actions.
Obviously, the sequence structure is the simplest of the three.
The selection structure
The selection or decision structure can be described as shown in the pseudocode The
selection structure in pseudocode.
Enter
Test a condition for true or false
On true
Take one or more actions in sequence
On false
Take none, one, or more actions in sequence
Exit
Test a condition for true or false
Once again, there is only one entry point and one exit point. The first thing that
happens following entry is that some condition is tested for true or false. If the condition
is true, one or more actions are taken in sequence and control exits the structure. If the
condition is false, none, one or more different actions are taken in sequence and
control exits the structure. (Note the inclusion of the word none here.)
The action elements may themselves be structures
Once again, each of the action elements in the sequence may be another sequence,
selection, or loop structure. Eventually all of the actions for a chosen branch will be
completed in sequence and control will exit the structure.
Sometimes no action is required on false
It is often the case that no action is required when the test returns false. In that case,
control simply exits the structure without performing any actions.
The loop structure
35 | P a g e
The loop or iteration structure can be described as shown in the pseudocode
The loop structure in pseudocode.
Enter
Test a condition for true or false
Exit on false
On true
Perform one or more actions in sequence.
Go back and test the condition again
As before, there is only one entry point and one exit point.
Perform the test and exit on false
The first thing that happens following entry is that a condition is tested for true or false.
If the test returns false, control simply exits the structure without taking any action at all.
Perform some actions and repeat the test on true
If the test returns true:
One or more actions are performed in sequence.
The condition is tested again.
During each iteration, if the test returns false, control exits the structure. If the test returns
true, the entire cycle is repeated.
Each action element may be another structure
Each of the action elements may be implemented by another sequence, selection, or
loop structure. Eventually all of the actions will be completed and the condition will be
tested again.
Need to avoid infinite loops
Generally speaking, unless something is done in one of the actions to cause the test to
eventually return false, control will never exit the loop.
In this case, the program will be caught in what is commonly referred to as an infinite
loop.
36 | P a g e
The description identifies good program documentation principles (at least 3).
Internal documentation
The variable declaration comments are one part of good internal documentation.
Internal documentation is the set of comments that are included within the code to
help clarify algorithms. Some students take internal documentation to mean that they
should comment each line of code! This is obviously an example of overdoing a good
idea. Any programmer knows how to increment a value in a variable; there's no reason
to explain trivial operations such as that. The value of some good internal
documentation should be clear by looking at the latest version of our sample program.
Even with the good code organization and variable names, the function of this
program is still not obvious.
37 | P a g e
1. "Block comments" (comments that are several lines long) should be placed at the
head of every subprogram. These will include the subprogram name; the purpose of
the subprogram; and a list of all parameters, including direction of information
transfer (into this routine, out from the routine back to the calling routine, or both),
and their purposes.
2. Meaningful variable names. In a nod to tradition, simple loop variables may have
single letter variable names, but all others should be meaningful. Never use
nonstandard abbreviations.
3. Each variable and constant must have a brief comment next to its declaration that
explains its purpose. This applies to all variables, as well as to fields of struct
declarations.
4. Complex sections of code and any other parts of the program that need some
explanation should have comments just ahead of them or embedded in them.
The trick with internal documentation is to make it easy to find while at the same time
ensuring that it's not making the code hard to read. Block comments can be partially
boxed (as shown) to separate them from the code. The use of the '*' at the start of
each line of the shorter clarifying comments in the code serves a similar purpose. There's
no one right way to do this, but it does need to be done. Experiment with some styles
and pick one you like. One piece of advice: Don't fall in love with the "complete box"
style. Lots of students like to completely enclose the block comments within a box. This
38 | P a g e
looks great, but the right-hand wall of the box is very hard to keep lined up as you make
adjustments and additions to the comments. The "three wall" style shown above is much
easier to deal with and looks almost as good.
External documentation
In a professional programmer's shop, large projects are documented in great detail, not
only with comments in the code but with descriptions that are maintained separately
from the code. In such an environment, programmers are often asked to fix problems in
code that they didn't write. Many times, the author of the code isn't even with the
company any longer. The documentation may be all the programmer has as reference
material to help him or her make the necessary modifications. External documentation
doesn't deal with details of the code. Instead, it serves as a general description of the
project, including such information as what the code does, who wrote it and when,
which common algorithms it uses, upon which other programs or libraries it is
dependent, which systems it was designed to work with, what form and source of input
it requires, the format of the output it produces, etc. Often the external documentation
will include structure charts of the outline of the program that were produced when the
program was being designed. All of this information is necessary to help other
programmers understand the program. One seemingly innocent change in a program
can have unpredictable consequences on other parts of the system. Good
documentation can help prevent such problems.
39 | P a g e
3. Approach used to solve the problem. This should always include a brief description
of the major algorithms used, or their names if they are common algorithms.
4. The program's operational requirements: Which language system you used, special
compilation information, where the input can be located on disk, etc.
5. Required features of the assignment that you were not able to include.
6. Known bugs should be reported here as well. If a particular feature does not work
correctly, it is in your best interest to be honest and complete about your program's
shortcomings.
The final version of the program is given at the end of this document. Look it over
carefully. Do you understand what the program does? More importantly for this
discussion, do you understand how it does it? If the indentation, identifier names, and
documentation helped, then they were well worth the time it took the programmer to
put them in. Hopefully, you'll now see the value of putting such documentation in your
programs as well. Take the time to ask yourself if you think the design of the comments
is a good one; are the comments easy to find and to read? Do they distract from the
code excessively? Are there too many of them to suit you, or too few? By asking and
answering questions such as these, you will begin to develop a style of your own. When
you see documentation styles that you like, consider adopting them into your own style.
Soon you'll have one you like, and as a result you'll be more likely to use it.
There are plenty of decisions that were made in the design and documentation of this
program that can be questioned and improved on. As you gain more experience in
programming, consider revisiting this program and trying to rewrite it from scratch.
Perhaps you can think of a better way to generate the times, for example. There isn't a
program in existence that can't be improved, and this one is certainly no exception.
Software Quality
There are many attributes of software quality. These include:
1. Effectiveness
2 Usability
3. Efficiency
4. Reliability
5. Maintainability
6. Understandability
7. Modifiability
8. Testability
Modifiability Means that it is relatively easy to identify and change any part of the
system that requires maintenance without affecting its other parts.
Testability Is the ease with which we can demonstrate that a modification resulted in a
quality system.
The following are the principal aspects of TQM - oriented quality assurance for
information systems:
1. Customer focus is achieved by involving end users in the IS development process,
particularly during its early stages when the requirements for the system are being
defined. Systems prototyping and joint application development (JAD) are the
principal techniques applied to this end. Joint Application Development (JAD) is an
organizational technique for conducting meetings between the prospective users of an
information system and its developers.
2. The life-cycle oriented systems development, with the inclusion of prototyping, is a
process that lends itself to control, measurement, and continuous improvement.
Support with CASE tools helps to ensure product quality.
43 | P a g e
3. Software development and maintenance teams are the primary human element in
ensuring software quality.
4. The quality measurement program can assist in consistent striving for higher quality
levels. Such a program rests on the foundation of software metrics. Software matrices
include techniques for measuring the attributes of software and techniques for
measuring the attributes of software development process.
The description explains the relationship between files, records and fields.
What is a Record?
The set of data associated with a single object or person is known as a record. In the
example of our students, the data associated with each student is a record.
Here is Jess's record...
Each student has their own record just like Jess's but with different data. The data in
each record is different, but each record has the same structure. (each one has a
45 | P a g e
name, d.o.b., phone, etc.) We say that each record contains the same fields. A
database is a collection of records. You can imagine a single record being a card with
one the details of one person/object written on it.
This is exactly how a lot of old, manual databases used to look. If you went to a public
library 30 years ago, and you wanted to find a specific book, you would have to look
through boxes of index cards until you found the details of your book.
What is a Field, and What is a Field Name?
You'll see that each of our student's records contain the same items. These items are
known as fields. Each field has a field name (e.g. 'Date of Birth') Each field will
contain different data in each of the records (e.g. in Jess's record, the Phone field
contains 7564356, but in Sita's record the Phone field contains 8565634 - same field,
different data values) It can be a bit confusing - what's the difference between the
field, the field name, and the data in the field?! Imagine that you were manually filling
in a record card for Jess. The card would have various labels and boxes to write in...
46 | P a g e
The field is the box that you would write in
The field name is the label next to the box
The data is what you would write in the box
47 | P a g e
SESSION 4.
Learning Outcomes
The description identifies methods of specifying problems.
The description explains techniques used to research problems in terms of inputs and
outputs.
The description includes an evaluation of the viability of developing computer
programs to solve problems and it identifies the issues in assessing the viability.
The description explains the features of a computer program that could solve a
given problem.
48 | P a g e
Top-down and bottom-up are both strategies of information processing and knowledge
ordering, used in a variety of fields including software, humanistic and scientific theories
( systemic), and management and organization. In practice, they can be seen as a
style of thinking and teaching.
A top-down approach (also known as stepwise design or deductive reasoning,[1] and in
many cases used as a synonym of analysis or decomposition) is essentially the breaking
down of a system to gain insight into its compositional sub-systems. In a top-down
approach an overview of the system is formulated, specifying but not detailing any first-
level subsystems. Each subsystem is then refined in yet greater detail, sometimes in
many additional subsystem levels, until the entire specification is reduced to base
elements. A top-down model is often specified with the assistance of "black boxes",
these make it easier to manipulate. However, black boxes may fail to elucidate
elementary mechanisms or be detailed enough to realistically validate the model. Top
down approach starts with the big picture. It breaks down from there into smaller
segments.[
A bottom-up approach (also known as inductive reasoning, and in many cases used as
a synonym of synthesis) is the piecing together of systems to give rise to grander
systems, thus making the original systems sub-systems of the emergent system. Bottom-
49 | P a g e
up processing is a type of information processing based on incoming data from the
environment to form a perception. Information enters the eyes in one direction (input),
and is then turned into an image by the brain that can be interpreted and recognized
as a perception (output). In a bottom-up approach the individual base elements of the
system are first specified in great detail. These elements are then linked together to form
larger subsystems, which then in turn are linked, sometimes in many levels, until a
complete top-level system is formed. This strategy often resembles a "seed" model,
whereby the beginnings are small but eventually grow in complexity and
completeness. However, "organic strategies" may result in a tangle of elements and
subsystems, developed in isolation and subject to local optimization as opposed to
meeting a global purpose.
The description explains the features of a computer program that could solve a given
problem.
50 | P a g e
Batch processing is execution of a series of programs ("jobs") on a computer without
manual intervention. Jobs are set up so they can be run to completion without manual
intervention. So, all input data are preselected through scripts, command-line
parameters, or job control language. This is in contrast to "online" or interactive
programs which prompt the user for such input. A program takes a set of data files as
input, processes the data, and produces a set of output data files. This operating
environment is termed as "batch processing" because the input data are collected
into batches of files and are processed in batches by the program.
51 | P a g e
52 | P a g e
The mouse pointing device sits on your work surface and
is moved with your hand. In older mice, a ball in the
bottom of the mouse rolls on the surface as you move the
mouse, and internal rollers sense the ball movement and
transmit the information to the computer via the cord of
the mouse.
Two-button mouse with scroll
The newer optical mouse does not use a rolling ball, but
wheel
instead uses a light and a small optical sensor to detect
the motion of the mouse by tracking a tiny image of the
desk surface. Optical mice avoid the problem of a dirty
mouse ball, which causes regular mice to roll unsmoothly
if the mouse ball and internal rollers are not cleaned
frequently.
A cordless or wireless mouse communicates with the
computer via radio waves (often
Wireless Macintosh mouse
using BlueTooth hardware and protocol) so that a cord is
not needed (but such mice need internal batteries).
A mouse also includes one or more buttons (and possibly
a scroll wheel) to allow users to interact with the GUI. The
traditional PC mouse has two buttons, while the
traditional Macintosh mouse has one button. On either
type of computer you can also use mice with three or
more buttons and a small scroll wheel (which can also
usually be clicked like a button).
Touch pad
Most laptop computers today have a touch pad pointing
device. You move the on-screen cursor by sliding your
finger along the surface of the touch pad. The buttons
are located below the pad, but most touch pads allow
you to perform “mouse clicks” by tapping on the pad
53 | P a g e
itself.
Touch pads have the advantage over mice that they
take up much less room to use. They have the
advantage over trackballs (which were used on early
laptops) that there are no moving parts to get dirty and
result in jumpy cursor control.
The description explains techniques used to research problems in terms of inputs and
outputs.
An actor in the Unified Modeling Language (UML) "specifies a role played by a user or
any other system that interacts with the subject. "An Actor models a type of role played
by an entity that interacts with the subject (e.g., by exchanging signals and data), but
which is external to the subject. “Actors may represent roles played by human users,
external hardware, or other subjects. Note that an actor does not necessarily represent
a specific physical entity but merely a particular facet (i.e., “role”) of some entity that is
relevant to the specification of its associated use cases. Thus, a single physical instance
may play the role of several different actors and, conversely, a given actor may be
played by multiple different instances. UML 2 does not permit associations between
Actors. The use of generalization/specialization relationship between actors is useful in
modeling overlapping behaviours between actors and does not violate this constraint
since a generalization relation is not a type of association. Actors interact with use
cases.
54 | P a g e
So the following are the places where use case diagrams are used:
Requirement analysis and high level design.
Model the context of a system.
Reverse engineering.
Forward engineering.
55 | P a g e
The description includes an evaluation of the viability of developing computer
programs to solve problems and it identifies the issues in assessing the viability.
Testing the Program
Some experts insist that a well-designed program can be written correctly the first time.
In fact, they assert that there are mathematical ways to prove that a program is
correct. However, the imperfections of the world are still with us, so most programmers
get used to the idea that their newly written programs probably have a few errors. This is
a bit discouraging at first, since programmers tend to be precise, careful, detail-
oriented people who take pride in their work. Still, there are many opportunities to
introduce mistakes into programs, and you, just as those who have gone before you,
will probably find several of them. Eventually, after coding the program, you must
prepare to test it on the computer. This step involves these phases:
Desk-checking. This phase, similar to proofreading, is sometimes avoided by the
programmer who is looking for a shortcut and is eager to run the program on the
computer once it is written. However, with careful desk-checking you may discover
several errors and possibly save yourself time in the long run. In desk-checking you
simply sit down and mentally trace, or check, the logic of the program to attempt to
ensure that it is error-free and workable. Many organizations take this phase a step
further with a walkthrough, a process in which a group of programmers-your peers-
review your program and offer suggestions in a collegial way.
Translating. A translator is a program that (1) checks the syntax of your program to
make sure the programming language was used correctly, giving you all the syntax-
error messages, called diagnostics, and (2) then translates your program into a form the
computer can understand. A by-product of the process is that the translator tells you if
you have improperly used the programming language in some way. These types of
mistakes are called syntax errors. The translator produces descriptive error messages. For
instance, if in FORTRAN you mistakenly write N=2 *(I+J))-which has two closing
parentheses instead of one-you will get a message that says, "UNMATCHED
PARENTHESES." (Different translators may provide different wording for error messages.)
Programs are most commonly translated by a compiler. A compiler translates your
entire program at one time. The translation involves your original program, called a
56 | P a g e
source module, which is transformed by a compiler into an object module. Prewritten
programs from a system library may be added during the link/load phase, which results
in a load module. The load module can then be executed by the computer.
Debugging. A term used extensively in programming, debugging means detecting,
locating, and correcting bugs (mistakes), usually by running the program. These bugs
are logic errors, such as telling a computer to repeat an operation but not telling it how
to stop repeating. In this phase you run the program using test data that you devise.
You must plan the test data carefully to make sure you test every part of the program.
57 | P a g e