in reply to Re^8: Corner cases are not always "code smell"
in thread Neither system testing nor user acceptance testing is the repeat of unit testing (OT)
In my view of the world (however limited in scope that might be), optimizations are an implementation detail, save where they are required by spec. For example, "This process must happen in 0.1 seconds or less per record." Then, you write tests to verify that not only does this occur for the 1-record situation, but that the process scales linearly as you run 100, 1000, and 1_000_000 records. (Obviously, the latter is an weekend-only test.)
When they are not required by spec, I begin to wonder why optimizations are needed. Assuming that they are, then it's just a different implementation that meets the same specification (as enforced by the unit-tests).
In your case, the original implementation had bugs in it. When you find the bug, it becomes part of the spec (through the testsuite) and you fix the implementation to pass the tests. If that results in a quicker runtime or a reduced memory usage, that's bonus. It's not an optimization - it's correctly functioning code.
Think of this another way - if your code has corner-cases, then your interface also has corner-cases. If the interface doesn't specify to the user that these corner-cases exist, then how will s/he know to take them into account? Or, let's say that there's what you would call a corner-case because of VMS. File::Spec is a good example of this. Well, the spec now includes "This will run on VMS." Whatever is needed to meet the spec is what is needed to be done. And in the File::Spec testsuite, there's a section that deals with VMS, as there should be.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^10: Corner cases are not always "code smell"
by tilly (Archbishop) on Oct 25, 2005 at 17:30 UTC | |
by dragonchild (Archbishop) on Oct 25, 2005 at 17:57 UTC | |
by tilly (Archbishop) on Oct 26, 2005 at 02:47 UTC |