Web Development

General discussion


Using short-circuiting operators

By editor's response ·
Tell us what you think about the value of using short-circuiting operators, as featured in the August 12th Java e-newsletter. Have short-circuiting operators improved performance and simplified your code?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Null Object

by kevlin In reply to Using short-circuiting op ...

Sometimes the answer that leads to cleaner code is not to change your style of evaluation, but to change what you are evaluating. There are cases when a check for null can be eliminated easily by introducing the Null Object pattern:



Collapse -

Bad link

by rsalcedo In reply to Null Object


I was interested in reading the document you mentioned, but the link is not valid. Do you know where else it can be found?


Collapse -

Bad link

by rsalcedo In reply to Null Object

Never mind,
I found it one level up in the directory tree:


Collapse -

Null Pattern

by bayard In reply to Null Object

Definitely. The Null pattern is a great way to eliminate NullPointerExceptions from occuring in your code. [As described in builder.com/TechRepublic e-newsletter dated Mon, 5 Nov 2001, though I'm not aware of an archive to link you to ].

Simple example being, when you ask your person-loading code for a person, and the ID you ask for isn't there, it returns NullPerson and not null. NullPerson is a legal person whose name is "" etc.


Related Discussions

Related Forums