0% found this document useful (0 votes)
44 views27 pages

Understanding Computational Thinking Concepts

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views27 pages

Understanding Computational Thinking Concepts

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Page | 1

Page | 2
9.1 Computational Thinking Skills complexity.
Q 1) What is meant by computational thinking? The benefits of abstraction:
Computational Thinking - is used to study a • the time required to develop the program is
problem and formulate an effective solution reduced so the program can be delivered to
that can be provided using a computer. There the customer more quickly
are several techniques used in computational • the program is smaller in size so takes up
thinking, including abstraction, decomposition, less space in memory and download times
and pattern recognition. are shortened
• customer satisfaction is greater as their
Q 2) Define Abstraction, Decomposition and requirements are met without any extraneous
pattern recognition. features.
Abstraction – the process of extracting
information that is essential, while ignoring Q 3c) Stepwise refinement is often used in the
what is not relevant, for the provision of a development of an algorithm.
solution. Describe stepwise refinement.
Decomposition – the process of breaking a Stepwise refinement – is the practice of
complex problem into smaller parts. subdividing each part of a larger problem into
Pattern recognition – the identification of a series of smaller parts, and so on, as
parts of a problem that are similar and could required.
use the same solution. Benefits of Stepwise refinement:
Increases the level of detail of the algorithm
Q 3a) Give reason/benefits for Make steps easier to solve
decomposition (breaking down a problem). to be directly translated into lines of code
Program code is easier to implement.
Different people can be assigned to work on Q 4) What is system and sub-system?
different modules A system is a set of rules, an arrangement of
Program code is easier to test and debug. things, or a group of related things that work
Modules are re-usable. together to perform a function.
A system is made up of a number of
Q 3b) Describe need for and benefits of using subsystems. Each subsystem can be further
abstraction, Describe the purpose of divided into subsystems and so on until each
abstraction. sub-system just performs a single action.
Abstraction involves filtering out information Computer system is often divided up into sub-
that is not necessary to solve a problem. systems. This division can be shown using top-
Abstraction gives us the power to deal with down design to produce structure diagrams
Page | 3
that demonstrate the modular construction of programmer can transfer from one language
the system. to another.
Programmer should be able to recognise /
Q 5) Define System and Sub-system. understand in another language:
System is a set of principles or procedures • Declaration, assignment, sequence,
according to which something is done; an selection, repetition (iteration)
organized scheme or method. Subroutines, Parameters passed between
A system is a set of rules, an arrangement of modules
things, or a group of related things that work program structure, Input and Output
together to perform a function.
A system is made up of a number of Q 8) Describe Structure Diagrams
subsystems. Each subsystem can be further The STRUCTURE DIAGRAM shows the
divided into subsystems and so on until each design of a computer system in a hierarchical
sub-system just performs a single action. way, with each level giving a more detailed
breakdown of the system into sub-systems.
Q 6) What is meant by computer system?
A COMPUTER SYSTEM is made up of
hardware, software & data, communications
and people; each computer system can be
divided up into a set of sub-systems. Each
subsystem can be further divided into sub-
systems and so on until each sub-system just
performs a single action.
Q 9) A structure chart is often used in modular
Q 7) Define Top-Down Design program design.
Top-down design is the breaking down of a State four features of structure diagram:
computer system into a set of subsystems, Feature 1: Sequence of operation
then breaking each sub-system down into a Feature 2: Selection of modules
set of smaller sub-systems, until each sub- Feature 3: Repetition
system just performs a single action. Feature 4: Parameters

Q 8) What is transferable skills? Explain Q 10) Define Library routines


how it helps in work on not familiar A LIBRARY ROUTINE is a set of
programming language. programming instructions for a given task that
Transferable skills, are the abilities is already available for use. It is pre-tested
Page | 4
and usually performs a task that is frequently Algorithm is a step by step design of a
required. solution. Flowchart and pseudo code are two
different representations of algorithm.

Q 11) Define Sub-routines


A SUB-ROUTINE is a set of programming Q 2) What is meant by Pseudo code?

instructions for a given task that forms a PSEUDO CODE is a simple method of

subsystem, not the whole system. Sub- showing an algorithm, using English-like

routines written in high-level programming words and mathematical operators that are

languages are called ‘procedures’ or set out to look like a program.

‘functions’ depending on how they are used.


