Menu

Enforcing Capitolization Schemes

brentoboy
2005-04-11
2013-03-08
  • brentoboy

    brentoboy - 2005-04-11

    what if we enforce case sensitivity in ape.  in other words,  since we kind of decided to enforce ALL_CAPS for constants, why not enforce  all_lower_case for variables.  And enforce FirstLetterCase for function names.

    That would require that a function name be more than one character  - since it has to start with a capitol letter, and it can't be all caps

    Maybe, because object properties are not really variables or functions they could be camelCase where it starts lowercase, but capitalizes the first letter of new words.

    What think ye?

    It adds a level of predictability.
    It probably doesnt appeal to newbies, but I dont think it puts them at a disadvantage. - so long as the editor fixes their capitalization mistakes based on what they are declaring.

     
    • brentoboy

      brentoboy - 2005-04-11

      OK, so some people (like myself) hate typing _  if every variable name ends up having a few of them, then maybe my right pinkie finger will go on strike.

      so, what if an underscore was treated much the same way as a capital letter is, namely that underscores are corrected after typing in a variable name - just like capitalization is.

      So, you type:

      Int MyVaraibleName = 0

      and the editor - that knows you declared a variable, fixes it to read like so:

      Int my_variable_name = 0

      And now, myvariablename is in use and whenever we type it - no matter what capitalization we use (and no matter what combination of underscores we use) it will clean it up and make it read:  my_variable_name

      If we had declared it as a constant, it would do exactly the same thing - except it would be all caps.

      Functions would not be allowed to have underscores. - To help keep them separate, and they would be required to be mixed case - and start off capitol.  But, of course, that is only in the declaration, of the function anywhere it is used in the code, it would be auto-capitalized correctly.

       
    • brentoboy

      brentoboy - 2005-04-11

      ok,

      what if, we refine that even more and allow for the following capitolization methods, so we can recognize what kind of info we are working with:

      Constants:
      ALL_CAPS
      (Use underscores to separate words, no lower case allowed. - numbers are ok)
      Examples:
      PI, WM_USER, MAX_INT

      Type Names, Object Names, Reserved Words:
      Normal
      (starts capitol, mixed case - requires some lower case - no underscores alowed)
      Examples:
      Int, Byte, Loop, End Loop, While

      Variables: all_lower_case
      (Use underscores to separate words, no upper case allowed. - numbers are ok)
      Examples:
      x, y, running_total, extra_data, i,

      Functions: doSomething()
      (starts lower case, mixed case - requires some upper case - no underscores alowed).
      toString(), createWindow(), buildString(), emptyRecylceBin()

       
    • brentoboy

      brentoboy - 2005-04-29

      ok, so I've been converting the windows header files into APe syntax, and I honestly dont like function names that start off lower case, and then have capitols in them.

      This :  InitiateSystemShutdown
      is easier to read then that: initiateSystemShutdown

      So I think that for functions, we should follow the scheme above for everything accept for function names.  Function names should be recommended to be capitolized the way reserved words are capitolized, but not religiously enforced as such.

      that's what I think.

       
    • brentoboy

      brentoboy - 2006-05-16

      Two more ideas:

      variable names should use a - instead of an _ becuase - is a lower case _ and because it reads easier on the eyes, consider this:

      return_value vs return-value
      or new_x vs new-x

      you can tell the difference between new *minus* x as opposed to "new-x" becuase new *minus* x would have spaces around the -  like so: new - x

      -

      idea # 2
      functions can (and should) be capitolized as described above, but properties are sort of a mix between functions and variables, so I was thinking that they should start with a lowercase letter, and then be capitolized like function after that, so the word:  Some Random thing would be capitolized like this in the following cases:

      Constant:  SOME_RANDOM_CONSTANT
      Variable:  some-random-variable
      Function:  DoSomeRandomThing
      Property:  someRandomProperty

       

Log in to post a comment.

MongoDB Logo MongoDB