Difference between revisions of "Coding guideline"

From SIMA wiki
Jump to: navigation, search
(Created page with "====== Coding guidlines ====== ===== General Conventions ===== * Comment your code (documentation_guidelines) * One File - One Class * Don't add packages with a w...")
 
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
   * 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
   * <del>Produce efficient code</del>
+
   * Produce efficient code
 
   * (in this order - first readability, then efficiency)
 
   * (in this order - first readability, then efficiency)
  
Line 14: Line 14:
 
camel case + (reduced) hungarian notation = ARS coding guidline
 
camel case + (reduced) hungarian notation = ARS coding guidline
  
example camel case: clsHeimoZeilinger (new word --> capital letter)\\
+
*example camel case: clsHeimoZeilinger (new word --> capital letter)\\
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|Hungarian notation - Wikipedia]]//
+
*[[http://en.wikipedia.org/wiki/Hungarian_notation|Hungarian notation - Wikipedia]]
  
 
Basics in (reduced) hungarian notation:
 
Basics in (reduced) hungarian notation:
  
 
1st letter:
 
1st letter:
<code>
+
 
      m ... member
+
*m ... member
      p ... method parameter
+
*p ... method parameter
      i ... interface parameter
+
*i ... interface parameter
      s ... static variable
+
*s ... static variable
  blank ... function scope
+
*blank ... function scope
        ... to be continued
+
 
</code>
+
 
 
2nd letter:
 
2nd letter:
<code>
+
 
b ... boolean
+
*b ... boolean
e ... enum
+
*e ... enum
n ... number (integer, long)
+
*n ... number (integer, long)
r ... real (floating point, double)
+
*r ... real (floating point, double)
o ... object (also string)
+
*o ... object (also string)
g ... generic
+
*g ... generic
  ... to be continued
+
 
</code>
+
 
  
  
 
===== File notation (java/eclipse) =====
 
===== File notation (java/eclipse) =====
<code>
 
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
 
</code>
 
 
  
{{tag>code guidelines Java Eclipse}}
+
*clsXYZ          ... Classe Files
{{backlinks>.}}
+
*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

Latest revision as of 17:01, 2 January 2013

Coding guidlines
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)
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)\\
  • [notation - Wikipedia]

Basics in (reduced) hungarian notation:

1st letter:

  • m ... member
  • p ... method parameter
  • i ... interface parameter
  • s ... static variable
  • blank ... function scope


2nd letter:

  • b ... boolean
  • e ... enum
  • n ... number (integer, long)
  • r ... real (floating point, double)
  • o ... object (also string)
  • g ... generic



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