A Dog named dog?
In many programming languages, it’s a popular conventionor even a language rulethat class names begin with a capital letter and class instances begin with a lowercase letter. For example, you might have a Dog
class and a particular instance of that class named dog
. In other words, you have a Dog
named dog
, and dog
is a Dog
.
I just accepted that as the normal state of affairs, until I read my daughter her new book Just Dog.
Just Dog begins:
“Dog was a dog and that’s what everyone called him. Dog. Just Dog.”
Now wait a minute. The story doesn’t say dog
is a Dog
, it says Dog is a dog.
Come to think of it, I’m not a Person
named mike
, I’m a person named Mike.
So why do we use a naming convention in programming that is the exact opposite of how we name things in the real world?
And even more puzzling, why does it feel right?
Because that convention is for naming persons, not things. The opposite convention in programming feels right probably because we are used to it, and real-life convention for things - “the book” is an object, “a book” is a class - does not fit in programming.
That must be it. Just for fun, I tried writing a few lines of code using “
Dog
is adog
” notation, and it didn’t look right at all. So it’s back to “dog
is aDog
.” :-)mmhh.. interesting. maybe because a the naming convention has been chosen by architects, who prefer classes and not by developers, who use instances. classist? :)
A PascalCase named camelCase
In both “Dog” and “Mike” the capitals are safely on the names as they should be. Even in the case where the objects are resources rather than literals it’s the predicate we conventionally begin with miniscule letters which relate to the “was” and “named” in your natural-language examples, the objects would conventionally begin with majuscule letters.
Ooops. Got here from a post citing this one on a blog largely concerned with RDF, and I read this with RDF thoughts in my head and didn’t cop-on that it was OO conventions being described. I look kinda stupid now after the last post. Also, my examples were treated as partly mark-up. Aw well, another lesson about not posting comments with insufficient blood-caffeine.