As every developer will tell you, when you build the application you can create a debug-version of the app. This has extra code added in that provides ongoing telemetry so that, if the application fails, the developer can see where, why and when the crash occurred.
Before the application is delivered to the users the debug code is removed making the application smaller, faster and it consumes fewer of those precious cpu-cycles.
That is the code debugger. What about the human debugger?
A big chunk of every application is code that will never be executed. This is code that is designed to help the users when they make an error. This code is the validation statements and actions and the compensating code to unwind changes that now cannot be committed.
A customer told me recently that they have to complete a form with six entries, one of which is pre-filled. They have to fill in this form, perhaps, once a month. The data is usually the same each time it is completed. This, to them, was tedious and in need of automation. Processing thousands of forms might seem as though something was being achieved but the real work is in dealing with the exceptions.
So what does this mean for computing?
Here is a the first program I ever wrote. It is in FORTRAN. It calculates the area of triangle using the semi-perimeter method.
C This program calculates the area of a triangle using
C the Semi-Perimiter method
C By Kevin Parker
C Area = SQRT( SP (SP - A) * (SP - B) * (SP - C) )
C SP = (A + B + C) /2
C Variable definitions
REAL sidea, sideb, sidec, sp, aot
C Get the lengths of the three sides
WRITE (unit=*, fmt=1001, advance="no")"Enter length of A: "
READ (unit=*, err=91, fmt=1002) sidea
WRITE (unit=*, fmt=1001, advance="no")"Enter length of B: "
READ (unit=*, err=92, fmt=1002) sideb
WRITE (unit=*, fmt=1001, advance="no")"Enter length of C: "
READ (unit=*, err=93, fmt=1002) sidec
C Validate the data
IF (ABS(0.0 - sidea) < 0.000001) THEN
PRINT *, 'Invalid triangle: length of side A is zero'
IF (ABS(0.0 - sideb) < 0.000001) THEN
PRINT *, 'Invalid triangle: length of side B is zero'
IF (ABS(0.0 - sidec) < 0.000001) THEN
PRINT *, 'Invalid triangle: length of side C is zero'
IF (sidea < 0) THEN
PRINT *, 'Invalid triangle: length of side A is negative'
IF (sideb < 0) THEN
PRINT *, 'Invalid triangle: length of side B is negative'
IF (sidec < 0) THEN
PRINT *, 'Invalid triangle: length of side C is negative'
IF (sidea > sideb + sidec) THEN
PRINT *, 'Invalid triangle: A is > than lengths of B + C'
IF (sideb > sidec + sidea) THEN
PRINT *, 'Invalid triangle: B is > than lengths of C + A'
IF (sidec > sidea + sideb) THEN
PRINT *, 'Invalid triangle: C is > than lengths of A + B'
C Calculate the area
sp = (sidea + sideb + sidec) / 2.0
aot = (sp * (sp - sidea) * (sp - sideb) * (sp - sidec)) ** 0.5
C And the result is
WRITE (unit=*,fmt=1003) "Area of triangle ", sidea, ", ", sideb,
& ", ", sidec, " is ", aot
91 PRINT *, 'Invalid data entered for side A'
92 PRINT *, 'Invalid data entered for side B'
93 PRINT *, 'Invalid data entered for side C'
END PROGRAM main
Notice how much of the code is in red? All that code is code that, in the normal course of events, will never be executed. Once the user knows how to use the application they don’t make data entry errors so why validate the data.
In fact in this simple application the extra code increases the executable size by 10% and the run time by 40%. And the cpu cycles consumed to run are also increased by 40%.
Imagine telling your boss you can save 40% of the cpu cycles on your processors. And what if everything ran 40% faster. How much would that improve the user’s satisfaction with the system?
So am I advocating ripping out the validation code? No, not really. What I am proposing is that we might design the application such that it detects the user and determines if the user is an advanced one or a novice. If the user is an expert skip all the validation, if they’re a novice test everything until they become an expert.
Just a thought.