Going well means going fast - going fast creates bad code

by jk 30. September 2009 12:22

Most projects end up in crunch time.  Here's a gem I ran across recently.  I didn't look to see who did it (hey, it may have been me), but nevertheless it needed fixing (the code here is not verbatim, but the meaning remains)...

		if (!someBooleanFunction(comparisonData1, comparisonData2)
		{
		   return false;
		}
		else
		{
  		   return true;
		}
			
		
  • The if statement has the ! (not) operator. I find negative logic difficult to read
  • This could have been solved by just doing a return on the output of the function!!
Cheers to good code! jk

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Technical

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen