Naming Conventions for a Multilingual Language Project

I am currently working on a project that includes several different programming languages, each of which has its own conventions on how things should be called. Should the same naming convention be used throughout, or should the names be different in each language in order to have an appearance (i.e., not interfere with the rest of the framework)?

For example, the project uses MongoDB (BSON), C #, JSON, and Javascript. Right now I call things in each layer a layer agreement, and then the code between each layer to translate, say, from BSON to a C # model. MongoDb, on the other hand, will do this automatically if the naming convention is the same.

+6
source share
2 answers

Twenty years ago, when I was just starting my professional career, I would probably agree with Paul and say: "Go to universal naming conventions!". :)

Today my answer is different. Accepting decent naming conventions is challenging, even if you are dealing with a single programming language. Having universal conventions for several languages ​​/ frameworks is a noble goal and an excellent brain teaser, but in general I do not consider this possible. The syntactic and lexical rules of different languages ​​/ frameworks are too diverse for "one size fits all." In addition, the set of languages ​​/ frameworks used can change at any time, and the corresponding adjustment to your “universal conventions” can be prohibitively expensive or prohibitive.

Therefore, I would recommend focusing primarily on solid and decent conventions for each language / structure (or for each group of languages ​​/ frameworks that are fairly similar - for example, C and C ++). One of the good results of this approach is that projects in which only one language participates should adhere to a set of agreements that do not look “foreign”.

Having said all this, I believe that some conventions may be common to all the languages ​​/ frameworks involved, without becoming too “alien”. Moreover, such a thing as vocabulary should be common to the entire project. These are mainly semantic and lexical rules, of course; but even some syntax rules can also be universal. For instance:

  • Lexical rules for entity names (for example, "always use singular nouns").

  • Lexical rules for acronyms (for example, "use only well-known acronyms").

  • Syntax rules for compound names (for example, "always use a common and then a specific sequence").

The above examples are, of course, simplified. But I hope the idea is clear: any general agreements can be general, but it will always be just a subset of all the conventions that you need.

+5
source

Source: https://habr.com/ru/post/906493/


All Articles