Ugo Cei wrote:

Marc Portier wrote:

yeah, but this is something that never needs to be catched it really is a programming error, so I find the test for null unesessary and the possible resulting NPE as more then RTE enough to commincate the coding error.


The problem with the NPE is that you'd need to look at the stacktrace to find what the exception is about, as you get no meaningful message, and the exception might be thrown when you try to dereference the null pointer, which could be far from where getId() is called. What I propose is to throw a RTE when the widget is built. Fail early, if you can.


yep that is the idea completely id should become a final member of the definition as such it needs to be provided during build

it could still be set to null, but would result in a state 'abstract' of the definition meaning it is an a state that will make the createInstance() on it to throw a RTE (IllegalState IMO)
(see wiki page WoodyRefactoring)


this will result in instances that can only point back to definitions that have an id set != null

so getId() on instance level will effectively lead to always returning a non-null

unless we have made a programming error in setting up this chain, this is not a circumstance IMO that requires additional RT checking to generate specific RTE's


Admittedly, this is just a convenience for the developer.


more then needed, no?
it seems odd to me to do a runtime check to generate a log message saying: "The developer of this code couldn't correctly implement his own design vision, please let him be excused and thank him for the fact that he could at least log this nicely?"


ah true open source!
we could actually even provide the patch in the error-message and encourage users to send it to bugzilla :-)


-marc=
--
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
[EMAIL PROTECTED]                              [EMAIL PROTECTED]

Reply via email to