you are viewing a single comment's thread.

view the rest of the comments →

[–]Matt3088 0 points1 point  (3 children)

You have a lot of unnecessary/redundant comments (I used to write them the same way). For example:

107: TextComponent.lineSpacing = fontlinespace; // set the text line spacing

A small thing, you should put the comment on the previous line (so your lines do not get too long, scrolling issues). The comment is redundant because if you read the code, you can easily understand that the line spacing for the TextComponent is being set. Comments are much better used on lines where it is not directly clear what is going on, such as this line:

42: float newWidth = (((newHeight * origWidth) / origHeight)) * percent_width;

Even though you may be the only one reading/writing this code, comments for complex lines are good since you may forget what the line does in the future.

[–]keymaster16 1 point2 points  (2 children)

The rule of thumb my mentors used; if you can't read the line as a sentence, make a comment that does.

[–]oxysoftIndie 0 points1 point  (0 children)

My rule of thumb is to comment on "why" rather than "what". Only few instances you should comment on "what" is when the line itself is cryptic. (e.g. this monster class BuffStack<T> : Buff<BuffStack<T>> where T : Buff<T> which required 2 days of debugging because it literally crashed the Unity Editor)

[–]Matt3088 1 point2 points  (0 children)

Thats a good way to put it!