Q 2) What are data types? Why they are
Q 11b) State three advantages of using built- needed?
in functions. A data type is a classification of data which
Saves development time, no need to write tells the compiler or interpreter how the
it again. programmer intends to use the data. Most
Pre-compiled and well tested, more programming languages support various
reliable, less chance of error types of data, including integer, real, character
Available to all programs or string, and Boolean.
Before a variable can be used in a program,
Q 12) What is meant by Function? the variable’s data type has to be identified.
A Function is a sub-routine that always
returns a value. Q 3) What are atomic data types?
The built in data types are called Atomic
Q 13) What is meant by Procedure? Data Types. For example Integer, Real,
A Procedure is a sub-routine that doesn’t Boolean, String, Char, Date etc.
have to returns a value.

Q 14) Differentiate terms Paramenter and


Argument.
A parameter is a variable in a method
definition. While the arguments are the data
that are passed.

9.2 Algorithm
Q 1) Define algorithm.
Page | 5
Q 4) What are User-Defined Data Types? special characters but number cannot be
A user-defined data type is a data type for used in calculation.
which the programmer has included the For example, “Inqilab Patel”, “0300-2724734”,
definition in the program. Here user means “House No 56 Block 2, PECHS Karachi”
user of programming language i.e. the 5. BOOLEAN: A data type with two possible
programmer. values
Once the data type has been defined, For example, TRUE and FALSE or YES or NO
variables can be created and associated with 6. DATE: To store a calendar date
the user-defined data type. For example, 16/04/2010

Q 5) Why are User defined data types are Q 7) Differentiate variable and constant.
needed? Variable is memory location where a value can
Sometime built-in data types are not fulfilling be stored. The values stored in a variable are
the requirements of a programmer then needs changed during execution.
to define own data type. Constant is a memory location that stores
values, but values once stored cannot be
Q 6) Describe different data types with changed during program execution.
examples.
The following keywords are used to designate Q 8) What are identifier, also describe rules
atomic data types: for deciding identifiers?
1. INTEGER: A whole number (without Identifiers are the names given to variables,
fractional part) can be positive or negative constants, procedures and functions.
and used in calculations. They are in mix case. They can only contain
For example, COUNT which never requires letters (A–Z, a–z), digits (0–9) and underscore
fractional part and may store 56, 89, 1 (_). They must start with a letter and not a
2. REAL: A number capable of containing a digit.
fractional part can be positive or negative
and used in calculations.
For example, Weight may contain fractional
Part like 56.8, 89.0, 1.2
3. CHAR: A single character (may be letter,
special character or number but number
cannot be used in calculation).
For example, ‘A’, ‘$’, ‘5’
4. STRING: A sequence of alphanumeric and
Page | 6
Q 9) What are Arithmetic operators? Count
Standard arithmetic operator symbols are
used: Terminator used at START
and END of the flowchart
 + : Addition
 - : Subtraction
Process Box: Rectangle
 * : Multiplication
 / : Division
 MOD : Division to calculate remainder Input / Output Box:
Parallelogram
 DIV : Integer division

Q 10) What are logic operators? What are Decision Box (IF and
their operands? CASE Selection, Loops)
Rhombus
The only logic operators used are AND, OR
and NOT. The operands and results of these
operations are always of data type
Function / Procedure CALL
BOOLEAN.

TOTALLING is used to calculate running total.


Q 17) Define flowchart and draw symbols
We can use a variable such as Total or Sum to
A flowchart is a graphical representation of
hold the running total and assignment
algorithm.
statements such as:
The following are recognised flowchart
Total ← Total + Number
symbols:
(new) (old)
i.e. ADD Number to (old) Total to obtain (new)
Q 18) Describe Counting and Totalling.
Total
Counting is used to find how many items are
there by incrementing by 1 during each time
Q 19) What is a program?
loop is executed.
A program is a sequence of instructions or
It is sometimes necessary to count how many
programming language statements written to
times something happens.
make a computer perform certain tasks.
To count up or increment by 1, we can use
statements such as:
Count ← Count + 1
(new) (old)
i.e. INCREMENT (old) Count by 1 to get (new)
Page | 7
Q 20) What are basic Control Constructs: Explain different types of selection
Following are the basic constructs of statements?
algorithm and program which controls Selection (Condition) determines program
execution of statements: flow path on the basis of given condition.
1. Sequence It also decides which statement(s) are to be
2. Assignment executed depending upon the result of a given
3. Selection condition.
4. Iteration IF and CASE selections are two different types
of selection statements

