Friday, April 26, 2019

You Can Use Unstructured Languages


Unstructured code violates Edsger Dijkstra's guidance to restrict control structures to IF-THEN-ELSE, DO-WHILE, DO-UNTIL, and CASE. Notice that it is possible to write structured code in languages without these structures, such as in assembly languages, by documenting the use of GOTOs to implementing these structures only.

To do this, first write your algorithms using the aforementioned control structures. Next, convert these into in-line comments. Next, translate the comments into their equivalent programming language statements. GOTOs will appear, but they will be implementing the better constructs and will facilitate, not hamper, readability, maintainability, and provability.


Reference:
McConnell, S., Code Complete, Redmond, WA: Microsoft Press, 1993.