On Maintaining Code
# Code is Design
Two of the most important characteristics of good design are discoverability and understanding. Discoverability: Is it possible to even figure out what actions are possible and where and how to perform them? Understanding: What does it all mean? How is the product supposed to be used? What do all the different controls and settings mean?
- Norman [^1]
# 1. Coding for Change
My approach to writing code is to make it as adaptable as possible. I evaluate code by how ready it is for change. Is it tightly coupled? Is it easily scannable? If it’s not elegant but it can easily be replaced or updated without touching other places in the code then I’ll make a comment but push it through a code review. The more effort it will take to change, the more I will push back.
At some point I will document some of the practical and most common ways I see for both making code stubbornly difficult to change as well as modular and composable.
# 2. Know Where You Are
The next thing I look for after the changeability of code is whether or not, at any given time, I can understand the state my application is in. Avoiding shared/global state is key. Avoiding mutations is key. Passing the entire current state down the line, never in part.
# 3. Performance
Sometimes performance is so important that it must skip the two previous points. On this case, the code can lose its clarity and its a good time to add comments. In most software, this seems pretty rare though.
[^1]: The Design of Everyday Things Norman, Donald