Q 21) Describe what is meant by sequence. IF statements are used when there are one or

Sequence: One statement is being executed two options.

after another in the order they are written. When there is only one option IF statements

In following example statement number ‘i’ will without an ELSE clause is written as follows:

be executed at 1st and then ‘ii’ then ‘iii’ and at


last statement number ‘iv’ will be executed: IF Number>Largest THEN

I. INPUT Num1 LargestNumber

II. INPUT Num2 ENDIF

III. Total  Num1 + Num2 When there are two options IF statements with

IV. PRINT Total an ELSE clause is written as follows:


IF Marks>=50 THEN

Q 22) Describe Assignment with example Result  “Pass”

statements. ELSE

Assignment: Storing values in a variable is Result  “Fail”

known as assignment. ENDIF

The assignment operator is ←. CASE statements is a conditional statement

Assignments should be made in the following to deal with many possible outcomes.

format: CASE statements allow one out of several

<identifier> ← <value> branches of code to be executed, depending

For example: on the value of a variable.

Counter ← 0 In case selection number of statements are

Counter ← Counter + 1 reduced so code become more simplified.

TotalToPay ← NumberOfHours *
HourlyRate
Q 23) What is meant by Selection/Condition,
Page | 8
CASE statements are written as follows: condition evaluates to TRUE. After the
CASE Marks OF statements have been executed the condition
>=90: Grade  “A*” is tested again. The loop terminates when the
>=80: Grade  “A” condition evaluates to FALSE.
>=70: Grade  “B” The statements may not be executed even
>=60: Grade  “C” once if, on the first test, the condition
>=50: Grade  “D” evaluates to FALSE.
>=40: Grade  “E” Example: To input a series of numbers and
OTHERWISE : : Grade  “U” calculate total and stops if a –ve number is
ENDCASE entered:
The condition is checked at the beginning of

Q 24) What is meant by Loop (Repetition or the loop. If condition is true loop statements are

iteration)? executed again and again.

Iteration (Loop or Repetition) is used to Total0


INPUT Num
execute a set of instructions multiple times. WHILE Num>0 DO
There are following three types of loops: Total Total + Num
INPUT Num
1. Count-controlled loop END WHILE
2. Pre-condition loop
3. Post-condition loop Q 27 What are post condition loop?
Post-condition (REPEAT UNTIL) loop is a

Q 25) Describe Count Controlled Loop. loop in which condition is given at the end of

Count-controlled (FOR) loops loop and which is executed only when the

Count-controlled loop is used when the condition is false.

number of repetition is already known. The statements in the loop will be executed at

For example to input 5 numbers: least once. The condition is tested after the

FOR Count  1 TO 5 statements are executed and if it evaluates to

INPUT Num TRUE the loop terminates, otherwise the

NEXT Count statements are executed again.


Example: To input and validate a number and

Q 26) What are pre-condition (WHILE) loops? to reject it if a negative number is entered and

A loop in which condition is given at the start ask to re-enter another number

of loop and which is executed only when the The condition is checked at the end of the loop.

condition is true, is called pre-condition loop. If condition is false, loop statements are

The condition is tested before the statements, executed again and again.

and the statements will only be executed if the


Page | 9
REPEAT Q 1) Define Data verification.
INPUT Num
Verification is performed to ensure that the
UNTIL Num>0
data entered exactly matches the original

Difference between Loop structures source. Verification means checking the

FOR … WHILE … REPEAT … input data with the original data to make sure

TO… NEXT ENDWHILE UNTIL that there have been no transcription errors
(transcription means copying the data).
Count- Pre-Condition Post
Verification methods include:
Controlled Loop Condition
loop Loop At the time of entry At the time of
transmission
Number of Executed Executed
repetition is when when Double entry Parity check

already condition is condition is Screen/visual check Checksum.

known TRUE FALSE ARQ

Executed a May not be Executed at Echo Check

set number executed least ONCE Q 2) What is validation?

of times even ONCE Validation is an automatic computer check to


ensure that the data entered is sensible and

Validation and Verification reasonable. It does not check the accuracy of

Validation and verification are two ways to data.

check that the data entered into a computer is


However, this does not guarantee that the
correct. Data entered incorrectly is of little
number typed in is correct. For example, a
use.
student's age might be 14, but if 11 are
entered it will be valid but incorrect.

A validation check is a rule that is built into a


