ARTICLE

pascalCase and camelCase Naming System

Posted by Abhimanyu K Vatsa Articles | C# Language June 17, 2011
In this quick post we will take a look at some un-avoidable naming systems in C#.
Reader Level:

Introduction

pascalCase and camelCase are naming recommendations and it is good practice to follow them always. Everyone is a programmer but the ones who follow these recommendations are good programmers. pascalCase and camelCase naming conventions are purely based on accessibility of class members. In other words, how to specify a method or field name if it has public accessibility or how to specify it if it has private accessibility.

 

Public Naming Recommendation

Identifiers that are public should start with a capital letter. Look at the example given below; the Addition field and Add methods given below start with capital 'A' (not small 'a') because it's public.

This system is known as the PascalCase naming scheme because it was first used in the Pascal language.

class Calc
{
   
public int Addition;

    public double Add()
   
{
       
//statements
   
}
}

Private Naming Recommendation

Identifiers that are private should start with a small letter. Look at the example given below; the addition field and add methods given below start with small 'a' (not capital 'A') because they are private. This system is known as the camelCase naming scheme.

class Calc
{
   
private int addition;

    private double add()
   
{
       
//statements
   
}
}

Remember this recommendation: class names should start with a capital letter. Never declare two public class members whose names differ only in case. If you do so then, developers who are using other languages that are not case sensitive, such as Microsoft Visual Basic, can't use our class.

HAVE A HAPPY CODING!!

Login to add your contents and source code to this article
post comment
     

Your proposal is a good practice. Thanks.

Posted by Luis David Guerrero CHávez Jul 20, 2011

Thank you for posting Sam. What you should reply/recommend/suggest if someone using method name or field name like this cALcuLaTioN(). Probably you'll "it is not good practice buddy" right? The guy who is using cALcuLaTioN() is also programmer, but the difference is, you have good practice and he has no. The same I am expressing though this article here. Is there any wrong, please reply I'll surely change, there are lots of things I need to learn from you all guys. I need your comments always which will make me perfect in coding.

Posted by Abhimanyu K Vatsa Jun 18, 2011

Please understand that I undersand you are not being too serious when you say that programmers "who follow these recommendations are good programmers". So I am not being serious when I say if being a good programmer requires use of these recomendations, then what are authors that don't use proper capitalization in thier articles? Seriously, I think it is futile to try to put everything in a name and development tools are now advanced enough that I think the tools can do a lot to help us know what an item is. Note that according to Microsoft's definition of "Camel case" there is not a differentiation of public and private; see: http://msdn.microsoft.com/en-us/library/x2dbyw72(VS.71).aspx

Posted by Sam Hobbs Jun 17, 2011
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts