Re: Adding enums?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Sep 23 2009 - 10:34:08 EDT

  • Next message: Michael Gentry: "Re: Adding enums?"

    +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:34:58 EDT