[jdom-interest] Still more Verification

Scott Ellsworth scott at alodar.com
Wed Aug 23 09:36:36 PDT 2000


At 02:48 PM 8/23/2000 +0200, Tako Schotanus wrote:
>And in what way would it be made "difficult"?  Because I sure as hell 
>wouldn't like it if I would be forced to use slower code just because to 
>force correctness on lazy programmers.  And the fastest code should be 
>just as easy to use in my opinion.

In most cases, the best answer is to make the checking code be on by 
default, but then to have a means of turning it off that is not 
horrendous.  Given that I am the profiler gnome for a number of projects, I 
can state with little fear of contradiction that most optimizations are a 
waste of time, but that some of them are very, very important.  It is 
important to make the right thing for the majority case be what happens 
unless you jump through a hoop or two.

I feel much the same way about assertions - our old c++ programmers made 
heavy use of them, with a boolean that could be compiled in or out.  We 
eventually found that in all but a very small subset of our code, the 
checking just did not make a difference.   Argument checks, for example, 
took essentially zero time for most large methods.  There were those few, 
though, that could not ship in runtime code, since they involved long 
searches or the like.  Those stayed only in the debug version.

So, yes, there must be a way to turn it off.  There are cases where it will 
make a difference, but those cases are only the ones where you are working 
in memory, as network or disk access will dwarf check time.  Because some 
people are doing that, we will want to make them happy.

The two means that have been suggested thus far are:

1.  a method, such as "killVerification"
2.  protected methods that require one to derive a subclass that can call 
protected methods.

Of the two, I think I prefer number 1, as I would rather people not have to 
look at the code if they do not have to.  I can see number 2, though, as 
you would have to recompile anyway if you wanted to get a profile for the 
jdom classes, and you would need that to know whether this was the problem.

Scott
Scott Ellsworth
scott at alodar.com




More information about the jdom-interest mailing list