Skip to content
← Back to glossary

ネストの深さNesting Depth

Learn in the textbookCoding Conventions and Structuring

DefinitionNesting depth (ネストの深さ) is how many levels of nesting are stacked, where a conditional branch or loop is placed inside another conditional branch or loop.

ExplanationFor 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.

Memory hookNest means a bird's nest in English: just as eggs sit in a nest, processing sits inside processing.