In pseudocode, is it more better to be indenting 'else if' statements almost as though the 'if' part is nested within the 'else' part?
As you see here, I feel like the 3rd/5th/7th line of code should not be indented, but instead at the same level as the 'if' statement. Is it true that these 'if' part should be nested within the preceding "else" part? If so, why aren't there more 'End if' statements, surely there wouldn't be one 'End if' which closes 3 'if' statements.
Here is an example from php code (random language, this following concept applies to any other language anyways):
As you see here, the elseif statements are not 'nested' - as if the 'elseif' statement are two separate statements but the 'elseif' is instead, one coherent statement. This 'elseif' does indeed have the same meaning as an 'if' nested within an 'else' yes, however, surely that does not mean the 'else if' statements should be nested within the previous 'else if' (refer back to 1st screenshot).
In pseudo-code, which style of indentation is correct in syntax and is more readable to other programmers?
Aucun commentaire:
Enregistrer un commentaire