1

When I was using Asp.Net Core 2.0 Web Api for Json(Cammel Case), I came across the following:

UNCouncil --> unCouncil

Most stack overflow sources like this question got me into thinking what is the correct implementation? That question only cares for the first letter.

UNCouncil --> uNCouncil

Clearly, the Microsoft Implementation seems More Readable, but when it comes to this:

UNCouncilWFPSection --> unCouncilWFPSection

Shouldn't WFP be Wfp? What's the recommended way?

In this snippet in Netwonsoft.Json Git Repository, only first letter is given consideration.

According to this article in wiki.c2.org,

  • The word does not end on a capitalized letter: CamelCasE
  • No two capitalised letters shall follow directly each other: CamelCAse

Clearly, both of these are not properly satisfied by any of these contract revolvers.

So, My question sums to the following:

  1. Shouldn't (the proper implementation) ToCammelCase of two words be equivalent, just like Lower/Upper case? [Try: AppleINC vs AppleInc]
  2. Is there a proper specification or is it whatever the developer feels?
tika
  • 7,135
  • 3
  • 51
  • 82
  • You can read about Microsoft's [Capitalization Conventions](https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions) for designing .NET libraries. These are just guidelines, not rules that you _must_ follow. – Martin Liversage Sep 26 '17 at 08:27

1 Answers1

1

"UN" is an acronym (at least in the context you presented it). So normally, you would leave it as upper-case since it's only two characters long. That is, UNCouncil would be appropriate.

As per this answer some guidelines Microsoft has written about camelCase are:

When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io.

Do not use abbreviations in identifiers or parameter names. If you must use abbreviations, use camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word.

Reddog
  • 15,219
  • 3
  • 51
  • 63
  • But it's totally up to you... It's all just a "style", so do whatever floats your boat. In the case of JSON, use whatever the reader of your document is expecting... – Reddog Sep 26 '17 at 03:35
  • Just to piggyback that microsoft guidelines link, they have a whole section on naming, in general if you follow the breadcrumbs... https://msdn.microsoft.com/en-us/library/xzf533w0(v=vs.71).aspx – bwoogie Sep 26 '17 at 03:45