May 28, 2020 // By Larry Smithmier
One technique I use when studying a subject is to compare it to another, looking for parallels and divergences. Often, I discover successful techniques in one which can be transfigured to work in the other. I also use this method to provide an efficient path to initial understanding when describing complex topics. Writing computer software is described as both a science and an art. It is useful for our understanding of evaluating the craft of software to compare it to common practices in music performance.
Code quality is the metric describing how well code is written. It should quantify the workmanship of an implemented solution, and not the quality of the solution to the problem. Producing quality code is a necessary part of succeeding in a consulting engagement, but that alone is insufficient. However, when working at the highest level of consulting, it is a required part of any delivered solution. It is analogous to the different metrics by which you critique both a busker in the subway and the principal in a symphony orchestra. The code output from high level consultants are, and should always be held to a higher-level scrutiny than either permanent staff or staff augmentation contract workers.
Code quality is impacted by four different factors: language, implementation, testing, and design/architecture. Music performance is influenced by instrument, style, production, and genre.
Language as instrument
It is important to know the history of computer programming languages to understand how choices made during their design impact their implementations. Writing code for the first computers (1940s) began as something done very close to the hardware through machine code. The first real programming language was defined around 1950, but it was just a human readable assembly language that mapped directly to machine code. Next came such languages as Fortran, COBOL, and RPG which had instructions that mapped to multiple machine language instructions. Code was still written by a single programmer or at most a small team and submitted to be run in batches with the results being returned at some later date. Programs were written as a single whole; structured programming didn't become formalized until 1969. Separating code into units of work allowed programmers to reduce their cognitive overhead and solve more complex problems. It also allowed teams of programmers to work together to solve a single problem. It wasn't until the 1960s to 1970s that programming languages evolved to support this structured programming style. Structured programming can be defined as programming without the use of 'goto' statements (a high level JMP statement), or programming through decomposition. C, the computer language from which most modern languages are descended was written by Dennis Ritchie and Ken Thompson between 1969 and 1973. It is a procedural language that allows scoped variables and recursion and enforces a static type system. It enforced a specific coding style and began the dynamic tension between language flexibility and imposed structure. If one were to align programming languages with musical instrument types, different instrument types tend to be associated with different musical styles, just as different programming languages are primarily used to solve specific types of problems. Slide guitars are most often associated with country music and Fortran is used primarily to solve scientific problems.
Design as style
Structured programming was the first of several design paradigms supported by a language definition explosion in the mid-1960s. Different groups of programmers in large organizations had devised various ways of dealing with the increased complexity of large problems using different techniques. A couple of competing programming approaches, which were also introduced around the same time, were object-oriented design and functional programming. The design or architectural concepts for all of these structures had been in existence for a while, but it was during this time that language specific mechanisms were included to facilitate the coding styles the language designers exposed. When designing solutions to be implemented in different programming languages we are predisposed to decompose problems along fault lines that produce pieces easily expressed by the chosen language. It follows that there are some problems which are more elegantly solved by one programming language than another. Therefore, the programming language choice should be dependent on both the problem you are trying to solve and the solution to be implemented. The choice of programming language constrains your available solution within certain patterns. Musical instruments have different voices and require different techniques which can make the same series of notes sound completely different when played. The musical instrument you choose can likewise be influenced by the music you want to perform. When we implement a solution, we need to be aware of the design patterns most appropriate for the language and target environment. Java and C# are very similar in syntax and structure and it is common for people to be able to implement solutions in both. The techniques used to play an electric guitar and a classical acoustic guitar are similar enough that playing one might imply that you can play the other. However, the skills are still distinct enough that being a master of one does not confer a mastery of the other. Stevie Ray Vaughan or Yngwie Malmsteen plays a completely different style than either Tommy Emmanuel or James Taylor.
Testing as production
Testing software as a separate concept from debugging software can be traced back to The Art of Software Testing by Glenford J. Myers, written in 1979 and revised twice. It codified a method of approaching testing in a systematic way, focusing on where programs often fail. It seems obvious now, that testing software should follow a structured path. But structured coding preceded structured testing by 10 years. Looking at testing from a high level, we can describe projects as filling a defined space consisting of the following axis: level (unit, integration, system, acceptance), approach (static, dynamic, passive), ‘box’ level (white, black, grey), type (automatic, manual), hierarchy (class 1-5), and possibly practice (TDD, BDD, ATDD). For the purposes of code quality, we begin at unit testing and stop at system testing. We will generally utilize automated white box testing. Producing a musical album is different than playing on one, just as testing is different than coding. A basic understanding of the underlying principles is required for both, but the focus is different.
Architecture as genre
The final factor to consider is design patterns and architecture. The book that is acknowledged to be the foundational book on design patterns is Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (aka the Gang of Four or GoF) written in 1994. Design patterns are mental and linguistic shortcuts for commonly occurring structures in complex software systems. They include such modern standards as singleton, factory, and façade. Design patterns are valuable because they establish a design language above and with which a problem solution can be implemented. They, like the programming paradigms described earlier, allow us to reduce the cognitive overhead by abbreviating certain portions of the program with a known good solution structure. They improve the implementation by simplifying it. From the other side of the problem, we have modern architectures like 12-factor, microservice, server free, event driven, and resource oriented. These provide a solid structure into which a solution can be implemented. They help to standardize the component interactions, allowing implementors to concentrate on the fine details. For large, enterprise sized applications or systems it is imperative that these larger structures or meta-implementations are well though out and defined. Design patterns are like the chord sets used by different genres of music like jazz, classical, rock, or country. Architecture is like the song structures such as bridge, chorus, or solo.