Home Commenting inside methods

Method header vs inline comments

There are three different kinds of comments you can write: class header comments, method header comments, and inline comments (which are comments that go inside your method).

It's important to note that what we expect from inline comments are somewhat different from what we expect from class/method header comments.

Inline comments

Use inline comments to describe complex pieces of code – to explain your implementation. You may also use inline comment to help delineate distinct "sections" of your method. Do not over-comment and leave excessive amounts of inline comments.

Formatting inline comments

There are no hard-and-fast rules for formatting inline comments. However, you should generally place inline comments on the line directly before the thing you are commenting.