[Pki-devel] Automatic reformatting and code style

Endi Sukma Dewata edewata at redhat.com
Wed Nov 23 21:05:51 UTC 2011


On 11/23/2011 1:57 PM, Ade Lee wrote:
> 1. Placement of braces

I'd say we should go with Sun's style, it's more common and would be 
consistent with the rest of the code (e.g. if/while/switch/try):

>     public class MyClass {
>         ...
>     }

> 2. We require that interface names begin with "I".  Sun says nothing
> about this.  This is probably a good one to keep.

Yes.

> 3. We specify "no tabs".  Sun says tabs are optional.  We should keep
> this.

Yes.

> 4. We say "Static methods should begin with a capital letter with each
> subsequent new word in uppercase, and subsequent letters in each word in
> lower case.  Sun has no special treatment for static methods - ie. they
> are treated just like other methods .. ie. beginning with a lower-case
> letter.

Yes, I don't think it needs any special treatment. Most IDE will show it 
italicized.

> 5. We do have some guidelines for naming functions that go beyond what
> Sun specifies - and also perhaps, beyond what eclipse can verify.
>
> For example:
> *   Get and set methods should begin with "get" / "set" and return the
> appropriate object type.

OK.

> *   Boolean get methods should use "is" or "can" as a prefix, such as
> "isUndoable()" rather than "getUndoable()".

There are probably some other words too, e.g. 'has'.

> * Factory class names should include the word "Factory". Factory method
> names should start with the word "Make."

Would 'create' be better? 'make' doesn't always mean creating a new object.

> * Methods for debug-only implementations should begin with "debug".

OK.

> * Member variables should begin with "m". For example, mMemberVariable.

I'd prefer not to use any prefix because sometimes we want to expose an 
attribute publicly, in that case it would be better to use less cryptic 
names. Most IDE will color it differently too.

-- 
Endi S. Dewata




More information about the Pki-devel mailing list