Write before code
While working on my own code or code written by others I tend to ask myself: “Why?”.
There are lots of reasons my past self or others did it: a lack of expertise? or maybe a tight schedule, was there a bug related? or some features not covered by your dependencies? I don’t know, I can’t remember or the people who wrote it are not here now.
Many times, code does not speak by itself. Write a comment, comment what makes sense, don’t be lazy, you will thank yourself in the future.
Read it, before moving to the next thing, read your comment and ask yourself if it is answering the why question. A programmer MUST write. For example:
- Is my comment answering whether reset function will partially or fully reset the work done?
- Why did I choose an extra scheduled thread? Can I improve the communication between these two threads?
Think before code, that’s it. Make diagrams (nothing fancy), talk in front of a mirror or to your rubber duck, does not matter what you use, but do it.
The autopilot mode is the reason your code is a brushwood pile, look for other opinions. Sometimes, a different point of view will refresh your brain, it will help you to wake up from your destruction dream.
Sharing is caring, and no one is able to build a cathedral alone, code is the last step to get the job done.
Finally, I learned it.