Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm just starting to learn C#. Coming from a background in Java, C++ and Objective-C, I find C#'s Pascal-casing its method-names rather unique, and a tad difficult to get used to at first. What is the reasoning and philosophy behind this?

I'm guessing it is because of C# properties. Unlike in Objective-C, where method names can be exactly the same as an instance variables, this is not the case with C#. I would guess one of the goals with properties (as it is with most of the languages that support it) is to make properties truly indistinguishable from variables and methods. So, one can have an "int x" in C#, and the corresponding property becomes X. To ensure that properties and methods are indistinguishable, all method names I'm guessing are also therefore expected to start with an uppercase letter. (This is just my hypothesis based on what I know of C# so far—I'm still learning). I'm very curious to know how this curious guideline came into being (given that it's not something one sees in most other languages where method names are expected to start with a lowercase letter)

(EDIT: By Pascal-casing, I mean PascalCase (which is basically camelCase but starting with a capital letter). Method names typically start with a lowercase letter in most languages)

share|improve this question

migrated from stackoverflow.com Mar 1 '11 at 19:14

This question came from our site for professional and enthusiast programmers.

    
If you saw that all the members of a certain family had all their walls in all their houses painted with a strange insignia, would you be curious why they did it such a strange thing? –  Nocturne Mar 1 '11 at 19:12
    
Why do you think it is called Pascal case? –  R. Martinho Fernandes Mar 1 '11 at 19:14
1  
@Martinho Fernandes it is standard name for this style, check Google –  Andrey Mar 1 '11 at 19:16
1  
@Nocturne - Yes. I would be curious :) –  Joel Etherton Mar 1 '11 at 19:17
1  
The "method names start with a lowercase letter in most languages" is false in my experience. Conventions starting with an uppercase letter - with or without underscore word-separating - are quite common, though not necessarily in official language guidelines. Most language standards don't have any single official style guides. Quite a few languages (mainly older) ignore case anyway, and often have an everything-lowercase convention because don't-press-shift is the laziest rule that means you don't get differently-mixed-case spellings treated as the same confusion. –  Steve314 May 13 '11 at 21:46
show 1 more comment

6 Answers

up vote 22 down vote accepted

It is matter of taste. Someone once decided to use Pascal style for names and it became a standard.

I have a wild guess that it was Anders Hejlsberg, who was architect of Delphi, successor of Pascal. Case style is same there as in C#.

share|improve this answer
    
this was going to be my answer. :P –  DevSolo Mar 1 '11 at 19:23
    
@DevSolo sorry, I started typing answer when question was at Stackoverflow :) –  Andrey Mar 1 '11 at 19:26
    
I think that the roots go even deeper into ancient history - see my answer below :) –  davka Mar 1 '11 at 22:14
add comment

If you are asking about reasons, here is one straight from the horse's mouth:

History around Pascal Casing and Camel Casing article by Brad Abrams at MSDN blogs

In the initial design of the Framework we had hundreds of hours of debate about naming style. To facilitate these debates we coined a number of terms. With Anders Heilsberg (the original designer of Turbo Pascal) a key member of the design team, it is no wonder that we chose the term Pascal Casing for the casing style popularized by the Pascal programming language...

Pascal Casing convention capitalizes the first character of each word (including acronyms over two letters in length)...

And here are the design guidelines: Design Guidelines for Class Library Developers

These guidelines are intended to help class library designers understand the trade-offs between different solutions. There might be situations where good library design requires that you violate these design guidelines. Such cases should be rare, and it is important that you provide a solid justification for your decision. The section provides naming and usage guidelines for types in the .NET Framework as well as guidelines for implementing common design patterns...

share|improve this answer
    
Great links. Thanks for sharing. –  Jared Updike Mar 1 '11 at 20:07
    
thanks for proof of my assumption! :) –  Andrey Mar 1 '11 at 20:18
1  
TurboPascal is the baby of Philip Kahn (aka Borland) which is very convenient for Microsoft to forget. Politics.... –  davka Mar 1 '11 at 22:19
    
The comments on the first link are great, lol. –  jmq Mar 1 '11 at 22:20
add comment

Don't know about philosphy, but Pascal casing seems to be common on Microsoft platforms since at least Win32 API days.

share|improve this answer
1  
and I still hate it, lol. –  jmq Mar 1 '11 at 22:19
add comment

I don't think there was a specific philosophy behind it. There needed to be guidelines, and there were many points that may have affected it:

  • They wanted to get rid of any prefix notations (read hungarian here)
  • They wanted that local/private members and public members be distinguished by just reading their names.
  • They did not want C# code look like Java code (which heavily uses camel case)
share|improve this answer
    
Note that this naming guideline is for the .NET framework and not C# in particular. In VB.NET, a case-insensitive language, the convention remains the same, but you cannot use it distinguish private and public members by case. –  R. Martinho Fernandes Mar 1 '11 at 19:21
    
@Martinho: agreed. but I still feel is was one of the reasons. –  decyclone Mar 1 '11 at 19:22
2  
+1: "They did not want C# code look like Java code (which heavily uses camel case)": I strongly suspect you are right here! –  Giorgio Apr 21 '12 at 16:41
add comment

I don't know that there is a "philosophy" behind the casing other than it's nice and compact and can easily appear as multiple words without using underscores.

There's been many variations of casing over the past few decades. They've ranged from very terse (see C and the standard C library) to verbose with underscores separating each word. While the .NET library convention of naming is still pretty verbose, I think it strikes some middle ground as far as casing.

share|improve this answer
3  
do-not-forget-lisp-style-naming! –  R. Martinho Fernandes Mar 1 '11 at 19:16
    
@Martinho Fernandes actually in context of c-like languages it is not valid. –  Andrey Mar 1 '11 at 19:20
    
Yeah, Lisp takes whitespace into account. (- var1 var2) –  Michael K Mar 1 '11 at 19:31
    
@Martinho Fernandes: Of course, that requires the use of whitespace to separate tokens. It's also COBOL-STYLE-NAMING, which makes it common to the languages I most admire and least admire. –  David Thornley Mar 1 '11 at 19:55
add comment

Taking a wild (but not unreasonable, IMHO) guess - C# design was supervised by Niklaus Wirth, the original inventor of Pascal. See the connection?... :)

Curious #1: I positively remember the announcement of .NET and C# (yes, I am prehistoric...) and how Microsoft bragged by having Wirth's name on C#. Yet, the Wikipedia pages on neither (C# and Wirth) mention this.

Curious #2: Although it is called PascalCase, it was popularized by the TurboPascal compiler (which eventually became Borland), not the language itself.

share|improve this answer
3  
and TurboPascal was conveniently designed and built by Anders Hejlsberg... –  SWeko Mar 2 '11 at 8:08
2  
Anders Hejlsberg was IIRC the lead designer of Delphi, and worked a lot on Turbo Pascal, but Turbo Pascal wasn't originally his baby (it was Philip Kahns). Niklaus Wirth invented the original Pascal and took it through standardisation, then saw the standard largely ignored. Also, Wirth has been retired for just about the whole of the life of C#, and before then designed several successor-to-Pascal languages (most recently Oberon 2) so I doubt he had any direct involvement at all. Microsoft bragged loudly about having Hejlsberg on board. Turbo Pascal was a Borland product from the start. –  Steve314 May 13 '11 at 21:35
    
I don't mind downgrading - I have enough points on StackOverflow, but I am curious about the reason –  davka Apr 13 at 13:36
add comment

protected by World Engineer Jun 6 '13 at 12:34

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.