...
In general, we are following the recommendations in the book: The Elements of Java Style. Please be familiar with the conventions in that book, as it will result in less reformatting of code later. (Such reformatting makes it harder to detect actual coding changes.)
Configure your Integrated Development Environment to assist you in following the style guidelines: Coding Standards - IDE Settings
Class Structure
For the most part, classes should be laid out in the following order:
LOG
fields
constructors
overridden methods (public)
protected/private methods
getters and setters with logic
- getters/setters with no logic
Use of Braces
In almost all cases, braces should be used when creating blocks. It is too easy to introduce bugs into the system by omitting braces for single-line clauses, especially if-then-else setups. (This is one of those cases where indentation comes into play, if lines after the first are also indented, a developer reading the code might assume that those lines are part of the else clause.
...
Entity | Naming Conventions | Good Examples | Incorrect Examples |
---|---|---|---|
package |
| org.apache.log4j.logger | org.kuali.YearEnd |
class |
| LedgerPendingEntry | BalanceTyp |
interface |
| TransactionPoster | PostTransaction |
enum |
| Weekday | |
enum values |
| MONDAY | |
method |
| save() | |
variable |
| documentTypeCode | findTypeCode |
constant |
| FISCAL_YEAR | FROM |
...
Examples of Constant Classes:
Constant Type | Global KFS Class | Module-Specific class example | Description/Usage | |
---|---|---|---|---|
Constants | org.kuali.kfs.sys.KFSConstants | org.kuali.kfs.module.purap.PurapConstants | Used to define general constants (don't fit in one of the categories below) for the system or module. | |
KeyConstants | org.kuali.kfs.sys.KFSKeyConstants | org.kuali.kfs.module.purap.PurapKeyConstants | Holds error key constants that are global or module-specific. | |
PropertyConstants | org.kuali.kfs.sys.KFSPropertyConstants | org.kuali.kfs.module.purap.PurapPropertyConstants | Holds property name constants that are global or module-specific. | |
ParameterConstants | org.kuali.kfs.sys.KFSParameterKeyConstants | org.kuali.kfs.module.purap.PurapParameterConstants | Has names of parameters associated globally or with a module (inner classes can be used to organize those parameters which don’t fit with the big four components of All, Batch, Document, and Lookup). | |
WorkflowConstants | org.kuali.kfs.module.purap.PurapWorkflowConstants | Has node names and application document statuses (inner classes can be used here to differentiate between nodes and statuses used on different documents, like what PurapWorkflowConstants does). | ||
AuthorizationConstants | org.kuali.kfs.sys.KfsAuthorizationConstants | org.kuali.kfs.module.purap.PurapAuthorizationConstants | Contains names of edit modes (again, inner classes to separate by document type is fine) and special permission names which need to be called...and in very very rare cases, role names. | |
KimAttributes | org.kuali.kfs.sys.identity.KfsKimAttributes | org.kuali.kfs.module.purap.identity.PurapKimAttributes | Special case that holdes constants for KIM attributes as well as instance variables, setters and getters for those attributes. |
...
Service | Purpose | Sample Methods | ||
---|---|---|---|---|
Standard KNS Services |
|
| ||
BusinessObjectService | General purpose service to retrieve and persist business objects. This service eliminates the need for custom DAOs and services for basic CRUD operations. |
| ||
LookupService | Service for performing more complex lookups of business objects. Criteria maps passed to this service can contain special characters in the lookup values which can perform and/or/between/greater than/less than operations. This also can be used to reduce the need for OJB-specific query code. |
| ||
MailService | Used to send email messages. |
| ||
DateTimeService | Use to obtain the current date/time and parse/format dates between String and Date objects. |
| ||
Data Dictionary Services |
| |||
DataDictionaryService | General purpose service to obtain information about business objects, documents, and their attributes from the data dictionary. These calls are lower level than either of the services below. Only use these calls if you can't get the information from one of the services below. |
| ||
BusinessObjectDictionaryService | Specialization of the above service to help answer more complex, but common, questions needed about business objects, mainly for implementing the KNS framework. | |||
MaintenanceDocumentDictionaryService | Same as the above, but for maintenance documents. |
| ||
Workflow Wrapper Services |
|
| ||
DocumentService | Primary KNS service for interacting with documents. This service should be used whenever possible instead of accessing KEW services. |
| ||
Information Services |
|
| ||
ConfigurationService | Used to pull configuration properties (mostly from configuration.properties). |
| ||
ParameterService | Used to pull parameters from the KRNS_PARM_T table on the Rice server. |
|
...