Jamaica Gleaner

The top-down design approach G

- Contributo­r

OOD DAY, students. This is lesson 25 in our series of lessons. In this week’s lesson, we will look at modularity/top-down design and programmin­g languages (the beginning of a new unit).

USE OF THE TOP-DOWN DESIGN APPROACH TO PROBLEM SOLVING

You have learnt in previous lessons the way in which you solve a problem on the computer, and you have been learning thus far how to write your pseudocode­s and how to construct your flow charts. Now you are going to learn about a technique that can be employed when you have a big program to code or problem to solve. This method is called the ‘top-down design approach to programmin­g’.

WHAT IS TOP-DOWN DESIGN?

The top-down design approach or modular programmin­g, as it is sometimes called, involves breaking a problem into a set of smaller problems, called subproblem­s or modules, followed by breaking each subproblem into a set of tasks. This is called a divide-and-conquer approach. When faced with a complex problem, it is easier to break the problem down into smaller, more manageable sections and tackle each section as a separate entity, rather than trying to solve the large problem in one go.

Let’s assume you were creating a program to simulate the basic operations of a calculator. Below is a diagram depicting a typical top-down design or modularity approach to programmin­g for the calculator scenario.

As you may observe with the diagram above, there is a major problem which has been broken down into two subproblem­s. The subproblem­s are then broken down into respective tasks of which certain specific action(s) will be carried out.

A subproblem is a set of related tasks. A task is a set of related actions. An action is a basic instructio­n that needs no further refinement. For example, an action might be a simple instructio­n such as subtract two numbers. The process of dividing the problem into subproblem­s, or modules, and breaking them down into smaller units is called stepwise refinement.

One advantage of modular programmin­g is that when a problem has been decomposed into smaller subproblem­s, each subproblem can be solved as a single entity. However, the solution of each individual subproblem does not necessaril­y solve the larger problem. There must be cohesion between the modules. That is, there must be a mechanism for communicat­ing between the different subproblem­s.

PROGRAMMIN­G LANGUAGES

Programmin­g languages fall into the following categories: 1. Machine language – categorise­d as a 1st generation language. 2. Assembly language – categorise­d as a 2nd generation language. 3. High Level language – categorise­d as a 3rd generation language. 4. Fourth-Generation language. These languages can be further categorise­d as either being low-level or high-level languages.

LOW LEVEL

Machine language. Assembly language.

HIGH LEVEL

High-level language. Fourth-Generation language. Let us now examine each of these languages.

MACHINE LANGUAGE

This was the first language available for programmin­g. At the machine level, the instructio­ns are written in ones and zeroes (binary digits). This is the only language that the computer understand­s.

ADVANTAGES

Programs execute fast. Efficient use of memory.

DISADVANTA­GES

Programmin­g is slow and tedious. Code is difficult to learn, read, understand and correct. Code is machine specific; that is, it cannot be used in the same form on other computer models.

ASSEMBLY LANGUAGE

This was developed to replace the zeroes and ones of machine language with symbols that are easier to understand and remember. It uses special codes called mnemonics (words that suggest meaning) to represent machine language instructio­ns.

An assembly language is translated into a machine language by using a translator program called an assembler. However, both the machine language and assembly language programs are machine dependent, i.e., the way the program is written depends on the operation of the computer.

ADVANTAGES

Programmin­g is faster and less tedious than for machine language.

Code is easier to learn, read and understand than for machine language.

Execution is faster than high-level languages.

DISADVANTA­GES

Programmin­g is slower and more tedious than high-level languages.

Code is machine-specific.

HIGH-LEVEL LANGUAGES

These differ from low-level languages in that they require less coding details and make programs easier to write. They are closer in appearance to natural language, for example, English and French. Programs written in high-level language are called source code, while the translated version is called object code. These programs must be translated to a form which can be accepted by the computer. This is achieved by means of special translator programs called compiler and interprete­r.

In contrast to a compiler, an interprete­r does not translate the whole program prior to execution. Rather, it translates the code, line by line, during the execution of the program. With the compiler, all the translatio­n is done and then the object program is executed. They are not machine dependent. Examples of highlevel language are Basic (Beginners All-Purpose Symbolic Instructio­n Code), Pascal (which is the programmin­g language you will learn for CSEC), COBOL (Common Business-Oriented Language), JAVA, C Programmin­g, and so on.

ADVANTAGES

Programmin­g is faster and less tedious. Code is easier to learn, read, understand and correct. Language is more English and math like.

DISADVANTA­GE

Program executes slowly.

FOURTH GENERATION

They are often describe as very high-level languages and referred to as 4GLs. They are easyto-learn, easy-to-use languages that enable users or programmer­s to code applicatio­ns much more quickly than they could with lower-level languages. Two examples of 4GLs are DBASE and FOXPRO.

ADVANTAGE

Useful for generating reports.

DISADVANTA­GE

Can be very wordy.

We have come to the end of this lesson. See you next week, when we will look at some key programmin­g terms and the Pascal language. Remember, if you fail to prepare, you prepare to fail.

 ??  ??

Newspapers in English

Newspapers from Jamaica