From my experience as a CS student and one internship experience, I’ve get the chance to read other engineer’s code. I have to admit that it is sometimes painful to truly understand what a piece of code is doing when it’s poorly designed. Thanks for CS467 introducing the Clean Code book to me, I’ve found very useful advices there.
Meaningful Names
It is not uncommon when I see people use x, n to describe an variable in their code. It makes me want to skip the whole piece when I get lost in the code and forget what x or n represents. One thing I noticed is that longer names is actually easier to understand than short ones. I don’t where I get the first impression that variable names or function names need to be simple and short. Meaningful names such as: areasWithMostDrivers, hitsPerMinute are more understandable than hotAreas and just hits.
Functions
Function is a great way to encapsulate a piece of code, with a meaning function name it makes our code cleaner and shorter. But sometimes we use one function to do more than one thing, which makes the code hard to read and even harder to debug. Putting a piece of code that does only one thing can help engineers to invoke the function without make changes to other part of the code. If the return value caused an error or throws an exception, it is relatively easy to track down which function caused the problem and can be dealt within the scope of that function.
There are other parties that I find useful in the book, and I will continue to read and share those knowledge once I get the chance.