Use Consistent Naming Conventions
This is basic, and good practice in any programming language, but Mathematica's slow-to-fail nature makes it in a sense a less forgiving language than others, so those of us who have in the past gotten away with bad habits may run into trouble. Suppose I have a function
loseMemoriesLikeTearsInRain[] which I later try to invoke thusly:
loseMemoryLikeTearsInRain[] In some other languages this would result in a compile error, and is easily spotted, but in Mathematica, what usually happens is either
- the unevaluated expression
loseMemoryLikeTearsInRain[]gets passed on to some other function, - Mathematica silently moves on without performing the side effects the function is supposed to perform, or
- both.
For this reason, I have found it especially important to have a consistent set of conventions for naming things. The exact choice is to some extent a matter of taste, but here are some things that have tripped me up:
- inconsistent capitalization,
- starting function names with a capital letter (can conflict with predefined Mathematica functions),
- inconsistent use of singular and plural (I now try to favor the singular whenever possible),
- names that do not distinguish between pure functions and those with side effects (I now use noun-clauses and verb-clauses respectively),
- generally inconsistent, idiosyncratic, or poorly thought out use of terminology,
- attempts to abbreviate beyond what is reasonable or memorable. (One consistent convention is to drop all vowels other than the first letter of the word, whch mks evrythng lk lk ths.)