Please read to the proposed solution at the end:

I am having difficulty understanding the reason behind the
implementation of Rectangle2D.  I am writing algorithms that depend
heavily on the maximum values of the rectangle.  However, the current
JAVA implementation uses the x and y coordinates along with the
width and height of the rectangle.  This presents a floating-point precision
problem for the maximum values because they depend on
two stored numbers instead of one.

Now this seems like a likely story.  And I can imagine a Tech Support ask,
Why?  However, the Rectangle2D object SHOULD
BE an abstraction (like all OO is) to the implementation and should produce
the same result no matter what platform (or implementation) it uses.

Well, I think I can consider myself a purist, and believe that JAVA should
be able to find a way to fix this floating-point precision problem.  I can
imagine that this problem crops up in more than one place in JAVA
(and of course in C++).  Because it is interesting to note that if algorithms
depended heavily on the width and height, and they were stored as maximums
and minimums, it would create the same unexpected behavior.

Solution:
I believe that the problem stems in the interface.  Since the interface allows
you to set one of these specific variables, (whether the min,max,
or difference(w/h)), it should return the same EXACT result if you ask for
it back WITHOUT a precision problem.  However, the computed values might still
have the precision problem, but that is OK because the user did not specify them.
Therefore, in order to implement you could do it in many ways, I
thought of two:
1) Just store both min, max, and length (w/h).  This would be considerably
more overhead in memory (50% more), but would produce the correct results.
2) Dynamic variables that represent which variables the user specifies. This
would only increase some computation time slightly, but a hacker could probably
pull it off quite easily.
or my way (which is definately not the best for OO:
3) B/c I know that I do not depend on width or height, just create a new
object that just represents the min and max variables.
This brings up an interesting fact, maybe a Constructor with Parameters that
choose which implementation?
But #1 and #2 ABSTRACT THE IMPLEMENTATION COMPLETELY, which is what we want.

Please Let me know what anyone thinks about this.  Also, send it to me
([EMAIL PROTECTED]) as well because I am not sure that I am on this mailing
list.

Blaine Bell

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to