Re: Adding enums?

From: Michael Gentry (mgentr..asslight.net)
Date: Wed Sep 23 2009 - 10:44:01 EDT

  • Next message: Andrus Adamchik: "Re: Adding enums?"

    BTW, I'm a little iffy on the static import stuff. It seems less
    explicit and somewhat cheating to me, but I'm just tossing the idea
    out for feedback.

    On Wed, Sep 23, 2009 at 10:40 AM, Michael Gentry <mgentr..asslight.net> wrote:
    > If wanting to keep things shorter, couldn't you do a static import?
    > I'm a little rusty on the syntax, but wouldn't it be something like:
    >
    > import static ...query.QueryDirection.*;
    >
    > Ordering ordering = new Ordering("artistName", ASCENDING);
    >
    > Hmm, or maybe that only works for static constants and not enums.  I'd
    > have to test that.
    >
    > mrg
    >
    >
    > On Wed, Sep 23, 2009 at 10:34 AM, Andrus Adamchik
    > <andru..bjectstyle.org> wrote:
    >> +1
    >>
    >> If we can do clean gradual deprecation of the old API. Also I like us using
    >> ASCENDING instead of ASC, as you proposed, but wonder if we can call
    >> OrderingDirection something shorter, just to keep things tight.
    >>
    >> Another candidate for such refactoring is PersistenceState. Maybe create a
    >> "State" enum or "PersistentState"?
    >>
    >> Andrus
    >>
    >> On Sep 23, 2009, at 5:24 PM, Michael Gentry wrote:
    >>
    >>> Should we add more enums to the code?  For example, in Ordering.java,
    >>> there are these constants:
    >>>
    >>> public static final boolean ASC = true;
    >>> public static final boolean DESC = false;
    >>>
    >>> However, there is no enum to represent the options.  The constructors look
    >>> like:
    >>>
    >>> public Ordering(String sortPathSpec, boolean ascending) ...
    >>>
    >>> There is nothing to encourage/enforce the usage of the constants, so
    >>> you tend to see "true" and "false" being used.  Even in our
    >>> documentation:
    >>>
    >>> http://cayenne.apache.org/doc/using-orderings.html
    >>>
    >>> query.addOrdering("artistName", true);
    >>> Ordering ordering = new Ordering("artistName", true);
    >>>
    >>> To the new (or even experienced) user, seeing "true" there tends to
    >>> have no meaning.  I (and some of the people I've been showing Cayenne
    >>> to here) would rather see something like:
    >>>
    >>> Ordering ordering = new Ordering("artistName",
    >>> OrderingDirection.ASCENDING);
    >>>
    >>> One guy even suggested something like:
    >>>
    >>> Ordering ordering = new AscendingOrdering("artistName");
    >>>
    >>> That is more concise and still explicit, but would obviously require
    >>> even more code changes (probably).  Especially when adding the case
    >>> insensitive stuff.
    >>>
    >>> Thoughts?
    >>>
    >>> Thanks!
    >>>
    >>> mrg
    >>>
    >>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Wed Sep 23 2009 - 10:44:33 EDT