8

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.

4
  • 1
    I am assuming you are talking about situations when a name with the same meaning is supposed to adhere to different syntactic and lexical rules in different languages/frameworks. For example, when a data element representing last name of a person is expected to be named "Person.LastName" in C#, "person/last-name" in XML, "T_PEOPLE.F_LAST_NAME" in SQL, and so on and so forth. Is my assumption correct? Commented Jul 12, 2012 at 4:23
  • @Yarik That is exactly it. Guess there are not many opions about it, but I'm curious what people think about the tradeoff being consistent throughout the project vs consistent with each language's conventions. Commented Jul 17, 2012 at 1:27
  • Hi, thanks for asking this question, exactly what I want to know, too. But I'd like to know what about function name? For example it's common to see GetFoo() in C++, while it's common to see getFoo() in actionscript. Commented Feb 13, 2015 at 3:27
  • Also did you ask the same question somewhere else? There seems not many people are talking about this problem... Commented Feb 13, 2015 at 3:28

2 Answers 2

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

We face a similar issue in our web app project. The backend is in ruby, and the frontend is in javascript. So when we need to expose some object from backend to frontend, it is quite confusing whether we should follow the snake case that is common for ruby, or the camel case that is common for javascript.
1

Yes. The DOM would be a good example:

as would SAX:

or ODBC:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.