Current area: HOME -> Blogs -> Jonathan's Blog -> Read Post

I hate "== true"

Posted on Thursday, December 13, 2007 at 9:19 AM
If you've asked someone to look for something you left at their house, would you say, "give me a call if it's true that you found it"? No, you'd say "give me a call if you found it". So why do so many people write things like:
if (found == true)
Instead of the shorter, clearer, equivalent:
if (found)
Yes, I know, I shouldn't let refactoring get me so cranky.

Comments
I agree in principle... - Posted on Saturday, December 15, 2007 at 12:40 AM by Actor
I agree in principle but if(found==true) is relatively minor compared to other examples of poor style that a new, or even experienced, programmer can use. It still rather clearly conveys what is meant and probably generates the same machine code.
Indeed - Posted on Monday, December 17, 2007 at 1:53 AM by Jonathan
For sure it's minor compared to other many other things that are done. I was just being irritable.


Sponsored links

ASP.NET 3.5 Hosting on Windows 2008!
ASP.NET 3.5/2.0 Hosting on Windows 2008 & 2003! AJAX, LINQ, & Silverlight Ready! 3 Mo. Free!!
Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
SFTP components for .NET
Add complete SSH and SFTP support to your .NET framework application
Experience Adobe? FLASH MEDIA SERVER 3
Introducing the media solution for total action without interruption. TRY IT NOW FOR FREE!


Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.