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#
Comments are closed.
Search
On this page....
Countdowns
The Daily Parker +2748d 18h 42m
Parker's 7th birthday 22d 18h 32m
To West Coast 35d 08h 22m
My next birthday 103d 11h 00m
Categories
Aviation (241) Baseball (92) Biking (26) Chicago (673) Cubs (148) Duke (129) Geography (258) Jokes (98) Kitchen Sink (486) London (2) Parker (164) Daily (203) Photography (123) Politics (294) US (893) World (181) Raleigh (18) Religion (53) San Francisco (67) Software (165) Blogs (48) Business (159) Cloud (52) Cool links (108) Security (75) Travel (67) Weather (574) Astronomy (66) Windows Azure (25) Work (14)
Links
Archive
<May 2013>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
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