Re: Cleaning up the code [Was: Re: Cayenne/Windows developer help]

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Mar 03 2006 - 02:18:07 EST

  • Next message: Tore Halset: "Re: ant default target ..."

    I think arguing about formatting and code style is opening a huge can
    of worms. I think Eclipse formatting preferences strike a nice
    balance, although even that can be contentious and lead to a lengthy
    discussion of wether a "\n" is needed before "{" or not ;-)

    For instance I'd code Kevin's example like this:

       return (whatever) ? something : anotherthing;

    But this doesn't mean that we need to follow one or the other style
    religiously. I don't care, as long as the code works. I am neutral in
    regards to the checkstyle addition to the build script. I am just
    afraid that we'll get bogged down in the discussion of what the right
    style is and never accomplish anything of value.

    Andrus

    On Mar 2, 2006, at 10:16 PM, Cris Daniluk wrote:

    > Apache has some style guides, I think.... I recall not liking them
    > much, though :)
    >
    > Are we bound to them? Obviously this is low priority stuff, but now
    > that we have a lot more people actively participating, it does make
    > sense to at least have going forward standards, kinda like what I'm
    > working on for docs.
    >
    > On 3/2/06, Kevin Menard <kmenar..ervprise.com> wrote:
    >> I guess that would require us to standardize a coding style. I
    >> know we
    >> have the eclipse prefs, but I think Checkstyle gives you a lot more
    >> control.
    >>
    >> So, while I'm not ready to write all of these out, I was wondering
    >> what
    >> the concensus on something like the following is:
    >>
    >> public Thing blah()
    >> {
    >> if (whatever)
    >> {
    >> return something;
    >> }
    >> else
    >> {
    >> return anotherthing;
    >> }
    >> }
    >>
    >> I personally feel the else should be removed. But, that's because I
    >> normally get fooled by such things. In my mind, it's easier to
    >> consider
    >> whatever to be a special case and thus it goes in the if() while
    >> the else
    >> body is the regular case (and there's no need to assert it). I'm
    >> asking
    >> because there's a lot of cases similar to this in the code. If
    >> others
    >> agree with me, I'll go through and clean it up. Otherwise, I can
    >> cope
    >> with the existing style.
    >>
    >> --
    >> Kevin
    >>
    >>
    >> On Thu, 02 Mar 2006 12:45:10 -0500, Cris Daniluk
    >> <cris.danilu..mail.com>
    >> wrote:
    >>
    >>> One thing that may be helpful is to setup PMD and Checkstyle... both
    >>> require extensive configuration to eliminate annoying false
    >>> positives,
    >>> but when tuned, they usually present helpful information.
    >>> Obviously no
    >>> tool is perfect, but for us, about 25% of the reported PMD issues
    >>> deserved attention, and 75% of the checkstyle issues did.
    >>>
    >>> Maybe Findbugs would be a better choice than PMD... either way, I've
    >>> used PMD more for analytics, and checkstyle more for pure
    >>> style/formatting myself.
    >>>
    >>> Ideas?
    >>>
    >>> Cris
    >>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Fri Mar 03 2006 - 02:18:09 EST