Simplicity - arcdev/engram404 GitHub Wiki
originally posted 2017-01-16 at https://engram404.net/simplicity/
For some reason, an assignment I had from college popped into my head. (Keep in mind college was quite a few years ago.) One of my electrical engineering professors gave us an assignment to simulate a vending machine. I don't remember the specifics, but the idea was the user put in a number of coins (nickels, dimes, quarters) and the machine needed to produce change for an single valued item (e.g. 35 cents). The catch was that we were only allowed to use a limited number of logic gates (AND and OR).
Not a single person I my class was able to figure it out.
No matter how we tried we couldn't figure out how to do math with so few logic gates.
When the professor finally gave us the idea we were all shocked.
Basically, just hard code the combinations. (You know all of the possible inputs and you know the various results in change so you create a state machine with only those situations. There's no reason to do actual '"math.'")
How does this relate to software?
So many times we find ourselves over-designing something trying to plan for every possible contingency. Instead, many times simplicity is more efficient and easier to maintain and to enhance.
And here's the plug for test-driven development.
One of the tenets is only to write the minimum amount of code (or logic) to make the test pass; or put another way – to meet the requirement.