News:

Want to praise Simutrans?
Your feedback is important for us ;D.

Code quality: Unify variable names

Started by Spike, February 27, 2012, 03:02:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Spike

Some classes have variables of the same purpose, but all with different names. I suggest to unify the names.
   
From hausbauer_t:


/*
* Diese Tabelle ermöglicht das Auffinden einer Beschreibung durch ihren Namen
*/
static stringhashtable_tpl<const haus_besch_t*> besch_names;


From tunnelbauer_t:


static stringhashtable_tpl<tunnel_besch_t *> tunnel_by_name;


From brueckenbauer_t:


static stringhashtable_tpl<const bruecke_besch_t *> bruecken_by_name;


From vehikelbauer_t:


static stringhashtable_tpl<const vehikel_besch_t*> name_fahrzeuge;


From warenbauer_t:


stringhashtable_tpl<const ware_besch_t *> warenbauer_t::besch_names;


From wegbauer_t:


static stringhashtable_tpl <const weg_besch_t *> alle_wegtypen;



These variables all serve the same purpose - to hold all besch_* objects of this one type, and allow to look them up by name. So they should be named very similar like "all_abc_by_name" with abc being the type of object stored. This would help a code reader to understand that these variables are functionally equivalent.

At the moment there are three naming schemes in 5 classes being used for the same thing.

Also, only one has a comment that explains what it does. (Assuming a code reader can read german).


prissi