Search This Site
Feb 04 2012 16:42 UTC | ||||||||||
Tutorials
Quick LinksQuestions
Got a question for us? Quality
Payment MethodsBookmarks |
Ricebridge Coding StandardsCoding standards are an essential part of developing high quality software. They create a consistent and reliable base for testing, evolving and evaluating all the code that goes into our components. We haven't just thrown together a few methods and classes that seem to work. We pay attention to the details, so that everything comes together to make our components rock solid. We are making our coding standards publicly available because we want to demonstrate that we take the quality of our work seriously. We stand by what we do and we want you to know that when you use our components, you can be sure that we have nit-picked every detail. By the way, we do not use Hungarian Notation, which we think is a bit silly and over-the-top. Rather, we use a practical set of prefixes, that show meaning, not type (that's what compilers are for!). This means that you can tell instantly, just by looking, what will happen when you use a variable. Our conventions are designed as additions and modifications to the standard Java conventions, which we use as the default standard. Coding Standards1. Choice of Name 2. Instance Variables private String iFoo = "bar";We use the prefix i to indicate an instance variable.
3. Static Variables private static String[] sFoo = new String[] {"bar"};
We use the prefix s to indicate a static variable.
4. Parameters public void method( String pParam ) {}
This one helps you spot those nasty argument modification bugs
(Did I say argument, shucks I meant parameter, no wait, argument, erm... let's just use p to
save confusion).
4. Local Variables int foo = 101;Start in lowercase, and avoid underscores if possible. StudlyCaps are not always
required if the name is relatively short.
5. Iteration Variables for( int rowI = 0; rowI < rows.length; rowI++ )Yeah, it's a suffix. The idea is that the traditional i,j,k are best left
for mathematics papers, which are meant to be impenetrable.
When you code, you code to be understood. So even simple iteration
variables should tell you what they are iterating.
This convention also applies to Iterators.
6. Always Use Brackets if( true ) { doThis(); }
Sorry, but there will come a time when a single line needs to be expanded, and then you will forget to put in the brackets
and waste half a day bug-hunting. No thanks. Anyway, if you always put in the brackets, everybody else knows what you meant.
(If you want to call them parentheses, you can, but bracket is easier to spell).
7. Indent! Indent! Indent! 8. Bracket Wars
if( true ) {
doThis();
}
else {
doThat();
}
We think this style highlights the logic of the code and keeps things nicely aligned. 9. Alignment private String iFirst = "bar"; private int iSecond = 202; 10. Separation 11. Comments 12. Use Common Sense So there you go, that's how we do things. If you have any views on our coding conventions, particularly strongly-held dogmatic ones, we'd love to hear them! | |||||||||
|
comment on this page
Home |
Search |
About Us |
Contact Us |
Our Products |
Documentation |
Resources |
Login
Copyright © 2004-2012 Ricebridge. All Rights Reserved. | ||||||||||