database to check that the data entered is:
 Sensible
 Reasonable
 Within acceptable boundaries
 Complete
It does NOT mean that the data is actually
correct, that requires verification.
Page | 10
Q 3) Describe different types of validation 7 Length Checks - ensures that such data is
checks. either an exact length or does not exceed a
There are a number of different validation specified number of characters.
rules: 8 Lookup - A lookup check takes the value
1 Type Checks – Checks that the data entered and compares it against a list of
entered is of a given data type. values in a separate table.
For example, string data entered in integer 9 Check digits - The last one in a code are u
field or variable will be rejected. sed to check the other digits are correct.
2 Range checks - these are used to limit the Bar code readers in supermarkets use check
range of data a user can enter. The 'day' part digits.
of a date must be in the range 1 to 31. An length check – e.g. only 30 characters in
exam grade should be in the range 'A'...'E' or name field
'U'. character check – e.g. name doesn’t contain
3 Limit Check - Similar to Range Check but numeric chars
the rule involves only one limit. range check – e.g. day of month in date is
For example, >=0 means reject negative between 1 and 31
numbers. Date of birth must not be later than format check – e.g. date in the form xx/yy/zz
a date. check digit – e.g. end digit on bar code to
4 Character Check - Checks that when a check if it is valid
string of characters is entered it does not type check – e.g. integer, real
contain any invalid characters or symbols. presence check = field is not left blank
For example a name would not contain digit Test Data
or special character. Test data is the data that is used in testing of a
5 Format Check - Checks the data is in the software system.
right format. Values must conform to a specific In order to test a software application, we need
pattern, for example, two letters followed by six to enter some data for testing most of the
digits followed by a single letter. features. Any such specifically identified data
A candidate number, PK-500-1234 or National which is used in tests is known as test data.
Insurance number is in the form LL 99 99 99 L There are following three types of test data:
where L is any letter and 9 is any number. for 1. Normal Data is the data a computer
Date dd/mm/yyyy or mm/dd/yyyy system should work on. Testing needs to
6 Presence checks - these simply check that be done to prove that the solution works
an entry has been made in a particular field correctly.
i.e. a null value (empty field) is not permitted. For example, here is a set of normal test data
for an algorithm to record the percentage
Page | 11
marks from 10 end-of-term examinations for a 3. Extreme Data are the largest and smallest
student and find their average mark: values that normal data can take.
Normal test data: 50, 50, 50, 50, 50, Extreme data: 0, 100
50, 50, 50, 50, 50 Expected results: these values should be
Expected result: 50 accepted
4. Boundary Data is used to establish where
2. Abnormal/Erroneous Data is the data the largest and smallest values occur. For
that should cause the system to tell the example, for percentage marks in the
user that there is a problem with data range 0 to 100, the algorithm should be
entered into the system. tested with the following boundary data; at
This test data should be rejected as the each boundary two values are required,
values are not suitable. one value is accepted and the other value
This type of test data is called ERRONEOUS is rejected.
or ABNORMAL TESTDATA; it should be Boundary data for 0 is –1, 0 and for 100 is
rejected by the solution. 100, 101
For example to input positive numbers: Expected results: –1 and 101 are rejected, 0
Erroneous/abnormal data:–12, eleven and 100 are accepted
Expected results: these values should be Rogue Values A value that stops input is
rejected called Rogue Value.
A rogue value lets the computer know that a
sequence of input values has come to an end.
Page | 12
10 Data Types and structures
Records, Arrays Files, ADT

