By now you've had classes in diagramming using DFDs which is a diagramming technique to help you understand a problem domain. But not just understand a problem but also explain it, both to yourself and others. This set of pages move to a more granular level in problem description and are designed to help you understand and use what is known as structured english, pseudocode, or program description language (pdl) - each of these terms means really the same thing.
You will have already noticed that everyday or natural language, and the way we commonly use it, can be ambiguous. So, of course, when we come to actually writing a computer program ambiguity leads to errors. Errors that might mean you didn't understand the problem in the first place, errors in communicating about the problem subsequently, and certainly errors in execution when you get around to writing computer programs to solve the problem.
Structured English, is sometimes known as Pseudocode, and also as Program Description Language or PDL. From now on I'm going to start using the term PDL just because it's quicker to write. So, here are the characteristics of PDL:
- PDL tries to reduce the ambiguity inherent in natural, language by using a more constrained language.
- PDL doesn't really describe WHAT the problem is, but rather HOW we solve it, or the steps we take to solve it
- PDL helps us focus on the logic of the solution rather than getting bogged down in the particular syntax of any one programming language. Don't forget that the actual code we later write to implement a solution might be in any one of a dozen different programming languages.
We must try to make sure we understand the problem and its solution before we ever start to code. Obviously, if you don't understand the problem you stand no chance of coming up with a solution. We'll come back to problem-solving, and strategies to make problem solving easier later on. Firstly we're going to take a quick look at the basics of PDL.
When writing PDL we have three basic structures we can use:
- a simple set of instructions carried out one after the other - known as
a
sequence
; - sometimes those instructions vary according to circumstance - known as a
selection
; - frequently we need to repeat instructions more than once - known as
iteration
.