How to: Use comments when coding

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.

STEAM Activities age bookmark-fill icon bookmark boy-girl broadcast icon calendar chevron-down icon close icon compass cross icon download external icon facebook gallery icon instagram icon Instagram icon linkedin links icon live-lessons icon location mail icon map next play previous professional-development right-arrow icon search share single image social-media speaker spinner icon students subject-update teacher-resources tick icon time twitter user video-lesson video youtube