You are on page 1of 5

OCR Computer Science A Level

2.1.3 Thinking Procedurally


Intermediate Notes

www.pmt.education
Specification:

2.1.3 a)
● Identify the components of a problem

2.1.3 b)
● Identify the components of a solution to a problem

2.1.3 c)
● Determine the order of the steps needed to solve a problem

2.1.3 d)
● Identify sub-procedures necessary to solve a problem

www.pmt.education
Identify the components of a problem

The first stage of thinking procedurally in software development involves breaking down
the problem into its component parts, in a process called ​problem decomposition​. In this
process, a​ large, complex problem is continually broken down into smaller subproblems
which can be solved more easily. The project also becomes ​easier to manage​ and can be
divided between a group of people​. This requires software developers to consider a
problem in terms of the ​underlying subproblems that need to be solved​ to achieve the
desired result.

Problems are commonly decomposed using ​top-down design​, shown below.

This is also known as ​stepwise refinement​, and breaks


problems down into ​levels​. Higher levels provide an
overview of a problem, while lower levels specify in detail
the components of this problem. The aim of using
top-down design is to keep splitting problems into
subproblems until each subproblem can be represented
as a ​single task​ and ideally a​ self-contained module or
subroutine​.

Each task can then be solved, developed and tested separately.

Identify the components of a solution

This is the stage in which the details about how each component is implemented are
considered.Just as we broke down the problem, we must now ​build up to its solution​.

www.pmt.education
Going back to our previous example involving the book reservation system, we need to
consider the ​lowest-level components​ and how they can best be solved.

Borrower name
This could be implemented as a procedure, ​getName()​ ,
which checks to see whether or not a user is signed-in to
their library account. If they are already signed-in, their
name can be retried by ​querying the library’s database​ of
users for the name of the borrower associated with the
borrower’s ID. Users that are not signed-in should be
redirected to a page, requesting them to either register or
sign-in. These options should redirect the user to the
relevant form.

Book details
The user should be able to enter the name of the book into
a text entry field, which would display the books stocked by the group of libraries. This
could be implemented as a function which returns the ISBN of the selected book, which is
easier to handle and can be more useful than a string.

Collection location
This input could also be implemented as a function, which returns the location specified by
the user. It is impractical to use a text entry field here, as this raises the likelihood of
erroneous data being entered, such as a location where a library does not exist. Therefore,
this data is best collected through a drop-down field in a form.

Check book availability


Another database query would have to be carried out to check whether books under the
selected ISBN are currently on loan or available for borrowing. This problem could be
programmed as a function which returns ‘True’ if the book is available, or ‘False’ if not.

As an exercise, consider the ways in which the two final


modules could be implemented.

During this stage, it is also useful to identify tasks which


could be solved using an already ​existing module,
subroutine or library​.

www.pmt.education
Order of steps needed to solve a problem

When constructing the final solution, thinking about the ​order in which operations are
performed​ becomes important. Some programs might require certain inputs to be entered
by the user before the processing can be carried out. These inputs would need to be
validated before they can be passed onto the next subroutines, which must also be taken
into consideration.

It might be possible for several subroutines to be executed simultaneously within a


program, and programmers must identify where this is possible by looking at the data and
inputs the subroutine requires. Some subroutines will require data from other subroutines
before they are able to execute, and so will be unable to execute simultaneously. In this
case, programmers should determine the ​order in which subroutines are executed​, as well
as ​how they interact with each other​, based on their role in solving the problem.

The same principle is important when considering how a program will be used. Programs
should be built so as to ensure operations are not carried out in an order that will raise an
error. Consider an adventure game. It should not be possible for users to access and play
levels ahead of those they have unlocked. A fast food delivery app should not allow users
to select food until they have confirmed their location, nor should it allow users to pay
before they have confirmed their order.

www.pmt.education

You might also like