Comments
Last updated
Last updated
Imagine if you were building a chair or something from IKEA and the instructions didn't have anything on them. The pure agony and misery you'd feel is the same feeling people get when they see a code without any comments (this is from experience).
Comments are little notes that the coder writes so that people who look through the code understand what's happening. Whatever's inside them will not be checked by the compiler for errors. If you're going to take away at least one thing from this entire page, remember to comment your code.
There are two types of comments that we use: singleline and multiline comments.
Multiline comments are named this because they can be more than one line long. You can have a one-line multiline command and nothing bad will happen.
For most cases both comments work fine. However, there are two style rules that we follow to keep our life expectancy up:
Put comments in parts of your code that look confusing.
If a comment ends up being too long (200 > characters long), move the rest of the comment onto a new one below.
Comment method/class headers. When you do, use multiline comments (VSC sets this comment as a tooltip. Behind the tooltip is the multiline comment)