Indentation (字下げ) is the practice of adding spaces at the start of lines so that blocks of processing and nesting levels are visible on sight.
Lines inside a conditional branch or a loop are shifted one level to the right, and lines at the same level start at the same position. In most languages changing the indentation does not change the result, but some languages such as Python use indentation to decide where a block begins and ends. Either way, block boundaries are clear at a glance and misreadings become less likely.
AnalogyIt works like an outline in which sub-items are written slightly to the right under a main item, so you see at once which sub-item belongs to which main item.
How to rememberThe Japanese name literally means "lowering the characters": the act of pushing the first characters of a line to the right became the name itself.
Indentation (インデンテーション) is simply the English name for 字下げ and refers to exactly the same thing.
The leading space itself, or its width, is called an indent, and one level is made of space characters or a tab. If the width of one level is not kept the same across the whole program, the boundaries between blocks become harder to read, not easier.
How to rememberThe English word indent describes the notch where text is set back inward from the edge of the page.
Exam points
Mix-upIndentation (インデンテーション) and 字下げ are the English and Japanese names for the same formatting practice, not two separate techniques.
Nesting depth (ネストの深さ) is how many levels of nesting are stacked, where a conditional branch or loop is placed inside another conditional branch or loop.
Loop (level 1)
Branch (level 2)
Branch (level 3)
Another branch inside that branch makes three levels, and the further in a line sits, the harder it is to trace when it runs.
3 / 3
For example, a loop containing a branch that contains another branch is nested three levels deep. The deeper the nesting, the more levels you must trace back to see when a line runs, which invites misreadings and faulty fixes. Deep parts are kept shallow by measures such as moving them out into separate processing.
AnalogyThink of boxes inside boxes inside boxes: the innermost box takes the most opening to reach.
How to rememberNest means a bird's nest in English: just as eggs sit in a nest, processing sits inside processing.
Exam points
Mix-upNesting depth (ネストの深さ) is a structural property, the number of nested levels, while indentation (字下げ) is a way to show those levels visually, so widening every level uniformly leaves the depth unchanged.
Indentation vs. Nesting Depth
Aspect
Indentation
Nesting Depth
Key differenceWhat it represents
Visual levels made by leading spaces
Number of stacked nesting levels
Nature
A writing (formatting) practice
A property of how processing is organized (structure)
Naming conventions (命名規則) are rules agreed in advance on how to name variables, functions and other elements.
Example rule
Example name
Mark word breaks with capitals
orderCount
Mark word breaks with underscores
order_count
Write constants in all capitals
TAX_RATE
Typical rules are to use English words that show the role, to mark word breaks with capitals or underscores, and to write constants in all capitals. Naming conventions are usually set together with rules such as the indentation width, as part of the coding standards that keep the way programs are written consistent. When names follow one scheme, people other than the author can guess a name's role from the name alone.
AnalogyIt is like naming every file in a cabinet as "year-month_client_content", so anyone looking can guess what is inside.
Exam points
ExamThe main aim of unifying the way code is written, with naming conventions (命名規則) and the like, is to make later reading and fixing easier, that is, to raise maintainability (保守性).
Module decomposition (モジュール分割) is a technique of splitting a large program into parts by function, called modules, and assembling it from them.
Payroll program
Read attendance records
Calculate pay amounts
Print pay slips
Each module is given a single role, and modules are combined after deciding what information they pass to one another. When a change is needed, its effect tends to stay inside that module, and parts already built can be reused in other programs. The word module is also used for the program units produced when source code is translated and linked.
AnalogyIt is like furniture built from boards, legs and drawers, where a broken drawer can be replaced on its own.
How to rememberModule means a standardized, interchangeable unit, like a spacecraft's habitation module, a part that can be swapped or added.
Exam points
ExamMachine code produced by linking translated programs, ready for the computer to run as is, is called a load module (ロードモジュール).
A main routine (メインルーチン) is the central processing that starts first when a program runs and directs the flow of the whole program.
Main routine starts
Call lower-level processing
Processing ends and returns to the caller
Continue with the next step
Once the processing returns, the main routine moves on to the next step.
4 / 4
It leaves individual detailed tasks to lower-level processing that it calls, then moves on to the next step once that processing returns. Reading the main routine therefore tells you what the whole program does and in what order.
AnalogyIt resembles a site supervisor who sets the order of the work, hands each stage to the right tradesperson, and moves to the next stage after hearing that one is done.
A subroutine (サブルーチン) is a part that packs a specific block of processing into one unit so that other processing can call it.
← Scroll the figure sideways →
When called, it carries out its processing and then returns to where the caller left off. The same code need not be written in several places, and one fix applies everywhere it is called. Depending on the language it is also called a function or procedure, and a subroutine can itself call other subroutines.
AnalogyIt is like a recipe that says "for making stock, see the separate page", which you can turn to whenever that step comes up.
How to rememberSub is a prefix meaning below or subordinate, the same sub as in submarine, a ship that travels below the surface.
Exam points
Mix-upA main routine (メインルーチン) is where execution starts and sets the overall order, while a subroutine (サブルーチン) runs only when called and then returns to its caller.
Main Routine vs. Subroutine
Aspect
Main Routine
Subroutine
Role
Directs the overall flow
Handles a specific block of processing
Key differenceWhat starts it
The program starting to run
A call from other processing
After processing
Heads toward the end of the program
Returns to the caller and continues
Key points
Indentation, under its Japanese and English names, shows the extent of blocks with leading spaces.
Deeper nesting invites misreadings, so deep parts are moved out into separate processing to keep levels shallow.
Shared rules such as naming conventions make code readable by people other than the author and easier to fix later.
Module decomposition builds parts by role, narrowing the impact of changes and allowing parts to be reused.
Processing placed in a subroutine can be called any number of times, and a fix is needed in only one place.