For commerical coding, I am accustomed to a “Best Practices” or “Code Guidelines” document that codifies code style expectations. These guidelines mostly fall into two categories:
- Readability/maintainability and
- Code robustness (ie coding that is least susceptible to unexpected/unwanted interactions)
A quick search did not turn up a previous discussion, though maybe it was called something different?
This early in my authorship, coding in a one-man bubble, I would like to test a few informal #2 patterns I seem to have evolved, and further solicit any additional rules others find useful. Note these are guidelines, not hard and fast rules. Some of these are objectively not great.
- Create a new Class if cut’n’paste > 2 (some might use a lower number!)
- use gActor rather than me in almost all cases, especially new Verb definition
- use obj.isDirectlyIn(gActor/me) rather than obj.location == me/gActor
- use message parameter strings ie {it dobj/he} in dobjFor/iobjFor(Verb) implementations added to Classes. Use them rarely inside specific object instances
- use double quotes instead of mainReport (mainly because it looks less cluttered to me)
- use StringPreParser when I can’t figure out how else to do something. Rarely go back and fix it if I figure it out later.
- When creating new objects, localize new verb definitions, including Thing modifications with them. This is a two-edged sword. It allows me to conceptualize and see all the relevant code together. It also means a crap-ton of Thing modifications sprinkled everywhere throughout my code.
- A minimum of three source files: game/map/objects, hints and npcs. Bigger games may have multiples of each of those.
- Define Topics immediately above the object/npc most likely to use them, and define that object before any others that might use them. The compiler seems to need to see topics defined before referenced? I am awaiting the day I trip over multiple file dependencies biting me.
- Almost always use Component instead of Fixture due to the reporting differences.
- General purpose verbs and functions defined at the bottom of a file, probably the Game file (usually not enough to push into its own file)
- use inherited even when in doubt. change if looks wonky
- heavy use of MulitInstance for new class’s scenery, acknowledging the result can be samey
Those are probably the big ones so far. If some above are misguided, head me off now, before my codebase gets too big! Def let me know if there is a relevant thread I couldn’t find. Also, love to hear any internalized practices ya’ll are benefiting from.