Re: [OJB-developers] various questions
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2002-04-30 05:07:35
|
Hi Chris, hi all, Chris Greenlee wrote: > > Sure. :) I'll just throw out the ones I'm most familiar with to get things > started. > I like you proposal, because it fits on one single page! This is crucial to make people use it ! > 1. Non-static member variables. > > a. References prefixed with "this.". OK! > b. First letter lowercase, beginnings of subsequent words capitalized. > > private int Anint = 0; > > public void increment() { > Anint++; > } > > would become > > private int anInt = 0; > > public void increment() { > this.anInt++; > } OK! > 2. Static member variables. > > a. All uppercase. OK! > b. Underscores ("_") used to separate words. > > So > > private static int aStaticInt = 50; > > would become > > private static int A_STATIC_INT = 50; > OK! Should we have special rules to mark "final" variables? > 3. Method names (static and non-static). > > a. First letter lowercase, beginnings of subsequent words capitalized. > > So > > public static int GetInt() { > return 5; > } > > would become > > public static int getInt() { > return 5; > } > OK! > 4. Braces around blocks of code. > > a. Opening brace on the end of the line starting the block. > b. Closing braces aligned with the beginning of the line starting the > block. > > So > > if (true) > { > doThis(); > } > > would become > > if (true) { > doThis(); > } > I would prefer to use the following bracket style: if (true) { doThis(); } This bracket style allows to identify opening and closing brackets much faster. (At least for me as a former LISP programmer). > 5. Method / member organization. > > a. Member variables declared before methods. OK > b. Static members declared before non-static members. OK > c. Static method declared before non-static methods. OK > d. Private members declared before protected members. OK > e. Protected members declared before protected members. OK > f. Public members declared after all others. OK, But should we allow public members at all? > g. Same precedence for methods. OK > > 6. Test class naming. > > a. All JUnit test classes should be named "xxxTest". > OK > So > > public class TestOfClassA extends TestCase { > } > > would become > > public class ClassATest extends TestCase { > } > > And that's what I can think of off the top of my head. Have at it. :) > This is really a nice and handy list. Of course there could be lot of more rules (e.g. naming conventions for parameters and local variables). But I like the fact that you reduced it to the minimum! After some more discussion we should publish in html format so that all developers may use it.! Thanks, Thomas > Cheers, > > Chris > > > > > > > > > > |