Well Crafted Code, Quality, Speed and Budget
I&#x27;m mixed about the post, esp the science part. The science of developing robust software is great and pretty consistent going back decades varying mostly in specific tools and tactics. Mainstream programming just <i>doesn&#x27;t apply it</i> although more adoption in past decade of key techniques. Here&#x27;s some computer science from the 1960&#x27;s-1980&#x27;s used in robust and secure system development (esp Orange Book B3 or CC EAL6) people might want to copy. I&#x27;m taking an empirical route where I reference techniques that were applied to many real-world projects with lessons learned in papers or studies that were consistent. All one can do with limited data &amp; these aren&#x27;t in order of importance.<p>1. Formal, non-English (eg math&#x2F;logical) specifications of requirements or abstract design. English is ambiguous and misreadings of it caused countless errors, even back then. CompSci researchers tried formal specs with both English as a start and precise notations (eg Z, VDM, ASM&#x27;s, statecharts) for clarity in specifics. Result was many inconsistencies caught in highly assured systems and protocol specs before coding even began.<p>2. High assurance stuff often used mathematical (formal) verification. Whether that worked or made sense was hit and miss. More on it later. Yet, virtually all of them said there was benefit in restrictions on the specs, design, and coding style to fit the provers&#x27; limitations. Essentially, they used boring constructs that were easy to analyse and this prevented&#x2F;caught problems. Don&#x27;t be too clever with design or code. Wirth and Hansen applied this to language design to bake safety &amp; comprehension in with minimal to low loss in performance.<p>Note: Led to Nick P&#x27;s Law of Trustworthy Systems: &quot;Tried and true beats novel or new.&quot; Always the default.<p>3. Dijkstra&#x27;s THE project showed that modular, layered design with careful attention to interfaces (and interface checks) makes for most robust and maintainable software. Later results confirmed this where each module must fit in your head and control graph that&#x27;s pretty predictable with minimal cycles prevented all kinds of local-becomes-global issues. Many systems flawless (or nearly so) in production were built this way. Dijkstra correctly noted that it was <i>very hard</i> to do this even for smart people and average developer might screw structuring up a lot. Solid prediction... but still worth striving for improvement here.<p>4. Fagan ran empirical studies at IBM that showed a regular, systematic, code review process caught many problems, even what tests missed. Turned that into formal inspections with the periodicity and prioritizing tuned per organization for right cost-benefit. Was generalized to whole SDLC by others in high robustness areas. Improved every project that used it from then on. Exactly what parameters to use is still open-ended but periodically looking for well-known flaws with reference sheet always works.<p>5. Testing for every feature, code-path, prior issues outside of code base, and common use-case. All of these have shown repeated benefits. There&#x27;s a cut-off point for each that&#x27;s still an open, research problem. However, at a minimum, usage-based testing and regression testing helped many projects achieve either zero or near-zero, <i>user-facing</i> defects in production. That&#x27;s a very important differentiator as 100 bugs user never experiences is better than 5 that they do regularly. Mills&#x27; Cleanroom process combined simple implementation, code review, and usage-testing for insanely-high, statistically-certifiable quality even for amateur teams.<p>6. By around 60&#x27;s-70&#x27;s, it became clear that the language you choose has a significant effect on productivity, defects, maintenance, and integration. Numerous studies were run in industry and military comparing various ones. Certain languages (eg Ada) showed vastly lower defects, equal&#x2F;better productivity, and great maintenance&#x2F;integration in every study. Haven&#x27;t seen many such studies since the 90&#x27;s and most aren&#x27;t constructed well to eliminate bias. However, it&#x27;s grounded in science to claim that certain language choices prevent common negatives and encourage positives. So, it follows to adopt languages that make robust development easier.<p>7. By the 80&#x27;s or 90&#x27;s, it was clear that computers were better at finding certain problems in specs and code than humans. This gave rise to methodologies that put models of system or code into model-checkers and provers to show certain properties always hold (the good) or never show up (the bad). Used successfully with high-assurance safety and security critical systems with results ranging from &quot;somewhat beneficial&quot; to &quot;caught stuff we&#x27;d never see or test for.&quot; Back then it was unclear how applicable it was. Recent work by Chlipala, Leroy, et al show near perfect results in practice when specs&#x2F;proofs are right and much wider application than before. Lots of tooling and prior examples means this is a proven way of getting extra quality <i>where high-stakes are worth the cost</i> and where core functionality doesn&#x27;t change often.. The CompCert C compiler, Eiffel&#x27;s SCOOP concurrency scheme, and Navy team&#x27;s EAL7 IPsec VPN are good examples.<p>8. Static analysis, aka &quot;lightweight formal methods,&quot; were devised to deal with specialized skills and labor of above. Getting to the point, tools like Astree Analyzer or SPARK Ada can prove absence of common flaws with little to no false positives without need for mathematicians in the company. Just a half dozen of these tools by themselves found tons of vulnerabilities in real-world software that passed human review and testing. Enough said, eh?<p>9. Software that succeeded with testing often failed when random stuff came at it, especially malware. This led to various fault-injection methods like fuzz testing to simulate that and find breaking points. The huge number of defects, esp in file formats &amp; protocol engines, found via this method argues for its effectiveness in improving quality. It ties in with stuff above in that well-written code that validates input at interface and preserves invariants throughout execution should simply disregard (or report) such erroneous input.<p>10. Interface errors themselves posed something like 80+% of problems. This was noted as far back as the 60&#x27;s in Apollo project when Margaret Hamilton invented software engineering, fault-tolerance, and specification techniques to fight it. Dijkstra and Hoare pushed for pre- and post-conditions plus specific invariants to document the assumptions of code during procedure calls. Modern version is called Design by Contract in Eiffel, Ada, and numerous other languages (even asserts in C). Many deployments and tests showed such interface checks caught many issues, esp assumption violations when new code extended or modified legacy.<p>11. Concurrency issues caused all kinds of problems. Techniques were devised by Hansen (Concurrent Pascal) and later Meyer et al (SCOOP) to mostly immunize against them at language level with acceptable performance. Languages without that, especially Java, later got brilliant tooling that could reliably find race conditions, deadlocks, or livelocks. Use of any method inevitably found problems in production code that had escaped detection. So, using prior, proven methods to immunize against or detect common errors in concurrency is A Good Thing. Note that shared-nothing, event-driven architectures also emerged but I have less data on them outside that some (NonStop, Erlang) worked extremely well.<p>The above are just a few things that computer science established with supporting evidence from real-world projects so long ago that Windows didn&#x27;t exist. Anyone applying these lessons got benefits in terms of code quality, security, and maintainability. The rare few applying most or all of them, mainly high assurance community, got results along lines of space shuttle control code with extremely, low defects or zero in production. So, given the past and present <i>results</i> of these methods every time they&#x27;re put to the test, I&#x27;m irritated every time another person talks like there&#x27;s no good science to quality software. I just listed a bunch of it, it&#x27;s been tested in production as scientific method requires thousands of time, tweaked probably hundreds, and core approaches remained even if tactics got modified.<p>Now people can feel free to use and improve on the science. CompSci continues to in every area I listed with a chunk of proprietary and FOSS developers using a subset of the techniques. Just need more uptake. Use what&#x27;s proven. And do note that there&#x27;s plenty of examples for specific design and implementation decisions for common types of functionality. Many things that were shown to work or not work that could be encoded in libraries, DSL&#x27;s, templates, whatever. No excuse except for our field&#x27;s continual failure to learn and hand down the lessons from the past.