One thing that bothers me, is that code I’ve written months before looks alien to me.
The question is why? Is it just the memory that fades or are there other factors involved?
Two assumptions:
- While writing code, the understanding of the problem and the context is at the highest peak ever for that particular piece of code. Meaning that you will probably never get into a state to fully understand all the details again. That explains the complexity which is so often observed in an initial implementation. Therefore, continuous refactoring is an important step to lower the detail awareness that is required to understand code over time.
- Even if you fully understand a piece of code, it may hard to use it, and this leads me to a related observation:
The processes of learning and creating get mixed seamlessly. Especially when there is Internet around, there is no differentiation. You learn and create at the same time.
But creating and learning are a distinct processes. They may use different brain mechanics and so should be separated while developing software.
This leads to a number of consequences:
- It is disrupting to look up for information while you are writing code. I.e. when you spot yourself switching to a browser looking for a solution to an algorithmic problem or the syntax of an API call, you switch to a learning and gathering mode which is far off from your creative flow you want to keep running. A good advice is: keep the creative flow, write the problem down and circumvent it with your current expertise and knowledge. But: take your time to research and fix the problem later on.
- Discriminate learning tasks from doing tasks as good as you can. I think that the success of Test Driven Development originates from this fundamental principle: The separation of the creative and the learning tasks in discrete units. Writing tests and debugging is more about learning how code works and is used. Writing and refactoring the code to be tested is the creative part.
- A good sign of a proper development process is either the flow, which is – as soon we collected enough knowledge about the details – a single stream of creativeness. Or the dance, in which we consciously and continuously switch between creating and learning.
I think it is worth to internalize: Learning is different from creating, meaning that even if we create something by ourselves, we need to take the time learn it.
Keep flowing and dancing,
yours
armin