[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-debug-dev] RE: Idle thoughts on NPE and debugging outside a
|
Just a comment:
My mission has been accomplished.
I just wanted to get some comments and stir some thinking on the
subject.
> The "NPE problem" is the problem of lazy programmers and=20
> programmers who do not look into the full specifications
> of the APIs they are using. This sweeping statement is
> not targetted at any particular developers or language but
> is true in general.
Lazy?
Some mindless ramblings on the matter follows...
I don't think it is going to be a very effective strategy to spend
resources on changing the programmers. Ref. parents spend 20 years on
their kids, look at the results! :-)
I believe that there is such a thing as "API tripwire"s.
E.g. "this API should have its arguments swapped, when called on
Thursdays".
Fortunally Java makes it impossible to define define other "null"-like
values, as is possible in C/C++. It is possible to multiplex error codes
onto pointers. "If the result is <0 then it is an error code, otherwise
it is a pointer to XXX".
There is no way to tag the return type with "returns XXX or null" vs.
"returns XXX". Would have been nice with "checked return values", just
like "checked exceptions".
The amount of information about the API that can be packed into a Java
method signature is very limited.
Hmmm.... could Java 5.0 be used to flesh out the API's in combination
with Eclipse to create a plugin that could do more checks on calling
code?
Perhaps even static AND runtime checks....
--
Øyvind Harboe
http://www.zylin.com