Difference between revisions of "Coding guidelines"
| (4 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
== General Conventions ==  | == General Conventions ==  | ||
| − | #Comment your code ([[  | + | #Comment your code ([[Documentation guidelines]])  | 
#One File - One Class  | #One File - One Class  | ||
#Don't add packages with a wildcard (e.g. java.lang.* - instead always type the whole package name java.lang.Integer)  | #Don't add packages with a wildcard (e.g. java.lang.* - instead always type the whole package name java.lang.Integer)  | ||
# Produce readable code  | # Produce readable code  | ||
# Produce efficient code (in this order - first readability, then efficiency)  | # Produce efficient code (in this order - first readability, then efficiency)  | ||
| + | |||
| + | To ease development while following the rules a checkstyle file can be used. [[Checkstyle_Eclipse|Download and configuration with Eclipse]]  | ||
== Naming Conventions ==  | == Naming Conventions ==  | ||
| Line 14: | Line 16: | ||
example hungarian:  mnCountOfHeimos (m for member, n typeof integer)  | example hungarian:  mnCountOfHeimos (m for member, n typeof integer)  | ||
| − | Origin: [http://en.wikipedia.org/wiki/Hungarian_notation  | + | Origin: [http://en.wikipedia.org/wiki/Hungarian_notation  Hungarian notation - Wikipedia]  | 
| Line 38: | Line 40: | ||
  g ... generic  |   g ... generic  | ||
   ... to be continued  |    ... to be continued  | ||
| − | |||
== File notation (java/eclipse) ==  | == File notation (java/eclipse) ==  | ||
Latest revision as of 14:58, 17 February 2013
General Conventions
- Comment your code (Documentation guidelines)
 - One File - One Class
 - Don't add packages with a wildcard (e.g. java.lang.* - instead always type the whole package name java.lang.Integer)
 - Produce readable code
 - Produce efficient code (in this order - first readability, then efficiency)
 
To ease development while following the rules a checkstyle file can be used. Download and configuration with Eclipse
Naming Conventions
camel case + (reduced) hungarian notation = ARS coding guidline
example camel case: clsHeimoZeilinger (new word –> capital letter)
example hungarian: mnCountOfHeimos (m for member, n typeof integer)
Origin: Hungarian notation - Wikipedia
Basics in (reduced) hungarian notation:
1st letter:
     m ... member
     p ... method parameter
     i ... interface parameter
     s ... static variable
 blank ... function scope
       ... to be continued
2nd letter:
b ... boolean e ... enum n ... number (integer, long) r ... real (floating point, double) o ... object (also string) g ... generic ... to be continued
File notation (java/eclipse)
clsXYZ ... Classe Files XYZ ... Class Files that contain the method //public static main(String args[])// and that are meant to be used to start the application itfXYZ ... Java Interface tstXYZ ... junit Test Cases tssXYZ ... junit Test Suites