Thorsten Behrens wrote:
Frank Schönheit - Sun Microsystems Germany <[EMAIL PROTECTED]> writes:

Sure, the need to enforce API
constraints programmatically is still a valid point, e.g. a method
returning a null reference though the API stated the returned ref is
never null has to lead to a RuntimeException.
But I rather would like this decoupled, e.g.

Reference<foo::XBar> x(y->baz()[, UNO_QUERY]);
assureNotNull(x);

IMO more verbose, but clearer to read.
[...]

I don't like the additional line. That's basically how it's done today,
and this really becomes cumbersome over time. Writing the same pattern
again and again isn't really fun.

I think this is more about readability, and not about writability. And
since code is read more often than written, I second Daniel's
opinion.
Its also about readability, code that uses the API, esp. old API has to
do lots and lots of queryinterface. As always, if not to compact, 20
lines of code read much better than 30+

+1 For Franks suggestion, I very often use UNO_QUERY_THROW to enforce
non null, since using if() does not only introduce a second line of
code, also your error handling and recovery code is shorter if it is
reduced to one catch block.

And if there is still someone who thinks the office should crash if a
component does not fullfill its contract, please drop me a mail.

Regards,
Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to