Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31724

Re: Main Loop porblm

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Main Loop porblm
Date 2015-05-18 11:15 -0400
Organization A noiseless patient Spider
Message-ID <mjcvk3$4gl$1@dont-email.me> (permalink)
References <c666ab49-a6d4-4ad0-b4a5-4ab7da6d5c97@googlegroups.com>

Show all headers | View raw


On 5/18/2015 9:50 AM, Michael wrote:
> Simple window application with JSlider. [...]

     From the follow-up, it seems you have solved your problem.
However, there's still a small matter of style:

> 	    	if(show == true)

Do you see anything odd about this test?  The comparison is
between a boolean variable (whose value is `true' or `false')
and the boolean constant `true', and the result of comparing
is either `true' or `false'.  In fact, the result of the
comparison is whatever value `show' itself has: The comparison
has made no "progress."  You began with a value that is either
`true' or `false', and you arrive at an expression whose value
is either `true' or `false'.  If you want to check the value of
the expression, shouldn't you write

	if ((show == true) == true)

?  Well, no: You're still stuck with a `true' or `false' result,
and you still need to test it.  So, maybe

	if (((show == true) == true) == true)

would be an improvement?  Um, no, and it's beginning to look like
adding more and more `== true' comparisons might not be the right
way to go.  Hmmm: What to do?

	if (show)

... might be an attractive option, don't you think?

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Main Loop porblm Michael <progressman757@gmail.com> - 2015-05-18 06:50 -0700
  Re: Main Loop porblm Michael <progressman757@gmail.com> - 2015-05-18 07:05 -0700
  Re: Main Loop porblm Silvio <silvio@internet.com> - 2015-05-18 17:01 +0200
  Re: Main Loop porblm Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-18 11:15 -0400

csiph-web