On 16 Sep, 04:01, ste...@coppice.org wrote:> On Sep 16, 6:33�am, Scott Seidman <namdiestt...@mindspring.com> wrote: > > > Rune Allnor <all...@tele.ntnu.no> wrote in news:3e4a5aef-3e3e-4a2b-8b1e- > > 22efb12bc...@f36g2000hsa.googlegroups.com: > > > > - One knows when one is finished, since the code apasses all > > > � the tests. �Which means one avoids stress as one knows > > > � the exact state of the project. > > I think that is overstating the value of a very valuable practice. It > implies the status of the units determines the status of the whole. In > a lot of projects that is far from the case.I can only speak from personal experience, but in the past I've always been a bit pessimistic when attempting to use my own old code, since I know that my main weakness is up-front attention to detail. I always start with the big picture and work my way out to the details as necessary. So I always knew there were details missing in my old code, since I knew I had left the code before all the details had been addressed. These unit test frameworks are the perfect persuation for addressing the details as I become ware of them. Once I know that the various units pass all the tests, I have far more confidence in the units, and thus in the system as such.> > This suggests that one knows what all the tests are before one starts > > programming. �Definitely the way to go, but not always the way things are > > done. > > It implies you know *some* of the things which must be tested at the > beginning, and you really should know that much.Exactly. If you don't, there is no point in doing the programming.> As you realise the > limitations in your test coverage, you can gradually fill in the gaps. > This practice tends to work very well, if taken seriously.This is the approach I've found myself to use. Again, I start with the big picture and fill in the details as I work. Rune
Online · Live + on demand
February 9-11, 2027
Price goes up Jan 1: register now to lock in today's rate
Register Now →
OT? Test-driven programming
Started by ●September 15, 2008
Reply by ●September 15, 20082008-09-15
Reply by ●September 15, 20082008-09-15
On 16 Sep, 01:01, Vladimir Vassilevsky <antispam_bo...@hotmail.com> wrote:> Rune Allnor wrote: > > Probably obvious to the pros out there, but test-driven programming > > has really made a difference! > > > I've been hacking away on some C++ code for a week now, and > > for the first time I have made a serious effort to write and run > > tests as an intergated part of the job. > > Unfortunately, even if all parts are working, that does not mean that > the whole thing is working. There are also the compiler, the operating > system and the hardware issues.Of course. But having confidence in the software makes a big difference. A few years ago I coded up a rather complicated IIR filter design program. On one of my travels a year or so later I discovered that the gain of certain IIR filters was wrong. The flaw was unstable, as it appeared every now and then in unpredictable ways. As I was away from home, I did not have much more than the source code and a debugger available, no books or formulas or anything like that. Anyway, I decided to have a try and see if I could find the flaw. So once I got a couple of faulty filters, I started the debugger to look for patterns and possibly see what might be wrong. The program used a polynomial root-finder which factored the 4th-order filter sections in bandpass and bandstop filters, which treated the mixtures of real and complex roots differently. Basically, the execution path depended on the order it found the roots. Whenever the root-solver found one real-valued root, it factored the root away. When it found a complex-valued root it factored both the root and its complex conjugate out. This happened only if one of the two first roots was complex- valued; if there was two roots left it used the usual formula to solve 2nd order polynomials. It turned out that when there was exactly one real-valued root left, there was a typo in the solution for the last root. What should be x=(a-c) was in fact x=(1-c/a) (or vice versa.) I spent between one and two hours tracking down that bug, with no other aids than the source code and the debugger. Which wasn't too bad, seen in isolation. However, the fact that the errors were present in the code for more than a year was a bit frustrating. And I can't guarantee there are no more errors of the same kind. A unit test framework can't ensure a good design, but it can catch those types of stupid blunders. Rune
Reply by ●September 15, 20082008-09-15
On 16 Sep, 04:08, ste...@coppice.org wrote:> On Sep 16, 5:46�am, Rune Allnor <all...@tele.ntnu.no> wrote:> > - One knows when one is finished, since the code apasses all > > � the tests. �Which means one avoids stress as one knows > > � the exact state of the project. > > This is far from true. Unit tests tell you about correctness of the > functionality of the modules, not the system.That's a big difference, compared to not knowing the state of the modules.> The bits may not all fit > together properly to form a system, or there could be funky real time > related issues that unit tests completely ignore.Sure. But if you know those are the unresolved issues, you know where to look for snags. I've seen SW vendors who more or less refused to follow up on customers requests to business- critical product enhancements for the very reason that they knew they would introduce bugs to the system. bugs of the kind a test framework would catch. Maybe a healthy decision on behalf of the SW vendor, but we were left hanging high and dry since we were unable to get our job done as we wanted to.> > - As one tests blocks which depends on earlier blocks, one > > � discovers bugs one made earlier (and thus, flaws in previous > > � tests.) I just found and corrected a bug I wrote five days ago, > > � due to a dependent module which failed a test. > > Yep. Keep fleshing out those unit tests, as you find their > limitations. :-)Making the effort, learning as one goes, try and fix the newly discovered bugs while not breaking previous tests...> > The Unit Test frameworks + post-build event configurations > > in the VS2005 IDE has really made the job a lot easier. > > Or at least more comfortable. > > "Comfortable" and "VS2005 IDE" do *not* belong together.Well, it's not up to me to select the tools. The OS is given, Windows, and among the tools available on that platform Visual Studio is the default. I used Borland's Turbo C++ 2006 for a couple of years, but there were too many hacks on top of earlier editions of VS to make a big difference. The makefiles on *NIX platforms ar of course more flexible, but VS has a configuration where one runs the test executable as part of the build process, such that test fails are reported on the same level as syntax errors and link failures. That alone is reason enough for me to select VS over an IDE which does not offer such a configuration. Rune
Reply by ●September 15, 20082008-09-15
On 16 Sep, 03:25, Richard Owlett <rowl...@atlascomm.net> wrote:> Rune Allnor wrote: > > On 15 Sep, 23:59, Richard Owlett <rowl...@atlascomm.net> wrote: > > >>Rune Allnor wrote: > > >>>Probably obvious to the pros out there, but test-driven programming > >>>has really made a difference! > > > ... > > >>Jerry, shall we let him in on a post 3rd generation language > >>(aside to Rune - its newsgroup is abbreviated clf, LOL ;) > > > Well, that a tool *exists* isn't sufficient for it to be useful; > > it needs to be *available* as well. Ah, and users need to be > > able to, well, use it. > > > It might well be the case that you two oldies know these things > > from way back when. I've been making waves for a couple of years > > now by showing computer laypeople tricks I learned under UNIX > > decades ago, but this time applied in the windows world. > > > Simple stuff like 'grep' and 'ls > regexp.' Hardly new or Nobel > > prize material, but it makes a certain impression on people > > who only knows the Windows GUI. > > > Rune > > LOL and possibly just made IDIOT of myself > Due to time zones > I *presumed* Jerry would respond before you saw my postI know, I'm on more or less US time. Don't know why, though.> Your post was a list of key features of my preferred programming > language �[with which Jerry is also familiar] > > FORTH encourages top down design with bottom up coding/testing > "clf" was a reference to comp.slang.forth newsgroupWell, the testing is automated here. Instead of manually selecting test parameters and evaluating results, one sets up a program to run the cases and check for all sorts of undesired conditions.> And since you are reading this ;} > In a previous thread you said that you had used spectrograms of call of > artic loon to demonstrate harmonics. I suspect I've demonstrated AM > sidebands with my version of 3D spectrograms. Have you seen the same > with traditional format. [If you wish private discussion on this my > email is valid]What kind of file was this? .wav? .mp3? What was the history of the file? If it was a .wav that had been generated from an .mp3 it would most likely suffer from all the 'weird' effects usually associated with .mp3... Rune
Reply by ●September 16, 20082008-09-16
Rune Allnor wrote:> [snip] > >>And since you are reading this ;} >>In a previous thread you said that you had used spectrograms of call of >>artic loon to demonstrate harmonics. I suspect I've demonstrated AM >>sidebands with my version of 3D spectrograms. Have you seen the same >>with traditional format. [If you wish private discussion on this my >>email is valid] > > > What kind of file was this? .wav? .mp3? What was the history > of the file? If it was a .wav that had been generated from an .mp3 > it would most likely suffer from all the 'weird' effects usually > associated with .mp3... > > RuneActually, I saw effect in both what I was led to believe were "prime sources". I think what I observed is real as I also observed similar in an *intrinsically* time invariant test case. If you have Scilab installed on your local system, see my last post to comp.soft-sys.math.scilab .
Reply by ●September 16, 20082008-09-16
Rune Allnor wrote:> Probably obvious to the pros out there, but test-driven programming > has really made a difference!Oh yes!> I've been hacking away on some C++ code for a week now, and > for the first time I have made a serious effort to write and run > tests as an intergated part of the job. > > Some of the benefits: > > - One can't just write some code and expect it to be testable. > One needs to break the code up in testable modules, which > makes for a better overall design.Yep. If it is difficult to break up code then I recommend to read Michael Feathers book "Working Effectively with Legacy Code".> - One can't get away by ostponing all those awkward limit > cases; they come back and haunt you in no time. One has > to deal with them up front. Which means the implementation > is better.This just depends on the set of test cases you select. You can easily skip or forget some limit tests.> - One knows when one is finished, since the code apasses all > the tests. Which means one avoids stress as one knows > the exact state of the project.This is true if there is also a test of the whole system. But it is very assuring to know that a bug is not in one of the tested units.> - As one tests blocks which depends on earlier blocks, one > discovers bugs one made earlier (and thus, flaws in previous > tests.) I just found and corrected a bug I wrote five days ago, > due to a dependent module which failed a test.Yep.> The Unit Test frameworks + post-build event configurations > in the VS2005 IDE has really made the job a lot easier. > Or at least more comfortable.Well, I adapted a very simple C++ class which I found while looking through the web pages recommended by M. Feathers, to my own needs. It's very simple to use, and the Makefile ensures that a test program passes before the library or the program is installed with 'make install'. See the link 'C++ Unit Test Library' on my home page at: http://www.huennebeck-online.de/software/download/src/index.html Welcome to the new world of tested code - it makes life so much easier. The biggest advantage is the regression test: each time you modify your code to introduce a new feature the unit tests tell you whether you broke an old test case. It happened once to me that a modification of an existing function broke one test out of more than 3000. This I would have never found just by code inspection. bye Andreas -- Andreas H�nnebeck | email: acmh@gmx.de ----- privat ---- | www : http://www.huennebeck-online.de Fax/Anrufbeantworter: 0721/151-284301 GPG-Key: http://www.huennebeck-online.de/public_keys/andreas.asc PGP-Key: http://www.huennebeck-online.de/public_keys/pgp_andreas.asc
Reply by ●September 16, 20082008-09-16
On 16 Sep, 06:12, Richard Owlett <rowl...@atlascomm.net> wrote:> Rune Allnor wrote: > > [snip] > > >>And since you are reading this ;} > >>In a previous thread you said that you had used spectrograms of call of > >>artic loon to demonstrate harmonics. I suspect I've demonstrated AM > >>sidebands with my version of 3D spectrograms. Have you seen the same > >>with traditional format. [If you wish private discussion on this my > >>email is valid] > > > What kind of file was this? .wav? .mp3? What was the history > > of the file? If it was a .wav that had been generated from an .mp3 > > it would most likely suffer from all the 'weird' effects usually > > associated with .mp3... > > > Rune > > Actually, I saw effect in both what I was led to believe were "prime > sources". > > I think what I observed is real as I also observed similar in an > *intrinsically* time invariant test case. If you have Scilab installed > on your local system, see my last post to comp.soft-sys.math.scilab .I suppose you mean this one: http://groups.google.no/group/comp.soft-sys.math.scilab/msg/c9ace7fd75245d60 I've only scanned the code very quickly, so I won't pretend I understand in full detail what you do. However, I can't find very easily refernces to window functions (hanning, hamming,...) which, if correct, might indicate that you don't use such functions. If that's correct, there is a chance that you will see high sidelobes caused by the rectangular window (-13 dB or so for narrow-band signals). If it is indeed the case that you don't apply window functions, scale each temporal frame by some window function prior to the FFT. Rune
Reply by ●September 16, 20082008-09-16
On 16 Sep, 00:33, Scott Seidman <namdiestt...@mindspring.com> wrote:> Rune Allnor <all...@tele.ntnu.no> wrote in news:3e4a5aef-3e3e-4a2b-8b1e- > 22efb12bc...@f36g2000hsa.googlegroups.com: > > > - One knows when one is finished, since the code apasses all > > � the tests. �Which means one avoids stress as one knows > > � the exact state of the project. > > This suggests that one knows what all the tests are before one starts > programming. �Well, no. One doesn't necessarily know *all* the conditions *before* one starts. One knows a lot before one starts and one (well, at least I) discovers quite a few of the awkward details as one goes along. On at least three occasions during the past week I have stopped and reconsidered (and reimplemented) 'obvious' approaches and designs when I ran into trouble with formulating boundary conditions or test cases. Of course, no guarantees that the present state covers 100% of the application domain, but I am quite sure I'm at >99%. And that whatever bugs remain can be smoked out by selecting 'awkward' boundary test cases for the dependent modules. Rune
Reply by ●September 16, 20082008-09-16
Rune Allnor <allnor@tele.ntnu.no> wrote in news:a5476ac9-660c-4523-93c2- 4a867ab80fcd@y21g2000hsf.googlegroups.com:> So I always knew there were details missing in my old code, since I > knew I had left the code before all the details had been addressed. > > These unit test frameworks are the perfect persuation for addressing > the details as I become ware of them. Once I know that the various > units pass all the tests, I have far more confidence in the units, > and > thus in the system as such.So, when are you jumping to Ada? ;) -- Scott Reverse name to reply
Reply by ●September 16, 20082008-09-16
steveu@coppice.org wrote in news:451d02af-9a2e-4e5c-87f0-eb23e9d3fcc0 @i76g2000hsf.googlegroups.com:> It implies you know *some* of the things which must be tested at the > beginning, and you really should know that much. As you realise the > limitations in your test coverage, you can gradually fill in the gaps. > This practice tends to work very well, if taken seriously. The last > point is important, as many people are forced to do unit testing, but > pay lip service to it. > > One of the great things a lot of people ignore about unit test suites > is they provide a very efficient way to do regression testing later > on. >One of the great things that people ignore about their test suites is the need for a test suite. -- Scott Reverse name to reply







