Improving Code Quality: Quick Tip – April 17, 2015

I am starting a series of quick tips that I hope to publish weekly.  These are intended to be very short posts giving you some quick advice.

Commented out code

First of all, don’t do it.  If you have a bit of dead code, delete it.  If you are using source control (and you should…I’ll have a post about that later), you can always go back in time and get that code back.

If you find some commented out code, delete it.

Commented out code is dead code.  It does nothing for the program, and is harmful to developers.  It only serves to clutter the file and make it harder to read the code.  Or, even worse, it tempts other developers to reuse that code for other things (that it may not have originally been intended for).

If you need that functionality again, I suggest rewriting it.  We are all getting better (or should be) as we continue our careers, so you can probably write it better the second time anyway.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s