Just to offer you guys a different take on this - It seems that my
post was encouraging extensive commenting of code. Actually, you will
find barely any comments in my code. I find that comments very often
get out of date as specifications change, what in essence you are
doing is repeating information (in code & in comments) - and
inevitably somewhere along the line one gets out of sync with the
other.

I dont claim to write the fastest executing code in the world, but I
do strive to make it both human & machine readible. This comes down to
being very clear about what your functions are called, and breaking
down your work into pretty granular pieces - more than make would
expect. For example - lets say I have an if statement which checks
some stuff:

//check mouse is in bounds
if(_xmouse>rightEdge && _xmouse<leftEdge && _ymouse>topEdge &&
_ymouse<bottomEdge){
 ...
}

I am likely to refactor something like this to:

if(mouseInBounds()){
 ...
}

private function mouseInBounds():Boolean{
 return _xmouse>rightEdge && _xmouse<leftEdge && _ymouse>topEdge &&
_ymouse<bottomEdge
}

This way I can notify other people who will be looking at the code
what my intention was. I use comments to notify when something was
done in a hackish way, of there is a known bug in the code, or
something else that may give a new pair of eyes a "huh?" moment...

Back to my point about optimization - I can imagine some of you guys
are reading this and thinking that this will slow down the app too
much. Well, as Ryan mentioned in his post - write the clearest code
first *then* and only then, if it is too slow, identify where the
bottlenecks are and concentrate on them...

*Stands down off soap-box*

PBH
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to