How to: Use comments when coding

View all subject updates

Why comments are important

Programs can include comments, which are ignored by the computer but are meant for humans to read. When you write code, it is helpful to add comments to let other people know what the code does or to remind yourself what it does when you’ve not looked at it in a while. In the mBlock language you can add a comment to any block by right clicking on it and clicking on ‘add comment’.

For example:

Subject Update How To Comment Code Figure 1

Comments are very important for sharing code, so that anyone reading, editing or debugging the original code in the future is able to understand the ideas and intent of the original author. In the real world, programmers work as part of teams. In teams, it’s important to share thoughts, ideas and processes quickly and easily.