Camel Case, Snake Case and Other Notations

Camel Case   Snake Case

There are a few syntax styles among programmers. I mentioned snake and camel case previously. Here are a few of the different notations:

    snake_case_notation
    cameCaseNotation
    PascalCaseNotation
    nocasenotation
    kebab-case-notation

Excel LAMBDA is not case sensitive. So while you don't have to use these notations, without them code reading becomes difficult.

I also recommend keeping Excel native functions in upper case. e.g. SUM, AVERAGE, COUNT. This to distinguish Excel functions from your own functions and variables. 

Snake Case Notation

I used snake case notation in Excel LAMBDA because LAMBDA didn't have an IDE (yet!) and I was writing the functions in a plain text editor. Snake case notation is easy to read as the individual words are spaced out.

    grp_sum, BYCOL(array, LAMBDA(p_column, SUM(p_column))),
    my_var, long_function_name(array),

Camel Case Notation

I switched to camel case notation when I started implementing data mining methods. Data mining methods were lengthier and I frequently ran into the Formula Name Manager limit. To overcome this issue, I opted for camel case notation instead.

Both snake case and camel case improve readability:

    grp_sum, BYCOL(array, LAMBDA(p_column, SUM(p_column))),   // Snake Case
    grpSum, BYCOL(array, LAMBDA(pColumn, SUM(pColumn))),      // Camel Case
    grpsum, BYCOL(array, LAMBDA(pcolumn, SUM(pcolumn))),      // No Case
    
    long_function_name  // Snake case. Easy to read.
    longFunctionName    // Camel case. Fairly easy.
    longfunctionname    // No case. Difficult to read

Pascal Case Notation

This is similar to camel case, popularised by the Pascal programming language. It is similar to camel case notation, except the first letter is always in upper case. You might want to consider Pascal case for function names. This will distinguish them from variables.

    long_function_name  // Snake case. Easy to read.
    longFunctionName    // Camel case. Fairly easy.
    LongFunctionName    // Pascal case. Fairly easy.

    my_var, SUM( long_function_name(input_array)), // Is long_function_name a function?
    myVar, SUM( longFunctionName(inputArray)),     // Is longFunctionName a function?
    myVar, SUM( LongFunctionName(inputArray)),     // LongFunctionName is a function.

Some programmers would suggest variable names to be clearly a noun, and function names to be in verb form.

    my_var, SUM( get_function_name(input_array)), // Snake case
    myVar, SUM( findFunctionName(inputArray)),    // Camel case
    myVar, SUM( SearchFunctionName(inputArray)),  // Pascal case

No Case Notation

This is still useful especially with single variable names. Do avoid uncommon acronyms as you will not remember their purpose in your codes.

    total, SUM(array),
    avg, AVERAGE(array),

Kebab Case Notation

Lastly I do wish to mention the kebab-case-notation. It is so called because it looks like a skewer poking through the pieces of meat and vegetables.

Unfortunately this notation cannot be used, as LAMBDA treats the "-" sign as a subtraction operation.

Conclusion

Here's a summary of some of the things discussed.   

Notation LAMBDA Usable Readability Suitability
nocasenotation Yes Poor Single word
camelCaseNotation Yes Fair Multi word, space saving
PascalCaseNotation Yes Fair Multi word, space saving
snake_case_notation Yes Good Multi word, easy to read
kebab-case-notation No Good LAMBDA considers the - sign
a subtraction operation

Excel LAMBDA is not case sensitive. But choosing and being consistent with case notation is important as it improves readability of your codes.

Now that you know the different types of notations, go use them in your DC-DEN!

Comments