Friday, May 29, 2015

//Comments

Comments come in two forms, bad and less bad. Comments and whether to use/leave them in code can be one of the more passionate discussions you can have with a developer. I say this because there are those that think all comments are bad and there are those that have valid reasons for leaving them. I fall somewhere in the middle. For the most part I see comments as bad. Most of what I have seen with comments can be replaced with cleaner, more descriptive code or removed entirely as they are no longer relevant and were never maintained. And, thanks to refactoring tools like ReSharper may not even be related to the code around them. There are some occasions that they are less bad. These are the rare situations where the code and related comment might actually remain together and be relevant. I have only seen this in situations where newer applications are tying into legacy applications and a bit of explanation is needed to explain why mapping Response Name to Response Type Name totally makes since. Special comments such as //TODO and //BUG are still bad comments to have. When I see these in code the first thing I look for is a task related to them in whatever tracking system we are using. Without a task TO DO things or fix that BUG then these are just lost on the code.

1 comment: