Politics, Weather, Photography, and the Dog
Tuesday 4 August 2009

(By way of explanation why I'm being wery wery qwiet today.)

Actually, I'm hunting financial accounting (Duke) and bugs (client). Like this one, which shows one of the perils of refactoring. See if you can spot my stupidity:

Original code

private void OldMethod
{
   bool canChangeThing =
   (
      _isCompany |
      _isClient &
      (
         someConditionA == true |
         someConditionB == true
      )
   );

   if (canChangeThing) 
   { 
      // do stuff 
   }
}

Refactored code

private bool CanChangeThing
{
   get
   {
      return (
         _isCompany |
         _isClient &
         !(null == _thing) &&
      	(
            someConditionA == true |
            someConditionB == true
         )
      );
   }
}

private void OldMethod
{
   if (CanChangeThing) 
   { 
      // do stuff 
   }
}

Fixed bug

private bool CanChangeThing
{
   get
   {
      return (
         _isCompany |
         (_isClient &
            !(null == _thing) &&
            (
               someConditionA == true |
               someConditionB == true
            )
         )
      );
   }
}

private void OldMethod
{
   if (CanChangeThing) 
   { 
      // do stuff 
   }
}

The sound you hear is me hitting my head on my desk until it stops hurting.

Tuesday 4 August 2009 13:32:21 CDT (UTC-05:00)  | Comments [0] | Software#
Search
On this page....
Hunting wabbits
Countdowns
The Daily Parker +2774d 21h 28m
Parker's 7th birthday +3d 08h 14m
To West Coast 9d 05h 35m
My next birthday 77d 08h 13m
Categories
Aviation (245) Baseball (92) Biking (26) Chicago (684) Cubs (150) Duke (130) Geography (263) Jokes (98) Kitchen Sink (502) London (4) Parker (171) Daily (203) Photography (124) Politics (296) US (906) World (185) Raleigh (18) Religion (55) San Francisco (67) Software (165) Blogs (48) Business (161) Cloud (52) Cool links (110) Security (75) Travel (68) Weather (575) Astronomy (66) Windows Azure (26) Work (14) Writing (2)
Links
Archive
<June 2013>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Full archive
Blogroll
About
David Braverman and Parker
David Braverman is a software developer in Chicago, and the creator of Weather Now. Parker is the most adorable dog on the planet, 80% of the time.
Legal
All content Copyright ©2013 David Braverman.
Creative Commons License
The Daily Parker by David Braverman is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License, excluding photographs, which may not be republished unless otherwise noted.
Admin Login
Sign In