From: Benjamin F. <ben...@he...> - 2013-04-11 19:35:26
|
Am Dienstag, 9. April 2013, 18:27:31 schrieb Michael Davidsaver: > On 04/09/2013 09:43 AM, Marty Kraimer wrote: > > On 04/08/2013 05:08 PM, Michael Davidsaver wrote: > >> For some time I have wanted to replace this ugly code anyway, > > > > I would have used a better choice of words or just left this sentence > > out of the message. > > I am not trying to offend. I myself have written ugly code which I, and > others, would like to replace. I think it is just a fact of life for a > developer that our first iterations (or the second or ...) aren't always > so nice. We have to work in the real world, with time constraints, and > utility code tends to suffer. > > I have found this to be an special problem with value type conversion > code. In Base we have conversion code in several places (ca, db, and > gdd). None of it has proper unit testing* and this makes it difficult > to work on. I've actually had this fact used as an argument against my > making changes to it. I do *not* want to see this happen again. > > * Proper unit test code for value conversion needs to compare the result > of a known input with an expected output, and to comprehensibly cover > the known corner cases. I agree with all the above, however with this > This also serves as a definition of "correct" > which can be applied to other implementations. I beg to differ. For a definition of "correct" conversion to be useful it must be based on mathematical properties. To give an example, I'd expect a roundtrip property convertBtoA(convertAtoB(a)) == a to hold for *all* a that can be faithfully represented as values of type B. (If A is a floating point type, the "==" above should of course mean "suitably near" i.e. taking possible rounding errors into account.) "Testing can only prove the presence of errors, not their absence." (E. W. Dijkstra, cited from memory) Cheers -- Ben Franksen () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments ________________________________ Helmholtz-Zentrum Berlin für Materialien und Energie GmbH Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V. Aufsichtsrat: Vorsitzender Prof. Dr. Dr. h.c. mult. Joachim Treusch, stv. Vorsitzende Dr. Beatrix Vierkorn-Rudolph Geschäftsführung: Prof. Dr. Anke Rita Kaysser-Pyzalla, Thomas Frederking Sitz Berlin, AG Charlottenburg, 89 HRB 5583 Postadresse: Hahn-Meitner-Platz 1 D-14109 Berlin http://www.helmholtz-berlin.de |