Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Bug #271235 - Refactoring of Precision Geometry API

Hi all,

I have been recently working on a refactoring of the precision geometry API in order to deal with its current inconsistencies (see bug #271235 for details). 

I my eyes the current API comprises the combination of two major design flaws:
(1) access to both, the non-precise integer as well as the precise double fields is allowed, and
(2) update of field values is not performed automatically but only via explicit calls of updateInts()

That is, if a client changes the value of a public non-precision field on a precision object the current implementation will not take it into account and will thus use the old precise field values for succeeding computations (this may easily happen if a client works with a precision object while not being aware about this, e.g. because it gets passed over as an actual parameter of method). Furthermore, if a client does not call updateInts() the values of the non-precision fields is not updated accordingly, and he may use outdated values for succeeding computations.

In the end, the major underlying problem seems to be that the current API does indeed not obey Liskov's substitution principle (i.e. the precision subclasses may not fully substitute their non-precise superclasses in all contexts).

While public access to the non-precise fields seems to be wishful to preserve (because of performance issues and because of consistency with SWT API) I think the best solution to overcome this is to 
(a) prevent access to the public precision fields in the precision subclasses, 
(b) ensure the non-precision fields are always automatically updated if precise calculations are performed (which implies all methods are correctly overwritten in the precision subclasses, see bug #142628 for details), 
(c) guarantee that if a client changes the value of a non-precision field directly via field access, the value of the precision field gets updated accordingly as well. 

I have uploaded a patch to bug #271235 that implements exactly this (while also addressing the current inconsistencies that are subsumed by bug #142628). As it is a somehow fundamental change (while the patch actually isn't so great at all) I want to give you the opportunity to review and comment on my changes before I actually commit them to the cvs. So please go ahead.

Best Regards
Alexander

--  
Dr. Alexander Nyßen
Dipl.-Inform.
Software-Engineer

Telefon: +49 (0) 231 / 98 60-210
Telefax: +49 (0) 231 / 98 60-211
Mobil: +49 (0) 151 /  17396743

http://www.itemis.de 
alexander.nyssen@xxxxxxxxx 

itemis AG
Am Brambusch 15-24
44536 Lünen

Rechtlicher Hinweis:

Amtsgericht Dortmund, HRB 20621

Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr. Georg Pietrek, Jens Trompeter, Sebastian Neus

Aufsichtsrat: Dr. Burkhard Igel (Vors.), Stephan Grollmann, Michael Neuhaus



Back to the top