Data type – a classification attributed to an comparing adjacent items and swapping them
item of data, which determines the types of if they are in the wrong order.
value it can take and how it can be used. File – a collection of data stored by a
Identifier – a unique name applied to an item computer program to be used again.
of data. Abstract data type (ADT) – a collection of
Record (data type) – a composite data type data and a set of operations on that data.
comprising several related items that may be Stack – a list containing several items
of different data types. operating on the last in, first out (LIFO)
Composite data type – a data type principle. Items can be added to the stack
constructed using several of the basic data (push) and removed from the stack (pop). The
types available in a particular programming first item added to a stack is the last item to
language. be removed from the stack.
Linear search – a method of searching in • Queue – a list containing several items
which each element of an array is checked in operating on the first in, first out (FIFO)
order. principle.
Bubble sort – a method of sorting data in an Items can be added to the queue (enqueue)
array into alphabetical or numerical order by and removed from the queue (dequeue). The
Page | 13
first item added to a queue is the first item to diagram , ndex of 90 in 1D array is [3], while
be removed from the queue. in 2D is [3,1].
• Linked list – a list containing several items Type: Data type of all elements in a single
in which each item in the list points to the next array have same data types.
item in the list. In a linked list a new item is Dimension: Dimension is the organisational
always added to the start of the list. structure of array. It may be 1D that has single
Arrays index or 2D that has two indexes.
Arrays are data structure used to store Lower Bound – the smallest index number
multiple data items of same data type Upper Bound – the largest index number
(homogenous) under one identifier name. Q 2) The following diagram shows four data
Square brackets are used to indicate the structures and four descriptions. [3]
array index. Draw a line to connect each data structure to
Each element in the array is identified using the correct description.
its subscript or index number. The largest Data Description
and smallest index numbers are called the structure
upper bound and lower bound of the array. A collection of related
Constant
For illustration, let's take array declaration to data
store marks of 10 students.
Marks[10] Marks[1:10] Marks[0:9] A value that can change
Q 1) Describe The terms associated with Array whilst a program is
Arrays running
Name: The identifier of the array is called Array t
Name. E.g. StudentName[] A value that never
Element: Each data item stored in array is Table changes whilst a
called element. Array can store only single program is running
types of elements.
Size: The number elements the array can A series of elements of
store. E.g. StudentName[1:30] can store 30 Variable
the same data type
names while StudentName[30] can store 31
names as by default it is 0 to 30.
after any existing data.
Index: The position of each element is
referred as Index Number. In the above
Page | 14
Q 3) Winter 21 P21
3 A programmer is writing a program to help manage clubs in a school.
Data will be stored about each student in the school and each student may join up to three clubs.
The data will be held in a record structure of type Student.
The programmer has started to define the fields that will be needed as shown in the following
table.
Field Typical value Comment
StudentID "CF1234" Unique to each student
Email “[email protected]” Contains letters, numbers and certain symbols
Club_1 1 Any value in the range 1 to 99 inclusive
Club_2 14 Any value in the range 1 to 99 inclusive
Club_3 27 Any value in the range 1 to 99 inclusive

(a) (i) Write pseudocode to declare the record structure for type Student. [3]
TYPE Student
DECLARE StudentID : STRING
DECLARE StudentID : STRING
DECLARE Club_1 : INTEGER
DECLARE Club_2: INTEGER
DECLARE Club3 : INTEGER
ENDTYPE

(ii) A 1D array Membership containing 3000 elements will be used to store the student data.
Write pseudocode to declare the Membership array. [2]
DECLARE Membership : ARRAY[1:3000] OF Student
(iii) Some of the elements of the array will be unused. [1]
Give an appropriate way of indicating an unused array element.
Any value of correct data type outside the normal range
In this example “empty” can be assigned in empty ID or email
(iv) Some students are members of less than three clubs. [1]
State one way of indicating an unused club field.
A number outside the range like here 1 to 99 is the range so any number outside the
range can be assigned.
Page | 15
Linear Search
Linear Search - is a method in which each element of the array is checked in order, from the lower
bound to the upper bound, until the item is found or the upper bound is reached.
For example, to search marks in an 1D array Marks[1:30], user has to input data to be searched.
Algorithm compares this search data with all elements of the array, starting from lower bound. If
search data matches with the element, then it displays the location of data first found and if data is
not found, it is searched at next location in the conditional loop until the data is found or it reaches
at the upper bound.
Example Code for Single Searching using Linear Search
DECLARE SearchData: REAL
DECLARE Found: BOOLEAN
DECLARE MaxIndex : INTEGER
INPUT SearchData
Found  FALSE
MaxIndex  30
Index  1
WHILE Index <=30 AND Found = FALSE
IF SearchData = Marks[Index]
THEN
Found  TRUE
ELSE
Index  Index + 1
ENDIF
ENDWHILE
IF Found = TRUE
THEN
OUTPUT “Found at”, Index
ELSE
OUTPUT “Not found”
ENDIF
Page | 16
Example Code for Multiple Searching, using Linear Search
To search and output all locations where the search data is found, a count controlled loop is used
instead of conditional loop.
DECLARE SearchData: REAL
DECLARE Found: BOOLEAN
DECLARE MaxIndex : INTEGER
INPUT SearchData
Found  FALSE
FOR Index  1 TO 30
IF SearchData = Marks[Index]
THEN
Found  TRUE
OUTPUT Index
ENDIF
NEXT Index
IF Found = FALSE
THEN
OUTPUT “not found.”
ENDIF
Bubble sort – is a method of sorting data in an array into alphabetical or numerical order by
comparing adjacent items and swapping them if they are in the wrong order.
Each element of the array is compared with the next element and swapped if the elements are in
the wrong order, starting from the lower bound and finishing with the element next to the upper
bound. The element at the upper bound is now in the correct position. This comparison is repeated
with one less element in the list, until there is only one element left or no swaps are made.
Page | 17

