|
Code formatting - Best practice |
|
Written by eaxs
|
|
Thursday, 27 August 2009 11:24 |
Everyone has his own coding style and approaches things in a different way. That's perfectly ok and everyone is free to write his code however he pleases. But there are a few rules regarding code formatting to which you should adhere.
English please! If you are not a native english speaking person you would probably write your variable names and other expressions in your own language. But that's not optimal. Try to write your entire code in english so everyone around the world can understand and read your code more easily!
Typography Typography is how you design your words and expressions such as variables and anchors. It is import that you have a strict and unified system of how you write down your code to keep it as readable as possible. For example you can write all your anchors in UpperCase and all your variables in LowerCase with underscores. This helps a lot identifying the different types of expressions.
Uppercase for anchors
LowerCase with underscores for variables
this_is_lowercase_with_underscores Comments please If your code starts to become complex, add a comment for yourself and others who might want try to understand how your code works. This can be a huge time saver if you come back a few weeks later to continue working on your project. And overall it helps understanding your code structure. You can add single line comments using //
// the amount of players on the server
CreateVar int _numplayers
|