3 ms·
Just a note, structured programming wasn't about structures in the data sense, but in the logic sense. Organizing program logic in a way that was more structure
by Jtsummers 7y ago
Just a note, structured programming wasn't about structures in the data sense, but in the logic sense. Organizing program logic in a way that was more structured. Using a pseudocode:
function unstructured_summation (int lower, int upper):
int sum := 0;
label loop:
sum := sum + lower;
lower := lower + 1;
branch_neq lower, upper, loop;
return sum; // this is assuming there's even a return concept
This is short and simple, so that goto or branch is fine here for reasoning about. But it doesn't scale very well [0]. Structured programming discouraged these ("discourage" being a scale from: don't use unless it makes sense to don't use at all) in favor of other constructs that were more clear in their intent and easier to reason about (particularly in the days when you couldn't write a piece of code and test in in 10 seconds or less).
[0] I once inherited a Fortran codebase that was essentially written in an unstructured style, many gotos and computed gotos. The guy who wrote it (yes, singular) over a 20 year period knew exactly what it did. But that didn't help me, because he was 70 and retired with a nice pension. The whole thing had to be rewritten using the original as a reference for testing because it was unmaintainable.
- deleted 7y ago[deleted]