I’ve always really wondered what people thought when they hear the term “clean code”. I often hear people say it is commenting your code, while others say object-oriented programming, and some just say “no spaghetti code”. While I agree with all those, I tend to lean towards object-oriented programming the most. In fact, I don’t even believe commenting your code should necessarily be a function of clean and legible code.
As you can probably tell, my approach is to cut down on code by making functions and existing code more modular and used by more sources, as opposed to living in the cache as a one time use function. Granted that the function is clearly written, declaring variables in plain text and using variable names that make sense for what they do, commenting becomes much less relevant, especially when the functions themselves are less than 30-50 lines of code (including line breaks). Commenting is something I felt was always added to help another developer understand one developers sloppy writing. Yes, creating code is like writing. If you cannot properly outline your introduction (declarations), your content (the main code) and the conclusion (clean up and return statements), then no one will understand what you are attempting to carry out.