Duwenbasden
Ver 6 CREATE energy AS SELECT * FROM u.energy
- Reaction score
- 165
Lately I've seen scripts that is not only confusing, but also impossible to understand. Please, whenever you are asking for help, or helping others in GUI script or JASS...
>>> Use comments <<<
No, I am not asking you to explain to me what each line means, you just need to explain what each segment of code do. Even a general idea of the function is a good start. The helper or the person asking should not be guessing what your code is trying to do.
Example of good comments:
Example of bad comments:
This case, the first example is much easier to understand than the second one, which is basically repeating what the code "said".
Also, I've seen increasing use of variable names like "u" and "s". These variables are totally meaningless, and also makes the code very hard to understand (The exact reason I am so against the use of GetTriggerUnit() without accompanying comment.) Please, try to use variable names that is relevant to the thing it is trying to do, like "caster" for the caster, "victim" or "target" for the target unit. Remember, you are here to help, or to be helped.
Thanks.
>>> Use comments <<<
No, I am not asking you to explain to me what each line means, you just need to explain what each segment of code do. Even a general idea of the function is a good start. The helper or the person asking should not be guessing what your code is trying to do.
Example of good comments:
JASS:
local integer x = 0 // for loop integer counter
loop // this loop creates 5 units, move them to a random location in LOCATION, and give them ability XYZ.
exitwhen x > 5
call CreateUnitAtLoc (...)
call MoveUnit (...)
call AddAbility (...)
set x = x + 1
endloop // x = 6 here
Example of bad comments:
JASS:
local integer x = 0 // for loop integer counter
loop
exitwhen x > 5 // exit the loop when x > 5
call CreateUnitAtLoc (...) // create a unit at location
call MoveUnit (...) // move the unit to random point in LOCATION
call AddAbility (...) // add ability XYZ to unit
set x = x + 1 // increment x
endloop
This case, the first example is much easier to understand than the second one, which is basically repeating what the code "said".
Also, I've seen increasing use of variable names like "u" and "s". These variables are totally meaningless, and also makes the code very hard to understand (The exact reason I am so against the use of GetTriggerUnit() without accompanying comment.) Please, try to use variable names that is relevant to the thing it is trying to do, like "caster" for the caster, "victim" or "target" for the target unit. Remember, you are here to help, or to be helped.
Thanks.