5

In .Net 4.5, System.Math.PI is written as such, in all caps. Microsoft's own Capitalization Conventions state that Pascal casing is to be used for all public members. Also, their conventions on Names of Type Members mention that all public static fields (which PI is, considering that it's a const) should use Pascal casing.

I'm aware that there's sometimes a convention to name constants in all caps, but the capitalization conventions mention nothing about constants. Pi is also not an acronym like IO, so shouldn't it just be System.Math.Pi?

Bas
  • 1,946
  • 21
  • 38
  • 1
    And it is not even an abbreviation (like ID = identifier) :-) – xanatos Feb 23 '17 at 10:50
  • 3
    If they'd been brave, they'd have named it `Math.π`. So maybe because it's real name is only a single letter, it is in pascal case, as much as one letter can be :-) – Damien_The_Unbeliever Feb 23 '17 at 10:51
  • 5
    My money's on it being a mistake in the early framework versions, and although fixing it would be trivial, it would be a huge breaking change to client code with no real benefit, so it stays as it is. – Patrick Allwood Feb 23 '17 at 10:54
  • 1
    There are other similar errors, like the `RSA` class (all upper-case). – xanatos Feb 23 '17 at 10:56
  • If we consider `PI` to be the Asciization of `π`, then being `π` uppercase, the whole `PI` should be uppercase (ok, I know, it is stupid :-), as we say in italy, it is an "arrampicarsi sugli specchi", "clutching at straws" for english-speaking persons) – xanatos Feb 23 '17 at 10:59
  • 1
    More famous errors: the whole `Encoding.*` static properties: `ASCII`, `UTF7`, `UTF8`, `UTF32` – xanatos Feb 23 '17 at 11:01
  • @xanatos And that's even besides the fact that two letter abbreviations should _also_ only capitalize the first letter. :) – Bas Feb 23 '17 at 11:13
  • 1
    Not so sure if this is a shocker, but PI was used long before .NET came around :) Very often capitalized, they just didn't break with the common convention. Like [Cobol](http://opencobol.add1tocobol.com/#what-is-pi-in-opencobol), [Fortran](http://stackoverflow.com/questions/2157920/why-define-pi-4atan1), [C](http://stackoverflow.com/questions/9912151/math-constant-pi-value-in-c), etc. Pascal was a notable exception. – Hans Passant Feb 23 '17 at 11:26
  • @HansPassant At least two examples are bad: in C it was "correct" to be all-upper because it was a constant. Older fortran were all upper in general... On Cobol I can't speak (but being very old, I wouldn't be surprised if it was an all-upper language) – xanatos Feb 23 '17 at 11:34
  • @Bas: Certain two letter abbreviations are generally written entirely in uppercase or lowercase; ID comes to mind. I think someone likely decided that `.Pi` looked weird, and that `.PI` looked better. – supercat Mar 29 '18 at 16:08

0 Answers0