News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

How to write good code

Started by jamespetts, January 07, 2011, 09:47:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

VS

#1
There is also a highly verbose counterpart... We are already good on a few points:

Quote
Names From Other Languages
Use foreign language dictionaries as a source for variable names. For example, use the German punkt for point. Maintenance coders, without your firm grasp of German, will enjoy the multicultural experience of deciphering the meaning.

Units of Measure
Never document the units of measure of any variable, input, output or parameter. e.g. feet, metres, cartons. (...) If somebody challenges you, tell them you did so that you could use integer rather than floating point arithmetic.

Lower Case l Looks a Lot Like the Digit 1
Use lower case l to indicate long constants. e.g. 10l is more likely to be mistaken for 101 that 10L is. Ban any fonts that clearly disambiguate uvw wW gq9 2z 5s il17|!j oO08 `'" ;,. m nn rn {[()]}. Be creative.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Spike

Quote from: jamespetts on January 07, 2011, 09:47:39 PM
All developers should read this.

Hehe :)

You know, from these:

quick - cheap - good

You usually only can have two:

quick and cheap -> won't be good
cheap and good -> won't be quick
quick and good -> won't be cheap



jamespetts

No prizes for guessing which one that Simutrans doesn't have ;-)
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

neroden

Quote from: VS on January 07, 2011, 10:38:57 PM
There is also a highly verbose counterpart... We are already good on a few points:

Heh.  I was trying to fix those, you know, but it is really hard to fix that stuff after the fact.  One of the catches is that major code cleanup patches, particularly the crucial renamings, *do* destabilize everyone else's workflow -- I think the only way to do it would be if everyone agreed to not develop any major new features for (say) a month while people work on code cleanup.