I've always heard of this book "Clean Code" by Robert C. Martin. In school, there really wasn't much of a pressure to write or maintain clean code. Mainly because we probably will only touch the code during that 13 weeks of semesters. On top of the deadlines and preparing for assignments, writing clean code is almost never my priority.
After starting my own side project, the thought of having to deal with my messy code in the time to come quickly prompt me into reading this book that I've been pushing away for so long.
This series is meant to be my notes on the book. While serving as a platform for discussion on the book.
Clarity of Thought
As I read the first chapter, the first thought that comes into my mind is the need for clarity of thought. Perhaps the reason my code is messy because I jumped in without having enough knowledge and experience on how to structure my web application. As I come across problems, my natural responses tend to be a quick google search rather than thinking about it for myself. This leads to the accumulation of "spaghetti code".
Importance of Caring for your Code
"Clean code always looks like it was written by someone who cares. - by Michael Feathers" This quote from Michael Feathers really hit me, perhaps the reason why I've been writing messy code is that I've been caring for the wrong things! What sort of wrong things? Prioritizing school work that grades you based on the passing of test cases and launching of an application ASAP. When I read this quote, I felt ashamed of myself.
Reading to Writing Ratio
In the book, Martin brought up an example illustrating that the ratio of reading to the writing of code is well over 10:1. Though my own experience, I do agree that I spend a lot more time reading than writing new code. Which is also one of the reasons which compelled me to start reading this book. One of the ideas that came to mind is to start drawing diagrams or models to facilitate the reading of code in the future. Even better if those diagrams/models are interactive. I would imagine it would be a lot easier to navigate through a huge code base than scrolling through seemingly infinite lines of code.
I'll conclude with two personal action plan:
Before I write code, start by having an implementation plan in the form of diagrams or flowchart. This should improve my clarity of thought.
Start thinking about yourself in the future (or your team members). Caring about your code is very similar to caring for the people that will work on your code next. Delay the need for speed and increase the need for care.