Back Link : HereticalProgramming
The blindingly short cycles and nano increments that I usually implement are what make think that when I work out what I do much of it will be XP.
10 Minutes may at times be an exageration at times it is only 4 or 5.
Whats a cycle?
Some times its just write compile.
Sometimes its write compile test.
Sometimes its write compile, say oh bugger, go for a walk.
Sometimes its write compile, say oh bugger, do something else until my unconscious solves the problem, say Aha and start again.
Write compile test? Come on, just try CodeUnitTestFirst. Just once. You'll be so glad you did. Then keep your unit tests in StarUnit - then you can ReFactor without pain. Go on, it won't hurt, it'll help. Then get someone to pair with you. Just for an hour, just as an experiment. It's not habit forming. Well, okay, it is ... --PeterMerel
Note I have accidentally programmed in pairs for periods, way before I heard of XP. We (small team) were working on a project and we get to some nexus, where the next iteration requires one critical change, a bottle neck. As there nothing to do for the one of the other prgrammers, we solved it together. Sorry there was no magic, the earth didnt move, and it was not habit forming. You asked for 'try it Just once', You got it. This has happened multiple times, it didnt form a habit on any of them. Well perhaps it did, but not an Xp style one. I still at very specific times take my code and run it by not just someone else but sometimes several. How do I decide when? When I get the bad feeling that Im not seeing the forest just the trees.
That was write compile, run the test... not write, compile, write the test, compile the test, run the test. The statement assumed the test was there. Seemed like a fiar assumption as how else did the test get there?
I suppose I could try to write the test first but in C++ that inavairiably produces tests that fail. aka Write the test compile. (Damn it dont link because I only have the test) Write the code thats missing Compile Run test.
So you could perhaps ask that I write the test code before the the other code then compile/link them both. On at least some occasions on some functions, I cant write the test first, why? How can it be cant? I cant write the test because I dont yet know precisely what the code Im testing will do. (yes Im serious) (see below) Also as it is I believe well known that full code coverage by testing is often not achieved and that even if full code coverage was achieved, it is rarley true that every code path is executed with the data structure it is running against in every possible state. Hence it is after I write the code to be tested that I usually am in the best posiion to know what tiny fraction (of every possible test) it is wise to write.
Note: In C++ Compile is a test that all code should pass. Then Link is test all code should pass. Then run the unit test is a test all code should pass. (AFAIK Until now the order is fairly non negotiable.) Also note that one of the code design critieria I have for classes I design, is that if the code compiles and links, it probably works too. How? Low level helper classes tend to accpet all possible inputs. Eg C++ string classes I write accept null ptrs, (char *)"", (const char *)"", ... as valid inputs. Before I did that bugs used to appear when a char * I thought never contains nulls had nulls in it.
No, operate from functional prototype to functional prototype.
Yes, you are saying what XP says, this is not XP, that is why I named these pages heretical programming. (I have now added a back link to make it clear.)
I think the discrepancy between our views is however mainly one of scale. I think I do go from functional prototype to functional prototype but those cycles are on average longer than 10 minutes.
Also see GrokTheProblemDomain where I advocate, in defined circumstances, implementing functional prototypes that are not aimed at meeting user needs but at developing a precise understanding of domain objects, SpikeSolution'''s for WorstThingsFirst, or to ClearTheFog.
Come on, just try CodeUnitTestFirst. Just once. You'll be so glad you did.
Sorry didn't like it. I like to document first. I like to undestand first. I still unit test throroughly, but i find no plus to unit test first. If that helps you understand better then so be it, but it's not the only way.
Interestingly, in a project I'm currently working on, simply running the resulting code has sufficed for a unit test so far... if it compiles, and if when I run it, it displays the little all important window with a webcam in it, I deem it working. I don't think it'll be long before I start including unit tests though; the only reason why I can get away with this (and I say get away with this for a reason) is that the program is currently fairly linear in nature... I know if it's working properly within a couple seconds of running it, about as quick as I can tell the difference between 'all tests passed' and 'test xxx failed'. (Hence why there weren't any unit tests posted up with the travesty of a wiki page call VideoMonExperiment?... sorry 'bout that by the way (sheepish grin) ) --WilliamUnderwood (cwillu)
... and now I'm realizing (couple months later), the above was really an involved spike solution...
If you are running in 10 minute cycles, doing code first or unit test first really doesn't matter. You are essentially doing them at the same time; it just depends on typing order. In languages like C/C++, it is just easier to create the basic code stub first, then write the code to test it.
Anything beyond a code stub should probably be written after the test, even in the 10 minute increments. I'm finding, anything more than a stub, and I start getting stuck on what it is I'm doing, and the 10 minute increments start devolving into 30 minute increments, and not long after, 8 hour increments... Yes, you could do it either way and still get benefit from the testing, but doing the test first in my experience allows me to focus much more on the task at hand. -- cwillu
You might devolve, I dont. Mine have got shorter over the years.
People who have removed their name from the thread mode: AlanChristiansen