Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #40966 > unrolled thread
| Started by | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| First post | 2016-02-15 21:49 +0000 |
| Last post | 2016-02-18 21:30 +0000 |
| Articles | 20 on this page of 75 — 11 participants |
Back to article view | Back to comp.lang.c++
TDD can be useful even when it doesn't achieve what you want Juha Nieminen <nospam@thanks.invalid> - 2016-02-15 21:49 +0000
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-15 21:56 +0000
Re: TDD can be useful even when it doesn't achieve what you want Juha Nieminen <nospam@thanks.invalid> - 2016-02-16 09:09 +0000
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-15 23:59 +0100
Re: TDD can be useful even when it doesn't achieve what you want Juha Nieminen <nospam@thanks.invalid> - 2016-02-16 09:12 +0000
Re: TDD can be useful even when it doesn't achieve what you want Öö Tiib <ootiib@hot.ee> - 2016-02-16 03:08 -0800
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-16 17:16 +0100
Re: TDD can be useful even when it doesn't achieve what you want Juha Nieminen <nospam@thanks.invalid> - 2016-02-17 11:26 +0000
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-17 16:55 +0000
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 08:00 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-17 18:57 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 08:02 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-17 20:11 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 08:23 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-17 20:32 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 08:54 +1300
Re: TDD can be useful even when it doesn't achieve what you want Cholo Lennon <chololennon@hotmail.com> - 2016-02-17 17:19 -0300
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 10:28 +1300
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-17 21:28 +0000
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-17 21:08 +0000
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-17 23:08 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 11:19 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 08:33 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 20:42 +1300
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 20:45 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 08:58 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 23:24 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 08:58 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 21:17 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 09:22 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 21:28 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 09:39 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 23:22 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 11:57 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-19 09:29 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 22:00 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-19 10:10 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 23:15 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-20 11:22 +1300
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-19 22:39 +0000
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-20 00:20 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-20 13:16 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-20 09:07 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-20 21:17 +1300
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-20 09:53 +0100
Re: TDD can be useful even when it doesn't achieve what you want Öö Tiib <ootiib@hot.ee> - 2016-02-20 04:24 -0800
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-20 14:08 +0100
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-21 01:19 +0000
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-21 09:29 +0100
Re: TDD can be useful even when it doesn't achieve what you want Paul Sinnett <paul.sinnett@gmail.com> - 2016-02-21 08:08 -0800
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-22 05:07 +0000
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-22 19:44 +0000
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-23 08:58 +1300
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-22 20:13 +0000
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-23 09:19 +1300
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-22 20:21 +0000
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-22 21:18 +0100
Re: TDD can be useful even when it doesn't achieve what you want Juha Nieminen <nospam@thanks.invalid> - 2016-02-23 09:14 +0000
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-23 22:21 +1300
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-23 17:33 +0000
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-23 19:28 +0100
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-24 08:43 +1300
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-23 20:13 +0000
Re: TDD can be useful even when it doesn't achieve what you want Gareth Owen <gwowen@gmail.com> - 2016-02-23 20:53 +0000
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-24 17:12 +0000
Re: TDD can be useful even when it doesn't achieve what you want Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-24 18:05 +0000
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-24 09:53 +1300
Re: TDD can be useful even when it doesn't achieve what you want Gareth Owen <gwowen@gmail.com> - 2016-02-23 21:09 +0000
Re: TDD can be useful even when it doesn't achieve what you want David Brown <david.brown@hesbynett.no> - 2016-02-23 22:22 +0100
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-21 01:21 +0000
Re: TDD can be useful even when it doesn't achieve what you want Ian Collins <ian-news@hotmail.com> - 2016-02-18 21:24 +1300
Re: TDD can be useful even when it doesn't achieve what you want Vir Campestris <vir.campestris@invalid.invalid> - 2016-02-18 21:27 +0000
Re: TDD can be useful even when it doesn't achieve what you want legalize+jeeves@mail.xmission.com (Richard) - 2016-02-18 17:48 +0000
Re: TDD can be useful even when it doesn't achieve what you want Wouter van Ooijen <wouter@voti.nl> - 2016-02-18 19:04 +0100
Re: TDD can be useful even when it doesn't achieve what you want Vir Campestris <vir.campestris@invalid.invalid> - 2016-02-18 21:30 +0000
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-17 23:08 +0100 |
| Message-ID | <56c4ef61$0$4197$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41006 |
Op 17-Feb-16 om 10:08 PM schreef Richard: > [Please do not mail me a copy of your followup] > > Wouter van Ooijen <wouter@voti.nl> spake the secret code > <56c4b474$0$4233$e4fe514c@newszilla.xs4all.nl> thusly: > >> PS Uncle Bob *does* claim that TTD is *the* tool to apply to every >> programming problem. > > What I've seen him claim is that he hasn't found anything better than > TDD. If you can show him something better than TDD, then he'll be > talking about that. > > If you have something you think is better than TDD, bring it Uncle Bob > and get him to champion it. If you can convince Uncle Bob, I'm very > interested in hearing about it. I'd rather convert the pope to shintoism and the Bush family to atheism than trying to convert Uncle Bob away from his rules. The chance of success seems much higher. The way he is talking he doesn't seem to have much experience in my main field, which is low-level microcontroller embedded real-time programming, so I don't regards his opinion as very relevant to me to begin with, and his dogmatism doesn't make it any better. Still, I think something like TDD can have some use for me in some situations, but 'the three rules' when taken literally are (at least for me) absurd. I like test, I like short code fragments (I don't use classic OO, so I don't mention about classes or methods.) But I also like to think, and write a bunch of test in one go, or a 100+ lines of code in one go. The 'three rules' seem to rule that out (is that a correct interpretation?) so anyone who thinks I should obey them literally to be a professional is, as far as I am concerned, a joke. Of course that doesn't rule out that the method works for some other people. I never did much user interface stuff (I don't think I ever felt the urge to use the MVC pattern, and I haven't touched a database for 30 years) so I am clearly in a different world than most of you :) Wouter van Ooijen
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-18 11:19 +1300 |
| Message-ID | <dik9vpFiat1U7@mid.individual.net> |
| In reply to | #41010 |
Wouter van Ooijen wrote: > Op 17-Feb-16 om 10:08 PM schreef Richard: >> [Please do not mail me a copy of your followup] >> >> Wouter van Ooijen <wouter@voti.nl> spake the secret code >> <56c4b474$0$4233$e4fe514c@newszilla.xs4all.nl> thusly: >> >>> PS Uncle Bob *does* claim that TTD is *the* tool to apply to every >>> programming problem. >> >> What I've seen him claim is that he hasn't found anything better than >> TDD. If you can show him something better than TDD, then he'll be >> talking about that. >> >> If you have something you think is better than TDD, bring it Uncle Bob >> and get him to champion it. If you can convince Uncle Bob, I'm very >> interested in hearing about it. > > I'd rather convert the pope to shintoism and the Bush family to atheism > than trying to convert Uncle Bob away from his rules. The chance of > success seems much higher. > > The way he is talking he doesn't seem to have much experience in my main > field, which is low-level microcontroller embedded real-time > programming, so I don't regards his opinion as very relevant to me to > begin with, and his dogmatism doesn't make it any better. My first XP (hence TDD) projects were low-level microcontroller embedded real-time as was my most recent... > Still, I think something like TDD can have some use for me in some > situations, but 'the three rules' when taken literally are (at least for > me) absurd. I like test, I like short code fragments (I don't use > classic OO, so I don't mention about classes or methods.) But I also > like to think, and write a bunch of test in one go, or a 100+ lines of > code in one go. The 'three rules' seem to rule that out (is that a > correct interpretation?) so anyone who thinks I should obey them > literally to be a professional is, as far as I am concerned, a joke. 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. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 08:33 +0100 |
| Message-ID | <56c573ab$0$4031$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41011 |
Op 17-Feb-16 om 11:19 PM schreef Ian Collins: > Wouter van Ooijen wrote: >> Op 17-Feb-16 om 10:08 PM schreef Richard: >>> [Please do not mail me a copy of your followup] >>> >>> Wouter van Ooijen <wouter@voti.nl> spake the secret code >>> <56c4b474$0$4233$e4fe514c@newszilla.xs4all.nl> thusly: >>> >>>> PS Uncle Bob *does* claim that TTD is *the* tool to apply to every >>>> programming problem. >>> >>> What I've seen him claim is that he hasn't found anything better than >>> TDD. If you can show him something better than TDD, then he'll be >>> talking about that. >>> >>> If you have something you think is better than TDD, bring it Uncle Bob >>> and get him to champion it. If you can convince Uncle Bob, I'm very >>> interested in hearing about it. >> >> I'd rather convert the pope to shintoism and the Bush family to atheism >> than trying to convert Uncle Bob away from his rules. The chance of >> success seems much higher. >> >> The way he is talking he doesn't seem to have much experience in my main >> field, which is low-level microcontroller embedded real-time >> programming, so I don't regards his opinion as very relevant to me to >> begin with, and his dogmatism doesn't make it any better. > > My first XP (hence TDD) projects were low-level microcontroller embedded > real-time as was my most recent... > >> Still, I think something like TDD can have some use for me in some >> situations, but 'the three rules' when taken literally are (at least for >> me) absurd. I like test, I like short code fragments (I don't use >> classic OO, so I don't mention about classes or methods.) But I also >> like to think, and write a bunch of test in one go, or a 100+ lines of >> code in one go. The 'three rules' seem to rule that out (is that a >> correct interpretation?) so anyone who thinks I should obey them >> literally to be a professional is, as far as I am concerned, a joke. > > 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? Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-18 20:42 +1300 |
| Message-ID | <dilavtFo6vkU1@mid.individual.net> |
| In reply to | #41018 |
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), but the last test for the requirement would be that the drive sits the correct bits in the the appropriate configuration register(s). -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-18 20:45 +1300 |
| Message-ID | <dilb45Fo6vkU2@mid.individual.net> |
| In reply to | #41019 |
Ian Collins wrote: > 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), but the last test for the requirement would be that the > drive sits the correct bits in the the appropriate configuration It's been a long day... s/drive sits/driver sets/ > register(s). -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 08:58 +0100 |
| Message-ID | <56c579a6$0$4048$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41020 |
Op 18-Feb-16 om 8:45 AM schreef Ian Collins: > Ian Collins wrote: >> 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), but the last test for the requirement would be that the >> drive sits the correct bits in the the appropriate configuration > > It's been a long day... s/drive sits/driver sets/ 9:00 here, a fresh day just started :) Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-18 23:24 +1300 |
| Message-ID | <dilkf8Fo6vkU7@mid.individual.net> |
| In reply to | #41022 |
Wouter van Ooijen wrote: > Op 18-Feb-16 om 8:45 AM schreef Ian Collins: >> >> It's been a long day... s/drive sits/driver sets/ > > 9:00 here, a fresh day just started :) 23:23 here, time to leave the Linux kernel bugs to fester until morning! -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 08:58 +0100 |
| Message-ID | <56c5798b$0$4048$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41019 |
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? > 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)? Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-18 21:17 +1300 |
| Message-ID | <dild1dFo6vkU3@mid.individual.net> |
| In reply to | #41021 |
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! I actually wrote tests for a UART driver on an ARM STM32 processor last year. To verify the settings I had a block of mapped memory at the appropriate address for the device registers and simply tested for the correct values getting written. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 09:22 +0100 |
| Message-ID | <56c57f1e$0$4042$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41023 |
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.) Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-18 21:28 +1300 |
| Message-ID | <dildknFo6vkU5@mid.individual.net> |
| In reply to | #41024 |
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
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 09:39 +0100 |
| Message-ID | <56c5832f$0$3977$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41026 |
Op 18-Feb-16 om 9:28 AM schreef Ian Collins: > 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. Now that the test I would start with. Note that I mentioned 'run-time specified baudrate'. Would you test (whether register-values-based or with real hardware) be for one specific baudrate? And would the code you write be for one baudrate only or for the allowed range? Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-18 23:22 +1300 |
| Message-ID | <dilkbdFo6vkU6@mid.individual.net> |
| In reply to | #41027 |
Wouter van Ooijen wrote: > > Note that I mentioned 'run-time specified baudrate'. Would you test > (whether register-values-based or with real hardware) be for one > specific baudrate? And would the code you write be for one baudrate only > or for the allowed range? Now that is really hard to answer, there are so many ifs buts and maybes! In the example I cited, there was only one baud rate, so we only had to test that the correct number was written to the register. if there were several discrete values, how many to test would depend on how the value was derived. I would probably test the setting of the register and the the algorithm used to calculate the value. The algorithm is just like any other and not specifically driver/embedded code code. Either way my point - that TDD is just as relevant and useful for low level embedded code as it is for business logic - still stands. Code is code. How you implement the details of the tests may vary, but the process does not. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 11:57 +0100 |
| Message-ID | <56c5a3a5$0$3966$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41028 |
Op 18-Feb-16 om 11:22 AM schreef Ian Collins: > Wouter van Ooijen wrote: >> >> Note that I mentioned 'run-time specified baudrate'. Would you test >> (whether register-values-based or with real hardware) be for one >> specific baudrate? And would the code you write be for one baudrate only >> or for the allowed range? > > Now that is really hard to answer, there are so many ifs buts and > maybes! In the example I cited, there was only one baud rate, so we > only had to test that the correct number was written to the register. if > there were several discrete values, how many to test would depend on how > the value was derived. > > I would probably test the setting of the register and the the algorithm > used to calculate the value. The algorithm is just like any other and > not specifically driver/embedded code code. > > > Either way my point - that TDD is just as relevant and useful for low > level embedded code as it is for business logic - still stands. Code is > code. How you implement the details of the tests may vary, but the > process does not. Some messages ago you said that you follow the 3 rules, I am trying to find how you do that in a meaningfull way. Rule 2 says "You are not allowed to write any more of a unit test than is sufficient to fail." And 3 says "You are not allowed to write any more production code than is sufficient to pass the one failing unit test." IMO whenever you add a new baudrate to the set suite, the simplest way to make that test pass is to add an if statement or maybe a switch case or a table entry. Writing a formula that calculates the settings from the baudrate is more complex (reequires more code), so doing that violates rule 3? Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-19 09:29 +1300 |
| Message-ID | <dimnt3F9h5uU2@mid.individual.net> |
| In reply to | #41030 |
Wouter van Ooijen wrote: > Op 18-Feb-16 om 11:22 AM schreef Ian Collins: >> Wouter van Ooijen wrote: >>> >>> Note that I mentioned 'run-time specified baudrate'. Would you test >>> (whether register-values-based or with real hardware) be for one >>> specific baudrate? And would the code you write be for one baudrate only >>> or for the allowed range? >> >> Now that is really hard to answer, there are so many ifs buts and >> maybes! In the example I cited, there was only one baud rate, so we >> only had to test that the correct number was written to the register. if >> there were several discrete values, how many to test would depend on how >> the value was derived. >> >> I would probably test the setting of the register and the the algorithm >> used to calculate the value. The algorithm is just like any other and >> not specifically driver/embedded code code. >> >> >> Either way my point - that TDD is just as relevant and useful for low >> level embedded code as it is for business logic - still stands. Code is >> code. How you implement the details of the tests may vary, but the >> process does not. > > Some messages ago you said that you follow the 3 rules, I am trying to > find how you do that in a meaningfull way. Rule 2 says > > "You are not allowed to write any more of a unit test than is sufficient > to fail." > > And 3 says > > "You are not allowed to write any more production code than is > sufficient to pass the one failing unit test." > > IMO whenever you add a new baudrate to the set suite, the simplest way > to make that test pass is to add an if statement or maybe a switch case > or a table entry. Writing a formula that calculates the settings from > the baudrate is more complex (reequires more code), so doing that > violates rule 3? Not if it still passes the tests. Being able to refactor your code at any stage and know that you haven't broken it is one of the benefits of the process. So yes, you might start off with a chain of ifs and then go back and change the code to use a better algorithm. That's OK, that's good. One of the biggest problems I see with people new to TDD is that they done do what I consider the most important step - refactoring. So they end up with the messy code TDD's detractors complain about. Write a test Pass the test Commit Refactor Commit -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 22:00 +0100 |
| Message-ID | <56c63104$0$4337$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41036 |
Op 18-Feb-16 om 9:29 PM schreef Ian Collins: > Wouter van Ooijen wrote: >> Op 18-Feb-16 om 11:22 AM schreef Ian Collins: >>> Wouter van Ooijen wrote: >>>> >>>> Note that I mentioned 'run-time specified baudrate'. Would you test >>>> (whether register-values-based or with real hardware) be for one >>>> specific baudrate? And would the code you write be for one baudrate >>>> only >>>> or for the allowed range? >>> >>> Now that is really hard to answer, there are so many ifs buts and >>> maybes! In the example I cited, there was only one baud rate, so we >>> only had to test that the correct number was written to the register. if >>> there were several discrete values, how many to test would depend on how >>> the value was derived. >>> >>> I would probably test the setting of the register and the the algorithm >>> used to calculate the value. The algorithm is just like any other and >>> not specifically driver/embedded code code. >>> >>> >>> Either way my point - that TDD is just as relevant and useful for low >>> level embedded code as it is for business logic - still stands. Code is >>> code. How you implement the details of the tests may vary, but the >>> process does not. >> >> Some messages ago you said that you follow the 3 rules, I am trying to >> find how you do that in a meaningfull way. Rule 2 says >> >> "You are not allowed to write any more of a unit test than is sufficient >> to fail." >> >> And 3 says >> >> "You are not allowed to write any more production code than is >> sufficient to pass the one failing unit test." >> >> IMO whenever you add a new baudrate to the set suite, the simplest way >> to make that test pass is to add an if statement or maybe a switch case >> or a table entry. Writing a formula that calculates the settings from >> the baudrate is more complex (reequires more code), so doing that >> violates rule 3? > > Not if it still passes the tests. Rule 3 at http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd is "You are not allowed to write any more production code than is sufficient to pass the one failing unit test." In your opinion, does that include refactoring? Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-19 10:10 +1300 |
| Message-ID | <dimqavF9h5uU3@mid.individual.net> |
| In reply to | #41037 |
Wouter van Ooijen wrote: > Op 18-Feb-16 om 9:29 PM schreef Ian Collins: >> Wouter van Ooijen wrote: >>> Op 18-Feb-16 om 11:22 AM schreef Ian Collins: >>>> Wouter van Ooijen wrote: >>>>> >>>>> Note that I mentioned 'run-time specified baudrate'. Would you test >>>>> (whether register-values-based or with real hardware) be for one >>>>> specific baudrate? And would the code you write be for one baudrate >>>>> only >>>>> or for the allowed range? >>>> >>>> Now that is really hard to answer, there are so many ifs buts and >>>> maybes! In the example I cited, there was only one baud rate, so we >>>> only had to test that the correct number was written to the register. if >>>> there were several discrete values, how many to test would depend on how >>>> the value was derived. >>>> >>>> I would probably test the setting of the register and the the algorithm >>>> used to calculate the value. The algorithm is just like any other and >>>> not specifically driver/embedded code code. >>>> >>>> >>>> Either way my point - that TDD is just as relevant and useful for low >>>> level embedded code as it is for business logic - still stands. Code is >>>> code. How you implement the details of the tests may vary, but the >>>> process does not. >>> >>> Some messages ago you said that you follow the 3 rules, I am trying to >>> find how you do that in a meaningfull way. Rule 2 says >>> >>> "You are not allowed to write any more of a unit test than is sufficient >>> to fail." >>> >>> And 3 says >>> >>> "You are not allowed to write any more production code than is >>> sufficient to pass the one failing unit test." >>> >>> IMO whenever you add a new baudrate to the set suite, the simplest way >>> to make that test pass is to add an if statement or maybe a switch case >>> or a table entry. Writing a formula that calculates the settings from >>> the baudrate is more complex (reequires more code), so doing that >>> violates rule 3? >> >> Not if it still passes the tests. > > Rule 3 at http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd is > "You are not allowed to write any more production code than is > sufficient to pass the one failing unit test." > > In your opinion, does that include refactoring? No. I would amend rule 3 to say "You are not allowed to add functionality to any production code than is sufficient to pass the one failing unit test." Or even "You are not allowed to change the visible behaviour of any production code than is sufficient to pass the one failing unit test." Although that may be a bit too vague. I prefer to teach the write a test, pass the test cycle as adding functionality rather than adding code. Code is too specific in my opinion: you might add functionality by removing code! -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Wouter van Ooijen <wouter@voti.nl> |
|---|---|
| Date | 2016-02-18 23:15 +0100 |
| Message-ID | <56c6427b$0$4348$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #41038 |
Op 18-Feb-16 om 10:10 PM schreef Ian Collins: > Wouter van Ooijen wrote: >> Op 18-Feb-16 om 9:29 PM schreef Ian Collins: >>> Wouter van Ooijen wrote: >>>> Op 18-Feb-16 om 11:22 AM schreef Ian Collins: >>>>> Wouter van Ooijen wrote: >>>>>> >>>>>> Note that I mentioned 'run-time specified baudrate'. Would you test >>>>>> (whether register-values-based or with real hardware) be for one >>>>>> specific baudrate? And would the code you write be for one baudrate >>>>>> only >>>>>> or for the allowed range? >>>>> >>>>> Now that is really hard to answer, there are so many ifs buts and >>>>> maybes! In the example I cited, there was only one baud rate, so we >>>>> only had to test that the correct number was written to the >>>>> register. if >>>>> there were several discrete values, how many to test would depend >>>>> on how >>>>> the value was derived. >>>>> >>>>> I would probably test the setting of the register and the the >>>>> algorithm >>>>> used to calculate the value. The algorithm is just like any other and >>>>> not specifically driver/embedded code code. >>>>> >>>>> >>>>> Either way my point - that TDD is just as relevant and useful for low >>>>> level embedded code as it is for business logic - still stands. >>>>> Code is >>>>> code. How you implement the details of the tests may vary, but the >>>>> process does not. >>>> >>>> Some messages ago you said that you follow the 3 rules, I am trying to >>>> find how you do that in a meaningfull way. Rule 2 says >>>> >>>> "You are not allowed to write any more of a unit test than is >>>> sufficient >>>> to fail." >>>> >>>> And 3 says >>>> >>>> "You are not allowed to write any more production code than is >>>> sufficient to pass the one failing unit test." >>>> >>>> IMO whenever you add a new baudrate to the set suite, the simplest way >>>> to make that test pass is to add an if statement or maybe a switch case >>>> or a table entry. Writing a formula that calculates the settings from >>>> the baudrate is more complex (reequires more code), so doing that >>>> violates rule 3? >>> >>> Not if it still passes the tests. >> >> Rule 3 at http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd is >> "You are not allowed to write any more production code than is >> sufficient to pass the one failing unit test." >> >> In your opinion, does that include refactoring? > > No. I would amend rule 3 to say > > "You are not allowed to add functionality to any production code than is > sufficient to pass the one failing unit test." > > Or even > > "You are not allowed to change the visible behaviour of any production > code than is sufficient to pass the one failing unit test." > > Although that may be a bit too vague. > > I prefer to teach the write a test, pass the test cycle as adding > functionality rather than adding code. Code is too specific in my > opinion: you might add functionality by removing code! OK, so I think we agree that taking that Uncle Bob page literally is not a good idea? Can you refer me to a page or document or whatever that describes the version of TDD that you find usefull? ================== And back to the UART :) After the first test case, would I be allowed to write the UART init code that calculates the settings from the specified baudrate? That is much more than needed to pass that single test (which is for one baudrate). The TDD demo's that I have seen specifically don't do that. Wouter
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2016-02-20 11:22 +1300 |
| Message-ID | <dipisvFj7j6U1@mid.individual.net> |
| In reply to | #41041 |
Wouter van Ooijen wrote: > Op 18-Feb-16 om 10:10 PM schreef Ian Collins: >> I prefer to teach the write a test, pass the test cycle as adding >> functionality rather than adding code. Code is too specific in my >> opinion: you might add functionality by removing code! > > OK, so I think we agree that taking that Uncle Bob page literally is not > a good idea? Taking anything related to Agile practices too literally isn't a good idea! Doing so goes against the underlying people over process philosophy of agile. The "rules" laid down by the well known agile evangelists should be interpreted as guidelines rather than strict process steps (like those mandated by RUP). Look on them as somewhere to start the development of your own process. Every agile team I know have their own modified processes, some of these go back well before the "agile boom" in the early 2000s. > Can you refer me to a page or document or whatever that describes the > version of TDD that you find usefull? Not really, I was shown TDD by Kent Beck at an agile development conference back in 2002 and realised it put a more formal structure around the way I had been working for years. My then team developed our own process based on the concepts we had learned at the conference. Learning how to use agile processes isn't easy on your own, the long standing advice is to hire a coach for the first few weeks or months (depending on your budget). You really do have to learn by doing. > ================== > > And back to the UART :) > > After the first test case, would I be allowed to write the UART init > code that calculates the settings from the specified baudrate? Why not? Just TDD the code... -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | legalize+jeeves@mail.xmission.com (Richard) |
|---|---|
| Date | 2016-02-19 22:39 +0000 |
| Message-ID | <na85jm$6sm$1@news.xmission.com> |
| In reply to | #41052 |
[Please do not mail me a copy of your followup]
Ian Collins <ian-news@hotmail.com> spake the secret code
<dipisvFj7j6U1@mid.individual.net> thusly:
>The "rules" laid down by the well known agile evangelists should be
>interpreted as guidelines rather than strict process steps (like those
>mandated by RUP).
Instead of generalizing, I'm going to say that for Uncle Bob's rules
of TDD you should *literally* do them when learning TDD. You should
obey those rules literally and without deviation. Doing so is crucial
to learning TDD and actually "getting it" IMO.
You'll know you're in a good TDD workshop when the instructor reviews
the code of students and tells them to delete everything they've done
and start over when they've violated the rules.
In martial arts, this is known as "shuhari". When you are beginning
to learn TDD you aren't yet masterful enough to know *when* you can
bend or break the rules, so you must follow them rigidly. (You are
"shu".) As you achieve mastery, you advance to "ha" where you can
start to bend the rules or even break them completely. When you
become a true master, you advance to "ri" and the rules are no longer
necessary because you've internalized them as habit and you can be
more expressive and freeform or even make up your own competing
system.
<https://en.wikipedia.org/wiki/Shuhari>
Many of the people I've seen struggle with TDD are programmers with
many years of experience outside of TDD that feel uncomfortable being
placed into a position where they have to rigidly follow the rules
because they haven't achieved mastery.
This is somewhat akin to saying:
"What's so hard about programming? It's just typing!"
From what I can tell, Ian has been doing this a while and he has a
good intuition for when he can bend the rules without getting himself
into trouble. For an absolute beginner, it is my opinion that they
follow the rules literally. Otherwise, they will miss the crucial
insight that TDD brings because they will keep doing things the old
way.
I describe TDD as turning your normal pyramid of development upside
down. It is a significantly different way of thinking about the code
development process.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
[toc] | [prev] | [next] | [standalone]
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
Back to top | Article view | comp.lang.c++
csiph-web