Writing more complex programs

Now that we know how to draw things on the board, we'll enjoy this ability and draw a beautiful G on the board (check Objective panel for details on what is expected).

When you write a quite complex program, it is sometimes useful to add comments to simplify the code reviews afterward. Here for example, it's quite easy to get lost in the drawing process, and you may want to add comments like vertical bar done or finished drawing the G. Time to move back to initial position. Commenting your code is almost mandatory if you (or someone else) want to read it afterward, although over-commenting (describing obvious stuff) is a bad idea as the important idea get lost in the noise.

There is [!java]three[/!][!python|scala|c]two[/!] types of comments in [!thelang], instructing the [!java|scala|c]compiler[/!][!python]interpreter[/!] to not read the text you add for humans:

methodCallReadByThe[!java|scala|c]Compiler[/!][!python]Interpreter[/!]()[!java|c];[/!] [!java|scala|c]//[/!][!python]#[/!] all this is ignored
otherCall()[!java|c];[/!] [!java|scala|c]/* This is
               also ignored */[/!]
[!python]''' This is
also ignored  '''[/!]
yetAnotherCall()[!java|c];[/!]

There is a third kind of comments in Java, between /** and */, which are read by a specific program called JavaDoc to generate automatically the documentation explaining how to use the code. These comments must follow a very precise formalism.

The comments on several lines are often used to document how to use the code, while others are more used to describe how this code works.