Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #41036
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: TDD can be useful even when it doesn't achieve what you want |
| Date | 2016-02-19 09:29 +1300 |
| Message-ID | <dimnt3F9h5uU2@mid.individual.net> (permalink) |
| References | (11 earlier) <56c57f1e$0$4042$e4fe514c@newszilla.xs4all.nl> <dildknFo6vkU5@mid.individual.net> <56c5832f$0$3977$e4fe514c@newszilla.xs4all.nl> <dilkbdFo6vkU6@mid.individual.net> <56c5a3a5$0$3966$e4fe514c@newszilla.xs4all.nl> |
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
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web