Skip to main content

Nothing More, Nothing Less

· 5 min read

Consider the solemn promise made in courtrooms worldwide: "Do you swear to tell the truth, the whole truth, and nothing but the truth?" This oath, while seemingly repetitive, meticulously encapsulates the essence of comprehensive honesty. It's a perfect springboard to explore the importance of precision in software development and how exceeding or not fully meeting requirements can lead to issues.

The Circle of Truth

Picture a circle representing "the truth." Anything within this boundary is true, while everything outside is not. This visual helps us understand the nuances of partial versus complete honesty.

Venn Diagram

When a witness commits to "tell the truth, and nothing but the truth," imagine they only share a segment of the entire circle (the truth), depicted as a smaller, contained circle. They're not lying, but they're omitting significant portions of the truth.

Venn Diagram

Conversely, if someone shares "the whole truth" but not exclusively, they might include extraneous, untrue details, or perhaps even lies. It's only by merging both commitments that we fully capture the essence of the truth, covering the entire circle without exceeding its bounds.

Venn Diagram Venn Diagram

Functionality, and Nothing But Functionality

Imagine you're tasked with developing a function to convert Celsius to Fahrenheit. A straightforward implementation might look like this:

// Example 1
function celsiusToFahrenheit(celsius) {
return (celsius * 9 / 5) + 32;
}

This code directly fulfills the client's request. However, consider a different approach:

// Example 2
function celsiusToFahrenheit(celsius) {
if (celsius === 0) { return 32; }
if (celsius === 100) { return 212; }
throw new Error("Unable to convert");
}

This function technically converts Celsius to Fahrenheit but only for two specific cases. It's an example of providing "the functionality, and nothing but the functionality," yet it fails to deliver comprehensively, rendering the solution impractical.

Alternatively, you might come up with:

// Example 3
function celsiusToFahrenheit(celsius) {
Logger.log("Converting Celsius to Fahrenheit!");
Logger.log("Input value: " + celscius.toString());
Logger.log("Length of Celsius input: " + celscius.toString().length);

var fahrenheit = (celsius * 9 / 5) + 32;

Logger.log("Converted Celsius to Fahrenheit, now storing in DB");
dbClient.temperatures.push({ celsius, fahrenheit, date: new Date() })

return fahrenheit;
}

Although this function ultimately returns the correct value, it does a lot of unnecessary logging and seems to store values into a database. You have given your client "the whole functionality", but failed to give "nothing but the functionality". Although the function is usable, it introduces external dependencies, increases risk of failure, and uses additional resources than are necessary.

Stick to the Scope

Example 2 above is essentially flawed, providing incorrect outputs for most inputs, whereas Example 3, although functional, strays beyond the requested scope. This tendency to overdeliver can be tempting but deviates from the core principle of fulfilling precise requirements. Scenarios like Example 3 are frequently tolerated, and sometimes even supported! (After all, you're giving your client BONUS functionality!). But Example 3 is equally as invalid and incorrect as Example 2, just in different ways.

When writing code, we should be very careful to do what our client requires us to do. Nothing more, and nothing less. Don't introduce assumptions into the code without checking with the client first. It's possible (and common) for the initial requirements to be incorrect or incomplete. When this happens, it's important to make a note of this disparity to maintain a 1-to-1 correlation between expectations and implementation. This discipline ensures clarity, efficiency, and satisfaction in the deliverables.

Code Review and Quality Assurance

For developers, maintaining a strict correlation between requirements and implementation is key. For code reviewers and quality assurance professionals, vigilance against over-engineering and unintended functionalities is equally important. Together, these practices safeguard the integrity of the codebase and ensure that software not only meets expectations but does so with precision and reliability.

Code reviewers possess the unique opportunity to scrutinize the code from an internal perspective, identifying any deviations from the specified requirements. Their vigilance helps prevent the inclination towards over-engineering, ensuring that each feature remains purposeful and within the project's scope. By doing so, they contribute significantly to maintaining the integrity and manageability of the codebase.

Quality assurance professionals complement this process by testing the software from the user's viewpoint. Their focus extends beyond verifying that the software performs its intended functions; they also ensure that it does not exhibit behaviors or side effects outside of those functions. This dual focus on confirming expected behaviors and identifying unexpected ones is critical for delivering a product that not only functions correctly but also operates securely and efficiently.

Together, developers, code reviewers, and quality assurance professionals form a comprehensive frontline defense against scope creep, over-engineering, and unintended functionality. Their collaborative efforts ensure that software development projects achieve a delicate balance between fulfilling explicit requirements and maintaining simplicity and clarity. This balance is paramount, not just for meeting immediate project goals, but for ensuring the long-term sustainability and adaptability of the software product.