• Welcome to Valhalla Legends Archive.
 

On Conventions

Started by Ender, February 05, 2006, 02:20 PM

Previous topic - Next topic

Ender

I read the following rules:
1) Classes/other Types should have the first letter uppercase
2) Variables and fields should have the first letter lowercase
3) Functions should have the first letter lowercase
4) Words can be separated either by an underscore or by capitalizing the letter of each word after the first word (like Java)

But what about file names? It seems logical to capitalize file names, so that they aren't confused with standard library files. I read from some site that filenames should be named similar to the source code, and that files:classes should be 1:1. The site was ambiguous, however, in that it capitalized the class but kept the file name in lowercase in its example! Hypocritical... So, anyways, lets say I have class Person in a header file. The header file should be named Person.h ? Or person.h ? And what about .cpp files? Should they be capitalized or not?


Kp

That you're asking about .cpp files says you're probably using Windows, but I'll go ahead and warn you anyway.  Many Unix users will get very perturbed if you go around capitalizing filenames needlessly, since Unix filesystems are usually case sensitive.  Of course, given our vastly superior command shells, some Unix people will retaliate by using filenames which are a real nuisance to type with anything less than autocomplete=ambiguous. :)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Skywing

Conversely, I've worked on some real unix projects with filenames like "ExampleFilename.cpp" instead of always all lowercase.

If you are working on an existing project, probably the best course of action is to remain consistent with already existing conventions.