Differences

This shows you the differences between the selected revision and the current
version of the page.


kbase:so_you_want_to_make_a_wme_game 2007/10/10 16:15 kbase:so_you_want_to_make_a_wme_game 2007/10/10 16:17 current
Line 72: Line 72:
=====Variables and "what have I meant with this?" syndrome===== =====Variables and "what have I meant with this?" syndrome=====
-Okay, this being said, let's move onto our next big problem: **variables and objects**. I already wrote a tutorial about them which can be find [[en:kbase:variables_and_objects|here]], but right now I will speak about semantics. It's really obvious mistake to fill your code with variables named //a, a1, a2, a3 etc. // It's even worse if you think you are cool and name your variables aptly like //SuperVariable15 or MyLittleBlueDaisy// when it has completely no relevance to the code itself. Right now you like that idea, but later on you will hate yourself while trying to spot a bug you made six month ago.  My advice is to be really strict and name variables according to what they really do. So if you need a variable for loop, why not name it this way? +Okay, this being said, let's move onto our next big problem: **variables and objects**. I already wrote a tutorial about them which can be find [[kbase:variables_and_objects|here]], but right now I will speak about semantics. It's really obvious mistake to fill your code with variables named //a, a1, a2, a3 etc. // It's even worse if you think you are cool and name your variables aptly like //SuperVariable15 or MyLittleBlueDaisy// when it has completely no relevance to the code itself. Right now you like that idea, but later on you will hate yourself while trying to spot a bug you made six month ago.  My advice is to be really strict and name variables according to what they really do. So if you need a variable for loop, why not name it this way?
Even worse is the situation with global variables. If you still believe in your //a, a1, etc.// naming convention you can easily use the same variables for global variables as for the local variables! This will lead to unpredicatablity of your scripts and lead you to alcoholism or even worse listening to reneissance music. On the other hand, if you will be systematic and use for example some kind of prefix for your global variables, you will never encounter this. If you are still clueless, here is a tiny example, how can your variables look like: Even worse is the situation with global variables. If you still believe in your //a, a1, etc.// naming convention you can easily use the same variables for global variables as for the local variables! This will lead to unpredicatablity of your scripts and lead you to alcoholism or even worse listening to reneissance music. On the other hand, if you will be systematic and use for example some kind of prefix for your global variables, you will never encounter this. If you are still clueless, here is a tiny example, how can your variables look like:
 
kbase/so_you_want_to_make_a_wme_game.1192025704.txt.gz · Last modified: 2007/10/10 16:17 (external edit)
Recent changes RSS feed Creative Commons License Driven by DokuWiki