Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: TDD can be useful even when it doesn't achieve what you want Date: Thu, 18 Feb 2016 21:28:06 +1300 Lines: 54 Message-ID: References: <56c34b5c$0$18569$e4fe514c@newszilla.xs4all.nl> <56c4b474$0$4233$e4fe514c@newszilla.xs4all.nl> <56c4ef61$0$4197$e4fe514c@newszilla.xs4all.nl> <56c573ab$0$4031$e4fe514c@newszilla.xs4all.nl> <56c5798b$0$4048$e4fe514c@newszilla.xs4all.nl> <56c57f1e$0$4042$e4fe514c@newszilla.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net d+ogkhs0hZlig2SjcXpyEQNYlr0vzRIICHmRmyrse06zYBHhAW Cancel-Lock: sha1:ZRcrNSltxHDTN45Y8b0a7SOjTT4= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <56c57f1e$0$4042$e4fe514c@newszilla.xs4all.nl> Xref: csiph.com comp.lang.c++:41026 Wouter van Ooijen wrote: > Op 18-Feb-16 om 9:17 AM schreef Ian Collins: >> Wouter van Ooijen wrote: >>> Op 18-Feb-16 om 8:42 AM schreef Ian Collins: >>>> Wouter van Ooijen wrote: >>>>> Op 17-Feb-16 om 11:19 PM schreef Ian Collins: >>>>>> >>>>>> Let me ask you why you wouldn't obey the rules for say a device >>>>>> driver? >>>>>> I certainly do and for such low level fiddly code I find TDD to >>>>>> be an >>>>>> ideal tool. I like to step through, almost bit by bit, tasks such as >>>>>> setting up device registers. The steps, both conceptually and in >>>>>> code, >>>>>> are small and ideally suited to an incremental test/code/refactor >>>>>> cycle >>>>>> such as TDD. Being close to a pure coding exercise, any objections to >>>>>> TDD and design are irrelevant at this level. >>>>> >>>>> Let's say I write code for a UART to transmit data at a (run-time) >>>>> specified baudrate. What would your (first) test be? >>>> >>>> It wouldn't be the first test (there would be more generic configuration >>>> to test first), >>> >>> such as? >> >> That depends on the device, if the UART is stand alone, there might not >> be any but if it is part of a processor, there will probably >> configuration registers that have to be setup before the UART can be used. >> >>>> but the last test for the requirement would be that the >>>> drive sits the correct bits in the the appropriate configuration >>>> register(s). >>> >>> But how do you determine what is the correct setting (or: how do you >>> make sure that the settings you have determined have the desired effect)? >> >> The device specification! > > Of course, but how do you verify that you derived the correct (and > complete) conclusions from the device specification? In my experience > *that* is where the errors can be made! (I often make errors - or rather > omissions - in that aspect. I don't recall ever making an error afer > that: once the correct values are determined writing them is trivial.) By sanity checking against real hardware. We had some test code from a spike build that validated our understanding of the real hardware. Oh and did I mention pair programming? That's be best way of avoiding those silly errors! -- Ian Collins