Episode 49 – Clean Code – Comments Are Lies
Coding blocks podcast is presented by Joe Zack, Michael outlaw and Allen Underwood. In this podcast episode, the authors discuss about creating good and clean code and eliminating as much comments as possible. Initially, I was very confused with this concept by pro developers because in my first intro to java class, my teacher emphasized on making sure that we adequately commented thoroughly on methods and functions that we wrote. There were even points that was taken for now properly commenting codes then all of a sudden, my CS 443 my professor tells me that commenting is not really a good practice since your code should be written so well that understanding the though process and program should very easy. But the more I thought about this, the more I understood what was being taught by the teacher and now this podcast episode. No one writes comments for print statements because it’s so rudimentary that, everyone basically understands it by looking at it. That’s how our algorithms should be designs. Code Readability and understanding should be the goal of all developers who walk out of school. Again using comments in clean code has its pros and cons. They almost never get updated while the code gets updated and fix. They tend to mislead because they are not often updated. They propagate lies and misinformation’s because as the code gets modified and updated, they are often left untouched. The only exception to this rule of thumb is when one is coding a public API that would be used by other developers. Comments are looked as a way for programmers to make up for their shortcomings in programing. If methods and variables are named and designed properly there would be no need commenting. Time used to create comments can be used to optimize the software program to increase its readability and logic flow. Another bad thing about comments is when they are not obsolete but just misleading. Also inaccurate comments put the developer in the wrong frame of mind and logic. The proper approach is utilizing refactoring and clean code techniques that build program structure and design instead of attempting to explain bad coding with comments. Ultimately, it makes sense that developers wanted to explain their thoughts and processes with comment but its just more effective when the thought process is explained in the logic and functionality of the codes and method.
Link – Episode 49
From the blog CS@Worcester – Le Blog Spot by Abranti3 Dada Kay and used with permission of the author. All other rights reserved by the author.