DELCARE Swapped: BOOLEAN


DECLARE MaxIndex, UpperBound: INTEGER
DELCARE Temp: INTEGER
Swapped  TRUE
UpperBound  5
MaxIndex  UpperBound - 1
WHILE Swapped = TRUE
Swapped  FALSE
FOR Index  1 TO MaxIndex
IF Marks[Index] > Marks[Index + 1]
THEN
Temp  Marks[Index]
Marks[Index]  Marks[Index + 1]
Marks[Index + 1]  Temp
Swapped  TRUE
ENDIF
NEXT Index
MaxIndex  MaxIndex – 1
Page | 18
12. 1 System Development Life Cycle
Program development lifecycle – the Rapid application development (RAD) – a
process of developing a program set out in type of program development cycle in which
five stages: different parts of the requirements are
analysis, design, coding, testing and developed in parallel, using prototyping to
maintenance. provide early user involvement in testing.
Analysis – part of the program development Q 1) What is the purpose of system
lifecycle; a process of investigation, leading to development life cycle?
the specification of what a program is Purpose of System Development Life
required to do. Cycle In order to develop a successful
Design – part of the program development program or suite of programs that is going to
lifecycle; it uses the program specification be used by others to perform a specific task
from the analysis stage to show how the or solve a given problem, the development
program should be developed. needs to be well ordered and clearly
Coding – part of the program development documented, so that it can be understood
lifecycle; the writing of the program or suite of and used by other developers.
programs. Stages of System Development Life Cycle
Testing – part of the program development Following are the steps of system
lifecycle; the testing of the program to make development life cycle:
sure that it works under all conditions. Analysi
Maintenance – part of the program s
development lifecycle; the process of making
Maintenan
sure that the program continues to work Design
ce
during use.
Waterfall model – a linear sequential
program development cycle, in which each Testing Coding
stage is completed before the next is begun.
Iterative model – a type of program
development cycle in which a simple subset
1. Analysis:
of the requirements is developed, then
This stage involves the process of gathering
expanded or enhanced, with the development
and interpreting facts, diagnosing problems,
cycle being repeated until the full system has
and recommending improvements to the
been developed.
system. Project goals will be further aided by
analysis of end-user information needs and
Page | 19
the removal of any inconsistencies and 4. Testing
incompleteness in these requirements. The program is run many times with different
Problem is defined and requirement sets of test data, to test that it does
specification is prepared. everything it is supposed to do in the way set
A series of steps followed by the developer out in the program design.
include:
5. Maintenance
i. Collection of facts: Obtain end user The program is maintained throughout its life,
requirements through documentation, to ensure it continues to work effectively. This
client interviews, observation, and involves dealing with any problems that arise
questionnaires. during use, including correcting any errors
ii. Scrutiny of the existing system: Identify that come to light, improving the functionality
pros and cons of the current system in- of the program, or adapting the program to
place, so as to carry forward the pros and meet new requirements.
avoid the cons in the new system.
iii. Analysis of the proposed system: Find
solutions to the shortcomings described in
step two and prepare the specifications
using any specific user proposals.
2. Design
The program specification from the analysis
stage is used to show how the program
should be developed. In this stage:
i. Identifier table is developed, variables,
constants, arrays and other data
structures are decided.
ii. Algorithm flowchart and/or pseudo
code is designed.
iii. Structure chart and state-transition
diagrams are also designed.
3. Coding
In this stage the program or set of programs
is written using a suitable programming
language.
After designing your solution, a suitable high-
level programming language is chosen.
Page | 20
1. Waterfall Model oriented projects.
This is the first model. According to the • Poor model for long and ongoing projects.
Waterfall method, the software development • Cannot accommodate changing
process goes through all the SDLC phases requirements.
with no overlapping and consists of a single • It is difficult to measure progress within
development cycle. According to the fact that stages.
it is a linear-sequential life cycle model, any • Integration is done at the very end, which
phase in the development process can begin doesn’t allow identifying potential technical or
only if the previous one is complete. business issues early.
2. Iterative Model
With the Iterative Model, only the major
requirements are known from the beginning.
Based on these, the development team
creates a quick and cheap first version of the
software. Then, as additional requirements
are identified, additional iterations of the
software are designed and built. Each
iteration goes through all the phases of the
SDLC and these cycles are repeated until
completion.

