Collapsing Comments in Code is a good thing

One of the things that I consider a double edged sword is commenting code. On one hand it is a great thing and it explains why code is there or why something was changed because of some bug that was reported while on the other hand when the code is really old and modified by many people over a long period of time the comments take over the code and it is very hard to actually read the code at that point.

Eclipse has a cool feature for this; as I am sure many IDE’s have this feature at this point so this tip, per say, applies to all code but the specific example is for Eclipse. The reason is, currently Eclipse can not seem to collapse the C++ style comments yet it can collapse JavaDoc and C like comments.

Here is the code when the comments are not collapsed:

uncollapsedcomment.jpg

Here is the code where the /**/ style comments are collapsed.

collapsedcomment.jpg

Even though this is a very basic and small example, it makes a huge difference when the code is inundated with comments. My first inclination is to write up a bug against Eclipse to have all consecutive lines that only contain either commenting style to in fact collapse when the option to collapse comment blocks is checked. You can argue this is not a “block” but I can also argue they are multiple lines with just comments which make a block!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.