开发者

How to do CamelCase with German words (or with any other language that supports compound nouns)?

开发者 https://www.devze.com 2023-04-01 23:37 出处:网络
Disclaimer: Feel free to close this as \"too localized\", if you think it is inappropriate for StackOverflow. Since there\'s quite a large German-speaking community here, I thought I\'d give it a try.

Disclaimer: Feel free to close this as "too localized", if you think it is inappropriate for StackOverflow. Since there's quite a large German-speaking community here, I thought I'd give it a try.

CamelCase is used frequently in programming language conventions (method names in C#, public method names in Java, etc.). It's quite easy to do in English: You just concatenate the words and capitalize the first letter of each one: DisplayName, InternalName.

German, however, supports compound nouns in many cases. E.g., "Anzeigename" (DisplayName) is a single noun, but "interner Name" (InternalName) is not. So, the latter case is easy to camelify: It's InternerName, just like the CamelCase rules in English. What about the first case? One could

  • use Anzeigename, to keep consistent with German grammar, or
  • use AnzeigeName, to keep consistent with the look and feel of CamelCase and with other *Name-s, which are not single nouns.

Is there some guideline or well-established best pract开发者_高级运维ice on this?

I realize that just using English names solves this problem quite easily, but that's sometimes not feasible when developing domain-specific software, or when configuration files must be human-readable by people without good English language skills. It just doesn't make sense to make up an English translation for Umsatzsteuervoranmeldung, when you are certain that the software will only be used in a German language context...


There is the same problem in English too.

For example Surname versus LastName

Use a captial if when written in the language there would be a preceding space


I don't think there's any reason why you would camelcase names to be "conformant". Norwegian (my native language) works the same way and camelcase should not be for anything else except a replacement for blanks.

But then again, I would never write code in anything except English.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号