Benefits include the following.


• Simple to understand as the stages are
clearly defined.
• Easy to manage due to the fixed stages in
the model. Each stage has specific
outcomes.
• Stages are processed and completed one at
a time.
• Works well for smaller projects where
requirements are very well understood.
Drawbacks include the following.
• No working software is produced until late
during the life cycle.
• Not a good model for complex and object-
Page | 21
Benefits • More resources may be required.
• There is a working model of the system at a • Design issues might arise because not all
very early stage of development, which requirements are gathered at the beginning of
makes it easier to find functional or design the entire life cycle.
flaws. Finding issues at an early stage of • Defining increments may require definition
development means corrective measures can of the complete system.
be taken more quickly.
Rapid Application Development:
• Some working functionality can be
In Rapid Application Development, problem is
developed quickly and early in the life cycle.
decomposed in modules, and prototype of
• Results are obtained early and periodically.
each module is designed. A prototype is a
• Parallel development can be planned.
working model of part of the solution.
• Progress can be measured.
All modules are developed in parallel as
• Less costly to change the
prototypes and are integrated to make the
scope/requirements.
complete product for faster product delivery.
• Testing and debugging of a smaller subset
There is no detailed preplanning.
of program is easy.
Changes are made during the development
• Risks are identified and resolved during
process.
iteration.
The analysis, design, code and test phases
• Easier to manage risk – high-risk part is
are incorporated into a series of short,
done first.
iterative development cycles.
• With every increment, operational product is
delivered.
• Issues, challenges and risks identified from
each increment can be utilised/applied to the
next increment.
• Better suited for large and mission-critical
projects.
• During the life cycle, software is produced
early, which facilitates customer evaluation
and feedback.
Drawbacks
• Only large software development projects
can benefit because it is hard to break a
small software system into further small
serviceable modules.
Page | 22
Benefits. stages of testing and every test that will be
• Changing requirements can be performed for a particular program.
accommodated. Dry run – a method of testing a program that
• Progress can be measured. involves working through a program or
• Productivity increases with fewer people in a module from a program manually.
short time. Walkthrough – a method of testing a
• Reduces development time. program. A formal version of a dry run using
• Increases reusability of components. predefined test cases.
• Quick initial reviews occur. Normal test data – test data that should be
• Encourages customer feedback. accepted by a program.
• Integration from very beginning solves a lot Abnormal test data – test data that should
of integration issues. be rejected by a program.
Drawbacks include the following. Extreme test data – test data that is on the
• Only systems that can be modularised can limit of that accepted by a program.
be built using RAD. Boundary test data – test data that is on the
• Requires highly skilled limit of that accepted by a program or data
developers/designers. that is just outside the limit of that rejected by
• Suitable for systems that are component a program.
based and scalable. White-box testing – a method of testing a
• Requires user involvement throughout the program that tests the structure and logic of
life cycle. every path through a program module.
• Suitable for projects requiring shorter Black-box testing – a method of testing a
development times. program that tests a module’s inputs and
Testing Methods: outputs.
Trace table – a table showing the process of Integration testing – a method of testing a
dry-running a program with columns showing program that tests combinations of program
the values of each variable as it changes. modules that work together.
Run-time error – an error found in a program Stub testing – the use of dummy modules
when it is executed; the program may halt for testing purposes.
unexpectedly. Alpha testing – the testing of a completed or
Test strategy – an overview of the testing nearly completed program in-house by the
required to meet the requirements specified development team.
for a particular program; it shows how and Beta testing – the testing of a completed of
when the program is to be tested. off-the shelf program by a small group of
Test plan – a detailed list showing all the users before it is released.
Page | 23
Acceptance testing – the testing of a another state
completed bespoke program to prove to the finite state machine (FSM): A system that
customer that it works as required. consists of a fixed set of possible states with
Corrective maintenance – the correction of a set of allowable inputs that may change the
any errors that appear during use. state and a set of possible outputs
Perfective maintenance – the process of Guard condition: A condition which must be
making improvements to the performance of met for a transition to occur from one state to
a program. another
Adaptive maintenance – the alteration of a state : The value or the position in which a
program to perform new tasks. system is at a given point
state transition diagram : A graphical
State Transition Diagram representation of a finite state machine
Accepting state: A state the system reaches state transition table : A table that shows all
when the input string is valid the states of an FSM, all possible inputs and
event : Something that can happen within a the state resulting from each input
system, such as a timer event, or an input to transition: The change from one state to
the system, that may trigger a transition to another state.

