A Dog named dog?

Michael Geary | Mon, 2004-08-09 15:15

In many programming languages, it’s a popular convention—or even a language rule—that 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?

Submitted by Artem (not verified) on Mon, 2004-08-09 16:07.

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.

Submitted by Michael Geary (not verified) on Tue, 2004-08-10 17:18.

That must be it. Just for fun, I tried writing a few lines of code using “Dog is a dog” notation, and it didn’t look right at all. So it’s back to “dog is a Dog.” :-)

Submitted by Marco P (not verified) on Wed, 2004-08-18 08:00.

mmhh.. interesting. maybe because a the naming convention has been chosen by architects, who prefer classes and not by developers, who use instances. classist? :)

Submitted by Web Log di Adrian Florea (not verified) on Fri, 2004-08-27 03:38.

A PascalCase named camelCase

Submitted by Jon Hanna (not verified) on Thu, 2004-09-02 18:14.

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.

Submitted by Jon Hanna (not verified) on Thu, 2004-09-02 18:18.

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.