directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Re: Checkstyle questions: inline conditionals, protected fields, Javadoc for private members
Date Mon, 04 Oct 2010 18:22:39 GMT
Thanks all for the feedback.

I already tweaked the checkstyle config, so protected fields are
allowed and no Javadoc is required for private fields.

I'll go through the inline conditionals and try to eliminate them.

Kind Regards,
Stefan


On Mon, Oct 4, 2010 at 10:11 AM, Stefan Seelmann <seelmann@apache.org> wrote:
> Hi dev,
>
> we are trying to fix remaining checkstyle errors in shared [1] and
> have some questions:
>
>
> 1. Inline Conditionals
> We have 151 inline conditionals, should we get rid of them or should
> we allow them?
>
> IMO 'simple' inline conditionals are ok:
>  return oid == null ? "" : oid;
>
> Such constructs could be simplified
>  return ( ( byteArray[index] == car ) ? true : false );
> to
>  return byteArray[index] == car;
>
> However nested inline conditionals are hard to read and should be avoided:
>  return ( val < 0 ? -1 : ( val > 0 ? 1 : val ) );
>
> So what is our policy regarding inline conditionals? With checkstyle
> we can't configure that simple inline conditionals are allowed but
> more complex ones are not allowed. My opinion here is to find and
> eliminate the complex ones and then to allow inline conditionals.
>
>
> 2. Protected Fields
> We have 135 fields with 'protected' modifier. Checkstyle complains
> that instead the modifier should be private accessor methods should be
> used. The rationale is to enforce encapsulation. Should we configure
> checkstyle to allow protected and/or package modifiers?
>
>
> 3. Javadoc for Private Members
> Checkstyle complains about missing Javadoc of private fields. I think
> we should relax that rule and don't force Javadoc for private fields
> because IMO the variable name should be descriptive. Thoughts?
>
>
> Kind Regards,
> Stefan
>
>
> [1] https://hudson.apache.org/hudson/view/Directory/job/dir-shared-metrics/
>

Mime
View raw message