File Handling
Q 1) Why files are needed?
When a program is being executed data is stored in variables, constants, arrays etc. These data
structures use RAM, making them temporary, when program is closed Files stored data in
secondary storage devices. These are permanent and non-volatile. They retain data even after
computer is switched OFF, so the data can be accessed next time program is run.

Q 2) Describe File Handling


Text files consist of lines of text that are read or written consecutively as strings.
Page | 24
A file must be opened in a specified mode before any file operations are attempted. This is written
as follows:
OPENFILE <File identifier> FOR <File mode>
The file identifier may be a literal string containing the file names, or a variable of type STRING
that has been assigned the file name.
Q 3) Explain different file modes
The following file modes are used:
READ - for data to be read from the file
WRITE - for data to be written to the file. A new file will be created and any existing data in the file
will be lost.
APPEND for data to be added to the file,
WRITE MODE: To create a new text file and write data in it
To create a new text file, firstly it is opened in WRITE mode, data is written in it and then it is closed.
If file is already existing, new file will be created and all existing data will be lost.
Syntax to create a new text file:
OPENFILE <File name> FOR WRITE
WRITEFILE <File name>, <String Variable to be written>
CLOSEFLE <File name>
For example, to store a name “Inqilab Patel” in a text file Teachers.txt, firstly “Inqilab Patel” is stored
in a string variable and then file is opened and variable is stored at the end of file.
OPENFILE “Teachers.txt” FOR WRITE
WRITEFILE “Teachers.txt”, Name
CLOSEFILE “Teachers.txt”
To input and store name of 5 teachers in a text file “Teachers.txt”.
OPENFILE “Teachers.txt” FOR WRITE
FOR Count  1 TO 5
INPUT Name
WRITEFILE “Teachers.txt”, Name
NEXT Count
CLOSEFILE “Teachers.txt”

APPEND MODE: To add data in existing file


If a file is already created, new data can be added in it.
To add data in existing file, firstly it is opened in APPEND mode, data is written in it and then it is
closed. New data is added at the end of the file.
Page | 25
Syntax to add data in existing file:
OPENFILE <File name> FOR APPEND
WRITEFILE <File name>, <String variable to be written>
CLOSEFLE <File name>
For example, to add a name “Abdullah Patel” in a text file Teachers.txt, firstly it is stored in a string
variable then file is opened and variable is stored at the end of file.
OPENFILE “Teachers.txt” FOR APPEND
WRITEFILE “Teachers.txt”, Name
CLOSEFILE “Teachers.txt”
To input and store name of 5 more teachers in a text file “Teachers.txt”.
OPENFILE “Teachers.txt” FOR APPEND
FOR Count  1 TO 5
INPUT Name
WRITEFILE “Teachers.txt”, Name
NEXT Count
CLOSEFILE “Teachers.txt”
Page | 26
READ MODE: To display contents of text file
To display contents of a text file, firstly it is opened in READ mode, data is read one line at a time
into a temporary variable and displayed on screen, then next line is read until it reaches End Of File
(EOF) marker. Then files is closed.

Syntax to read first line from text file:


OPENFILE <File name> FOR READ
READFILE <File name>, <String Variable to store content>
OUTPUT <String Variable>
CLOSEFLE <File name>

For example to read 1st line from text file Teachers.txt and to store in a variable “TextLine”
OPENFILE “Teachers.txt” FOR READ
READFILE “Teachers.txt”, TextLine
PRINT TextLine
CLOSEFILE “Teachers.txt”

To read all contents of text file “Teachers.txt”.


OPENFILE “Teachers.txt” FOR READ
WHILE NOT EOF(“Teachers.txt”) DO
READFILE “Teachers.txt”, TextLine
OUTPUT TextLine
ENDWHILE
CLOSEFILE “Teachers.txt”
Page | 27

You might also like