4 ms·
"structured programming" is not the use of flow-control but a way to design programs. Even if most language have structured flow-control, a lot of people NOT d
by mamcx 5y ago
"structured programming" is not the use of flow-control but a way to design programs.
Even if most language have structured flow-control, a lot of people NOT do structured programming.
This is how I remember it back in the day and how I do it (curiously, much better on Rust, where it match better how was done on Pascal! ie: Not OOP, big on structs, functions, enums) and is a mix of:
- Define the major components of the app and put it on "modules" (aka their own file or folder if truly large)
- Define the major structures according to the domain (aka: make tables in sql). This is what POCOs are used today or plain Rust structs.
- Make procedures that operate on the above with a clear in/out discipline. Also, document that (this one, I always forget!)
So, is not that far away from functional, inmutable programming, only that:
- A lot was mutable and pass references. This is also a big part of how you discipline to define the flow make this tractable or not
- You don't have generics or classes, so you stick to plain data, plain vectors or lists and duplicate stuff (algos) here and there (no way to abstract "map/filter/folds" that I remember)
- You must be disciplined with the naming of "modules", "POCOs" and functions. Also limited in the length of names (like files only being 8 chars), causing the rise of Hungarian notation (that was misunderstood/misused badly!)
- All your pipeline are eager (not chance of iterators and stuff) so you repeat "loops" everywhere
- Everything was more self-contained, that is great... as long you don't forget the discipline.
"The discipline" was the key here, for make this actually "structured programming".
The MAJOR point is how you STRUCTURED the program, not the use of structured control flow!
- anyfoo 5y agoBut then you (and the author?) talk about different things than the Wikipedia entry that the author linked to, because that entry (and what I remember about structured programming--but I was very young, so might have missed a lot) specifically talks about "making extensive use of the structured control flow constructs [...], block structures, and subroutines", also mentioning Dijkstra's "Go To Statement Considered Harmful" and some debate around that. The structured program theorem is also about specific control structures, essentially proving that they are Turing complete by themselves. I remember that we had to prove in university that as a result, you can transform any program into a program with one big while loop. (I think that's equivalent to "μ-recursion", whereas the simpler "LOOP" statement only implements "primitive recursion" which is not Turing complete, but it's been a while.) What you talk about sounds like it could be "modular programming", of which Wikipedia states: "Modular programming per se, with a goal of modularity, developed in the late 1960s and 1970s, as a larger-scale analog of the concept of structured programming (1960s)." Of course, Wikipedia is not a good source, I wasn't there when it started, and it's entirely possible that structured programming meant more back then than it seems to mean today, or meant different things in different circles. A quick Google search seems to confirm that nowadays structured programming primarily seems to be the use of control structures, though maybe that's just what survived?
- howenterprisey 5y agoAs a Wikipedia editor who's poked around in our articles on programming paradigms, there's a decent amount of strange stuff going on -- and I'm not sure how much of that writing I'd take as authoritative, if you catch my drift.
- anyfoo 5y agoI get it, but if the author means a different thing, then they should link to a source that actually defines what they mean (and that I myself could not find, except for the mention of modular programming), instead of to the Wikipedia article that refers to what we have been talking about here. As it stands, what they link to, and what most seem to understand as structured programming, was not a fad at all.
- mamcx 5y agoIs possible we are talking about different stuff. Back in the day we don't wikipedia (and I learn programming before I have Internet, around 1998 so the idea was more developed?) so this is how I understand the idea as teached to me and by examples from my peers. Also, a lot of good practiques was from books or conferences (mostly sponsored by MS).