18 December 2009

The logical-complement operator !

Maybe I'm weird but I really do not like syntax for this operator.

Now time it's like:

if (!person.getThinkingModel().isThinking()){...}

I would personally prefer:

if (person.getThinkingModel().!isThinking()){...}

I would do same about instanceof to allow:

if (obj !instanceof Person){...}

Work around:
Would be nice to see both methods generated isThinking() as well as isNotThinking() instead of one in that case. Problem in this solutions involve setters which should be duplicated as well, and mostly 'Not' version should call traditional with simple negation, which increases stack traces.

if (person.getThinkingModel().isNotThinking()){...}

This way have one more advantage. When you write in more than one language you can worry less about operators priority.

Use yours own judgement, which is easier to read and write.