This is an introduction to a serie of articles about code simplicity. The concept itself is a bit abstract but don’t worry: I aim to provide some good examples and explainations for you to get something out of it!
In this first article I’ll share some context about that whole code simplicity thing.
There are different kinds of applications. Most of the application I wrote myself were web applications. They could be defined as state associated with a list of operations.
The state of the application includes obviously what’s in the database as well as the emails that have been sent, payments that have been made, logs, cached contents, etc.
The operations transform the current state of your application to the new one. For instance, when you Tweet something, you’re updating Twitter’ state. Even when you display your feed, Twitter updates its state regarding the ads it showed, the last tweets you’ve seen, etc.
The portion of code simplicity relating to the previous definitions is that reading simple code helps you better understand the application’s state and how it evolves over time. If you acknowledge the difference between state and operations then you’ll tend to write code in an intention-revealing way that will contribute to the understanding of future readers.
Keep in mind that we spend more time reading than writing code.
If state and operations never needed to evolve we wouldn’t care so much about making the code expressing them as simply as possible. But…
When either state or operations are poorly organized, it becomes longer and harder to deal with the previous list. Time is lost trying to untangle the past, making those actions more expensive and sometime impossible to achieve.
Now that I gave more context, I can afford to give you my definition!
Code simplicity is a way to get changes in your application, through both years and people, at a low and constant cost.
I’m not saying that getting there is achieved only by code simplicity. I’m saying that without simple code, you’ll have a hard time.
As I said this article was an introduction. In the next articles we’re going to explore examples showing situation where code simplicity could be enhanced. Here are the list of the following articles:
I’ll update the list with links as they are published!