分享

Naming conventions for Java

 昵称1408237 2010-07-19

Use terminology applicable to the domain

If your users refer to their clients as customers, then use the term Customer for the class, not Client. Many developers make the mistake of creating generic terms for concepts when perfectly good terms already exist in the industry or domain.


Use abbreviations sparingly and intelligently

This means you should maintain a list of standard short forms (abbreviations), you should choose them wisely, and you should use them consistently. For example, if you want to use a short form for the word number, then choose one of nbrno, or num, document the one you choose (it doesn't really matter which one), and use only that one.


Avoid long names (15 characters max is a good idea)

Although the class name PhysicalOrVirtualProductOrService might seem to be a good class name at the time (OK, I'm stretching it on this example), this name is simply too long and you should consider renaming it to something shorter -- perhaps something like Offering.


Avoid names that are too similar or that differ only in case

The variable names persistentObject and persistentObjects should not be used together, nor should anSqlDatabaseand anSQLDatabase.


Capitalize the first letter of standard acronyms

Names will often contain standard abbreviations, such as SQL for Standard Query Language. Names such as sqlDatabase for an attribute or SqlDatabase for a class are easier to read than sQLDatabase and SQLDatabase.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多