Search code examples
interopnaming-conventionsmultilingual

Naming Conventions for a Multi-Programming Language Project


I am currently working on a project that incorporates several different "programming" languages, each of which have their own conventions for how things should be named. Should the same naming convention be used throughout, or should names be different in each language to have a native look (ie not clash with the rest of the framework)?

For example, ths project uses MongoDB(BSON), C#, JSON, and Javascript. Right now I name things in each layer with that layer's convention and then have code between each layer to translate, say from BSON to the C# model. On the other hand, MongoDb would do this automatically if the naming convention was the same.


Solution

  • Twenty-something years ago, when I was just starting my professional career, I'd probably agree with Paul and say "Go for a universal naming conventions!". :)

    Today my answer is different. Coming up with a decent naming conventions is a challenging task even when you are dealing with one programming language. Having universal conventions for multiple languages/frameworks is a noble goal and excellent brain teaser, but in general I don't think it's feasible. The syntactic and lexical rules of different languages/frameworks are way too diverse to make "one size fit all". Besides, the set of the employed languages/frameworks can change at any time, and appropriate adjustment of your "universal conventions" could turn out to be prohibitively expensive or prohibitively untimely.

    So I would recommend to focus primarily on solid and decent conventions for each language/framework (or for each group of languages/frameworks that are sufficiently similar - like C and C++, for instance). One nice outcome of this approach is that the projects involving only one language would have to adhere to a set of conventions that does not look "foreign".

    Having said all that, I believe that some conventions can be common for all the involved languages/frameworks without becoming too "foreign". Moreover, such thing as vocabulary should be common for entire project. This is mostly about semantic and lexical rules, of course; but even some syntactic rules can be universal, too. For example:

    • Lexical rules for entity names (e.g. "always use singular nouns").

    • Lexical rules for acronyms (e.g. "use only wide-known acronyms").

    • Syntactic rules for composite names (e.g. "always use general-then-specific sequence").

    The examples above are oversimplified, of course. But I hope the idea is clear: whatever conventions can be common should be common, but it's always going to be just some subset of all the conventions that you need.