Monkey Game Development:Beginner's Guide
上QQ阅读APP看书,第一时间看更新

One more thing... comment your code!

Well, we are not at a presentation show of the next big thing from a fruity computer company, but this is very important! As you might have noticed already, we have commented the code in Pongo a lot. Some will say that you only need to add comments to your code when you show it to other people. Other people say that it will also help you to understand your own code, later on.

Imagine finishing a piece of code, and then after several months, having to look at it again and make important changes or fix a nasty bug. Without comments, it could become very difficult to do, even for yourself on your own code. A well-commented source code is much easier to understand.

And remember the two different methods to comment code in Monkey:

  • Single-line comments, such as:
    'This is a single line comment
    
  • And multi-line comments, such as:
    #rem
    This is
    a multi line
    comment!
    #end
    

So, make it a habit to comment your code. One day you will thank yourself for it!