SIGN UP MEMBER LOGIN:    
ARTICLE

pascalCase and camelCase Naming System

Posted by Abhimanyu Kumar 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
share 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 Kumar 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
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Gauge for SharePoint
Become a Sponsor