geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geronimo-...@incubator.apache.org
Subject [Apache Geronimo Wiki] Updated: CodingStandards
Date Wed, 28 Apr 2004 15:50:48 GMT
   Date: 2004-04-28T08:50:48
   Editor: 208.42.65.236 <>
   Wiki: Apache Geronimo Wiki
   Page: CodingStandards
   URL: http://wiki.apache.org/geronimo/CodingStandards

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -16,49 +16,69 @@
 
  * 4 characters indentation
  * '''No tabs''' please!
- * '''No K & R style blocks''' such as:
-(This English is confusing. Does this mean that "the following example is K&R and is
not the way to do it"? Does it mean "do not use K&R but instead do the following"?)
 
-Perhaps wordsmith this to:
 Correct brace style:
 {{{#!java
-public void foo() {
-}
-}}}
-Deprecated Visual Basic begin-end style - do not use:
-{{{#!java
-public void foo()
-{
-}
-}}}
+public class Foo {
+    public void foo(boolean a, int x, int y, int z) {
+        do {
+            try {
+                if (x > 0) {
+                    int someVariable = a ?  x : y;
+                } else if (x < 0) {
+                    int someVariable = (y + z);
+                    someVariable = x = x + y;
+                } else {
+                    for (int i = 0; i < 5; i++) {
+                        doSomething(i);
+                    }
+                }
+
+                switch (a) {
+                    case 0:
+                        doCase0();
+                        break;
+                    default:
+                        doDefault();
+                }
+            } catch (Exception e) {
+                processException(e.getMessage(), x + y, z, a);
+            } finally {
+                processFinally();
+            }
+        } while (true);
 
-Here is the original example
-{{{#!java
-public void foo() 
-{
-    if (whatever) 
-    {
-        // ...
-    } 
-    else if (whateverElse) 
-    {
-        // ...
-    } 
-    else 
-    {
-        // ...
-    }
-}
-}}}
+        if (2 < 3) {
+            return;
+        }
+
+        if (3 < 4) {
+            return;
+        }
 
+        do {
+            x++
+        } while (x < 10000);
 
-To be honest I think that a cross platform open sourced tool like Jalopy should be used.
It has ANT tasks and plugins for many IDEs (Eclipse, WSAD, JBuilder etc). You can configure
the preferences and save them as an XML file. Perhaps posting a preferences file for everyone
to use would be better than this page of fiats? I'll do this if we agree this would be the
way to go. -- Gene De Lisa
+        while (x < 50000) {
+            x++;
+        }
 
-(Excellent idea, please do that! -Erik)
+        for (int i = 0; i < 5; i++) {
+            System.out.println(i);
+        }
+    }
+
+    private class InnerClass implements I1, I2 {
+        public void bar() throws E1, E2 {
+        }
+    }
+}
+}}}
 
 == XML ==
 
- * Suggested using 4 characters (was use 2 characters indentation) to allow IDEs such as
Eclipse to use a unified formatting convention
+ * Use 4 characters.  This is to allow IDEs such as Eclipse to use a unified formatting convention
  * '''No tabs''' please!
 
 = Interfaces =
@@ -77,7 +97,7 @@
 
 This has the added advantage that the interface can be converted into an abstract class (and
copy and paste individual definitions) without changing anything.
 
-Preferably add public/static/final to constants, and public/abstract to methods, but it's
not mandatory. However, if it's there, don't take it out :-)
+Preferably add public/static/final to constants, and public/abstract to methods, but it's
not mandatory. However, if it's there, don't take it out.
 
 = Exceptions =
 
@@ -119,16 +139,17 @@
 == IDE Auto-Formatting ==
 
  * Eclipse users can 
-  * use `Source -> Organise Imports` to organize imports
-  * use `Source -> Format` to format code (please use default Eclipse formatting conventions,
which are as above)
+ * use `Source -> Organise Imports` to organize imports
+ * use `Source -> Format` to format code (please use default Eclipse formatting conventions,
which are as above)
  * IntelliJ users can 
-  * use `Tools -> Organise Imports` to organize imports
-  * use `Tools -> Reformat code` to format code (uses the code style setting in IDE options)
+ * use `Tools -> Organise Imports` to organize imports
+ * use `Tools -> Reformat code` to format code (uses the code style setting in IDE options)
 
 = JavaDoc Tags =
 
- @version:: Should be: `@version $Revision$ $Date$`
- @author:: Should not be used in source code at all.
+ @version  Should be: `@version $Revision$ $Date$`
+
+ @author  Should not be used in source code at all.
 
 = Unit Test Cases =
 
@@ -179,10 +200,9 @@
 }
 }}}
 
-= Abbreviations in methods/classes/interfaces' names =
+= Abbreviations and Acronym in methods/classes/interfaces' names =
 
 Abbreviations are all written in capitals in methods/classes/interfaces' names.
-("Acronym" might be a better term here.)
 
 {{{#!java
 public final class J2EELoader {
@@ -193,4 +213,3 @@
 
 }
 }}}
-

Mime
View raw message