Program design is how you organize a COBOL program so it is easy to understand, change, and test. Key ideas are top-down design (main steps first, then break each into smaller steps), modular structure (each paragraph or subprogram does one job), and clear flow (sequence, selection, iteration). This page introduces these ideas and how they look in COBOL. For the actual flow of control see Program flow and Program logic.
| Principle | Meaning |
|---|---|
| Top-down | Start with main steps; break each into smaller steps |
| Modular | One paragraph or program = one clear task |
| Single entry/exit | Paragraphs and subprograms have one way in and one way out |
| Readable names | Paragraph and data names describe what they do or hold |
Start with the big picture: what are the main steps? For example: open files, process records until end-of-file, then close and finish. Write a main paragraph that PERFORMs those steps. Then implement each step as its own paragraph; each of those can PERFORM lower-level paragraphs. You get a hierarchy: the main paragraph is the “boss”; the steps it PERFORMs are the next level; and so on.
12345678910111213141516171819PROCEDURE DIVISION. MAIN. PERFORM INIT-PROGRAM PERFORM PROCESS-ALL-RECORDS PERFORM TERMINATE-PROGRAM GOBACK. *> Top level: three main steps PROCESS-ALL-RECORDS. PERFORM READ-RECORD PERFORM PROCESS-LOOP UNTIL WS-EOF . *> Next level: read once, then loop until done PROCESS-LOOP. PERFORM VALIDATE-RECORD PERFORM UPDATE-AND-WRITE PERFORM READ-RECORD .
Each paragraph should have a single responsibility: one clear task (e.g. validate input, compute total, write a line). Keep paragraphs short; if one grows too long, split it into smaller PERFORMed paragraphs. Use names that describe the task (VALIDATE-RECORD, CALCULATE-TOTAL, WRITE-OUTPUT-LINE). That way the PROCEDURE DIVISION reads like a table of contents and new developers can find where to change logic.
PERFORM is for calling paragraphs or sections inside the same program. Use it for your main structure: init, process, terminate, and all the small steps in between. CALL is for a separately compiled subprogram. Use CALL when you need a reusable program (shared by many callers), need to link with another language, or want a clear program boundary. For most internal structure, PERFORM is the right choice; see Subprograms for CALL and parameter passing.
1. What does top-down design mean?
2. What is a good guideline for a paragraph or module?