Routines with many nested routines make for code that is difficult to navigate and understand. While nested routines can be helpful for small units of work specific to a particular routine, their easily missed syntax and non-linear control flow make them confusing when containing large amounts of functionality.
Consider if the nested routines can be inlined to the body of the main routine:
procedure DoThing;
procedure DoSubThing;
begin
Log('Hello!');
end;
// ...
begin
DoSubThing;
// ...
end;
procedure DoThing;
begin
Log('Hello');
// ...
end;
Otherwise, extract the nested routines out into one or more independent routine:
procedure DoThing;
procedure DoSubThing;
begin
// ...
end;
// ...
begin
// ...
end;
procedure DoSubThing; begin // ... end; procedure DoThing; begin // ... end;