Page 2 of 2

Re: Noob looking for help!

Posted: Thu Apr 14, 2011 6:17 pm
by Lafolie
TheKraigose wrote:A tip - comment often - specifically at the top of each function or each lua file. This will help you remember what function does what in detail. It may seem weird but trust me, it's good practice.
This is something that you should get used to doing right from the start. This little piece of advice can be found a million times over if you search for programming tips. It's one of those things that makes such a huge impact yet requires so little effort but many people still don't do it.

Even if you're just writing a relatively arbitrary function that is small and simple, commenting it's purpose, arguments and methodology can be incredibly useful. It helps not only with debugging but just understand your older code (which is easy to forget!), especially when you remember that you coded something before and want to go back and re-use it or whatever.

For me, commenting code helps me understand what the hell is going on when I get an unexpected error or odd behaviour. Reading what a few lines is supposed to do rather than studying syntax first makes more sense to me and helps me identify my mistakes and understand what is actually going on much more easily.