MUSHCode Style

These are some of the guidelines I try to follow when writing code. They work for me. Your mileage may vary. :)


A lot of people who do offline coding use formatters that let you write code broken up into many lines, and then 'compile' it to one-line attributes that can be quoted into the mush. I don't like them, but they work for a bunch of people. If you do use them, and provide code for public use, just please make it available as the non-formatted version so poeple can just /quote it straight in instead of having to get a program to transform the code to a usable state.

Personally, I use tinyfugue. The ctrl-- key combination does paren/brace/bracket matching, which is really useful. For mass offline editing of larger stuff, I use xemacs with a mushcode mode I threw together, available off the index page.

Attribute names

Names should be meaningful. Have a name that describes what the attribute does. As a convention, I normally give attributes with a $-command on them a name like <COMMAND>_cmd, and helper functions that aren't meant to be evaluated by external functions/code names starting with a period.

Some examples:

Object organization

When working on a large project, I try to have one object just for $-commands, one for ufuns, and a third for data. This doesn't always happen, but it does tend to result in smaller, more managable objects.

Spaces and such

I like to put spaces after commas in function arguments, and after semicolons in action lists. This makes it more readable to me than code with spaces only between words, as well as making it wrap nicer when editing in tinyfugue or other clients.

The use of braces and brackets should be minimized. Brackets are used to force evaluation of what they enclose as a function, and aren't needed when function evaluation normally takes place, such as an argument to another function. Braces are more useful, both for grouping an action list and stopping a string with a lot of commas from being split like function arguments. If there's only a few commas, though, backslashes are nicer.


Last modified: Mon Aug 7 22:36:06 PDT 2000