Naming convention in Phobos

%u wfunction at hotmail.com
Mon Mar 7 01:36:11 PST 2011


> The general naming convention as far as variable names go is camelcased with the name starting with a lower case letter - this includes constants. Most of Phobos follows this, and the parts that
haven't been have been moving towards it. There are likely to be a few exceptions, but on the whole, that's how it's supposed to be. Type names are the same, except they start with an upper case
letter (this includes enum names - the enum values are capitalized the same as any other variables however). That's the way it has been, and that's the way that it's pretty much guaranteed to stay.


I don't like the idea that enum values (which are constants) would also be camelCased; I think they should be PascalCased. Why? Simply because something like:

enum InteropKind
{
    import,
    export
}

won't compile. Furthermore, these aren't "variables" (they can't vary *at all*, even through casts -- unlike immutables) so I think enum values should be CamelCased.
(PLEASE DO NOT USE ALL CAPS as it has no real benefit, and since it needlessly forces the use of underscores.)


Another issue: Whatever the naming scheme is, please make sure that it's _specific enough_ that it won't conflict with other imports through reasonable use. E.g. don't make a function in std.path
called getName() to get a file's name, because someone who's unaware of this could easily call getName() for a totally different module (say, hypothetically, on an Exception) and it would confuse
the heck out of the reader. In this case, I'd say it should be getFileName().


If there's a lot of good choices, then I'd say that using a camelCased version of what Microsoft does in .NET would be a good idea; e.g. getFullPath(), isPathRooted(), getTempFileName(),
getDirectoryName(), etc.


Just my take on this... any thoughts?


More information about the Digitalmars-d mailing list