"A little progress everyday adds up to big results"

Tuesday 29 May 2012

My coding conventions

                                  When I started programming, I didn't follow any conventions in naming the variables and functions. But, as days passed by, I started using standard conventions for naming. The naming conventions I use for programming are

class - Every word in title case - standard Java convention

method - Every word except the first one in title case - standard Java convention

variable - Every word in lower case, each word separated by an underscore '_'

non-final, non-static, member variable - Every word in lower case, each word separated by an underscore '_' and prefixed with 'm_'

non-final, static, member variable - Every word in lower case, each word separated by an underscore '_' and prefixed with 's_'

final variables - Every word in upper case, each word separated by an underscore '_'

Other conventions used by me:
Task pending - // TODO: - Convention followed by Eclipse IDE

Optimization possible - //::

Test code which has to be removed later - surrounded by lines // TEST //

3 comments:

  1. Dear Suresh,
    This is nice.
    But, why haven't you added about indentation and spacing in your convention ?

    ReplyDelete
    Replies
    1. Vignesh,
      I use normal indentation ( Allman indentation style, where a blank line is left after each close curly brace, conditional and looping statements ) and leave a space wherever possible ( before and after parentheses, after comma, before and after an operator, etc ).

      Delete