Re: Function and object naming conventions
- To: mathgroup at smc.vnet.net
- Subject: [mg106773] Re: Function and object naming conventions
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 23 Jan 2010 07:32:19 -0500 (EST)
On 1/22/10 at 5:38 AM, lshifr at gmail.com (Leonid Shifrin) wrote: >>I have seen one general recommendation to use all-lower-case for >>functions, since Mathematica proprietary functions use initial caps. >For functions, that's probably too restrictive given that >Mathematica is a functional language and an average >idiomatically-written Mathematica program is likely to contain many >more functions than (global) variables. Many (myself included) find >it convenient to use the "camel" notation, like <getAllWordsInText>. >This can be partly motivated by the fact that this notation is used >by Mathematica built-ins. What matters is that the first letter is >lower-case - this is enough to guarantee that you don't collide with >a built-in. What you write above is true. But I believe a more important reason for camel case is readability of code. Contrast alongvariablename with aLongVariableName >For variables, it seems a common practice to use all-lower-case >names, since there are typically not so many of them in any given >function. I personally sometimes use camel notation also for >variables, but I don't know how common this practice is. My practice is similar. For short variable names that are also local variables, I use lower case. For one line functions, the variable name I use will most likely be a single lower case letter. For longer names or global variables, I use camel case.