Adding enums?

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

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

    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:25:28 EDT