   Variable names (No, not the usual topic...)
  Or at least I hope it isn't.  My question is, when you are reading someone else's code, do you mind if someone heavily abbreviates?  For example (this example isn't meant to show an actual peice of code, it is meant to show different names):int spd;    //Speedint fps;    //Frames per secondint hp;//Hit pointsint mp;//Magic pointsint gvty;   //Gravityint dmg;    //Damageint jmpHt;  //Jump heightint dist;   //Distance    I don't do this yet, but I am getting tired of looking at long lines of code. I am if wondering people hate seeing code with ridiculously abbreviated variables names, if they are commented at their declaration.[edited by - PlayGGY on February 18, 2004 12:10:04 AM]
  If the scope of the variable is small (short function, inner loop), it''s not a big deal. If the scope is large, then some of those abbreviations are just plain stupid (gvty? wtf?!) ;  It''s a lot faster and easier on and for your brain to process the whole words.  Basically, it''s really not Dependant on length at all unless you have tons of syntax on a single line that your brain has to filter out anyway.  Take regular language, for example.  It''s a lot faster to read this post than it would be if I started using abbreviations for words, even if I could cut the length in half.My opinion is that someone''s time isn''t so important that they have to write spd instead of speed.  The extra characters probably save development time in the long run anyway.;  It really depends on the abbreviation to me. Speed should be spelled out, but fps is a normal abbreviation for frames per second so it is fine. hp, mp, dmg, and dist are the same as fps in that they are usual abbreviations. The rest are not (well, jmp and ht might be individually, but it looks weird together) so I would much prefer them spelled out as words. If they weren''t, its easy enough to do a search/replace, so it wouldn''t bother me much. The only way it would bother me would be if the same letters were used to stand for different things so that a search/replace wouldn''t work. ;  OK, I guess I won''t abbreviate as much as planned.I just don''t like looking at wordy lines.  It wasn''t about being confused by them. ;  There are other ways to chop up those long lines - one thing that I like to do when things start getting hairy is to declare new variables for everything.So instead of a line like this:thisThing->doSomething(otherClass->aStruct.field1, otherClass->aStruct.field2, some_value * (whatever + blah + blahblah));you could break it up like this:MyStruct& struct = otherClass->aStruct;int thirdArg = some_value * (whatever + blah + blahblah);thisThing->doSomething(struct.field1, struct.field2, thirdArg); ;  I think such laziness is really not forgivable. Modern IDE's have made abbreviations have little purpose outside of obfuscating code. Incidentally the same is true of hungarian notation and the many bizarre derivitives it has spawned. I also feel that "space saving" bracketing does little more than obfuscate code as well.for( ;;; ) {  ..;  ..;  ..; }Compared to:for( ;;; ){    ..;    ..;    ..;}One is about a thousand times easier to read at a glance and modern ides have the ability to 'collapse' sections of code from view. This makes the argument that it improves readaibility since it compacts 'less relevant code' invalid.   [edited by - haro on February 19, 2004 3:24:20 AM]