Maybe I'm weird but I really do not like syntax for this operator.
if (!person.getThinkingModel().isThinking()){...} if (person.getThinkingModel().!isThinking()){...} if (obj !instanceof Person){...}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()){...}
Hello
ReplyDeleteThis is hard to read because You use a train of get()...get()...get()... The situation will become even worse if You will use more get()...
When You put ! in that chain it is easy to omit by someone who reads it (for me sometimes it may look like small letter L). Besides this construction is not natural: why draw outside some personel's object internal details just only to ask them about something more?
Hide the logic inside personel object. I think personel object has (or should have) all required knowledge about "thinking" process. Create method isThinkingNow() inside personel object, and inside this metod do simple:
return getThinkingModel().isThinking()
Now Your code looks clear and is easy to understand:
if(person.isThinkingNow())
if (!person.isThinkingNow())
Anonymous is right...
ReplyDeleteold Chinese wisdom says:
If You think against Object Oriented (encapsulation in this case) paradigm than Your code stinks.
I never thought that someone my consider this as OO sample, while it's pure XML like.
ReplyDeleteAny way, now I know where the problem is, so I'll rewrite this post.