Tip of the week - comment your code!
- Posted by ChrisB (moderator) Oct 03, 2010
- 1082 views
This weeks tip of the week brought to you by me(!)
Comment your code profusely. Its easy to remember what you wrote that obscure looking line or what those oddly named variables were, or where those global variables / functions were defined when you wrote the code earlier that week, but try to remember what they were in 6 months time!
function add_splodges(integer a, sequence X_ogg) end function
is a lot harder to understand than
------------------------------------------------ function add_splodges(integer a sequence Xogg) --a function to add a to all items in X_ogg --X_ogg - a sequence of oggs --returns - a sequence of oggs with a added ------------------------------------------------ end function
Whats more, you can block comment with the C construct /* .. */
/*This is a block of code to explain what I'm about to do here but the block would be so long as to make putting -- tedious */ --(note, the web page display has 'issues' with displaying the above correctly!
You can also use /* .. */ to temporarily block off a section of code tosee the effect, as if the code were not there.
Also its a lot easier for other people to understand and modify your code later - check out the standard libs for an excellent set of examples.
Post your own tips to totw@openeuphoria.org - remember they can be as simple as you like, or as complicated as you want to make them. We're all interested in knowing what you have discovered to help your coding experiences.
Chris