This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Gtk constants in Java


Per Bothner <per@bothner.com> writes:

Per Bothner <per@bothner.com> writes:

> First, there is an impedance mismatch:  

Ok, got this point.

> Perhaps.  But Java does not not have have enum types.  Instead, Java
> uses final static int.  It is *less* readable if we try to simulate
> enum types using enum objects, since that is not a standard Java idiom.

Ehm, "Java programmers coming from C use static int", like myself :->; 
enum objects *are* a standard java idion by the way, i learned it in 
Sun documentation ... and anyway the code using them is exactly the same
as the code using int (if you haven't set, of courses).

> This is *really* bad.  Consider checking to see if GtkOption.GREY is
> a member of opts.  This now requires a loop - and a loop that indexes
> through an array.  This is very slow.  Allocating an array is also very slow.

There is nothing bad in absolute; is this check done one time during
the application initialization, or during the refresh of a graphic
screen happening during a mouse drag ?

What i mean, is that any tradeoff between performance, readability and
type safeness should be done within a defined context; performance is
not an absolute value; i am *not* saying that arrays or Collection Sets (hash
table are faster than lopps in arrays) are fast enough, just saying that
the question "fast enough for what" should be added to the discussion.

Also, bitmaps of options are an idiom coming from C; there may be
better OO solutions, like representing the option set by a dedicated 
object (ScreenConfiguration, in my example).

Sure, a Gtk/C programmer would prefer to see the same API style;
but a Java programmer would prefer a more Java API (don't know
which audience you are thinking about).

Maurizio

-- 
Maurizio De Cecco
MandrakeSoft 		http://www.mandrakesoft.com/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]