Naming conventions for Java

来源:百度文库 编辑:神马文学网 时间:2024/04/28 05:59:39
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.
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 nbr, no, or num, document the one you choose (it doesn't really matter which one), and use only that one.
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.
The variable names persistentObject and persistentObjects should not be used together, nor should anSqlDatabaseand anSQLDatabase.
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.