{"id":94,"date":"2008-06-11T06:05:45","date_gmt":"2008-06-11T11:05:45","guid":{"rendered":"http:\/\/onthe8spot.com\/?p=94"},"modified":"2008-06-11T06:05:45","modified_gmt":"2008-06-11T11:05:45","slug":"on-refactoring","status":"publish","type":"post","link":"http:\/\/onthe8spot.com\/index.php\/2008\/06\/11\/on-refactoring\/","title":{"rendered":"On Refactoring"},"content":{"rendered":"<p>Inspired by <a href=\"http:\/\/cafe.elharo.com\/web\/refactoring-html\/objections-to-refactoring\/\">this post<\/a><br \/>\nI was recently handed the responsibility to maintain\/fix the code of my officemate who has already left for greener pastures. Its my first day with the code so I did a 2-3 hour refactoring session with around 4k LOC.<br \/>\nI finished trudging through 1k LOC , and would probably be finished with the rest of the code if my team lead didn&#8217;t tell me to fix a critical bug (on the code I was refactoring).<br \/>\nNote One: I haven&#8217;t been told that the code was my responsibility but I have a sixth sense for things like this, so I faced the hurdle head on.<br \/>\nNote Two: Writing Unit tests before refactoring, trust me on this, You know that feeling you have before an operation, well that&#8217;s how you feel before and , while and after you are testing your code.  No matter what you do you have that fear that maybe you didn&#8217;t do it right. So just write the test. Just do this for your sake.<br \/>\nI saw a few readily fixed errors around 10 and about 4 errors that took me awhile to understand and eventually fixed.<br \/>\nAround 2 hours after lunch we had a quick meeting because of the critical bug. The bug was a show stopper and at the meeting the code\/functions\/pages were formally given to me with a reminder:\u00a0 We need the bugs fixed today.<br \/>\nluckily, some of the the bugs I have already fixed and my refactoring allowed me to easily zero in on the offending code. I was able to fix it in less than 30 minutes.<br \/>\nAfter two hours, my team lead comes to me and ask warily,<br \/>\n&#8220;When are you going to finish fixing the bug?&#8221;<br \/>\n&#8220;Its Already fixed&#8221;<br \/>\n&#8220;The bug? you sure?&#8221;<br \/>\n&#8220;yep&#8221;<br \/>\nThe face of my team lead of disbelief\/suspicion\/slight admiration was priceless.<br \/>\nThis was all due to refactoring!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inspired by this post I was recently handed the responsibility to maintain\/fix the code of my officemate who has already left for greener pastures. Its my first day with the code so I did a 2-3 hour refactoring session with around 4k LOC. I finished trudging through 1k LOC , and would probably be finished &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/onthe8spot.com\/index.php\/2008\/06\/11\/on-refactoring\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;On Refactoring&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[18,72],"tags":[],"class_list":["post-94","post","type-post","status-publish","format-standard","hentry","category-coding","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/comments?post=94"}],"version-history":[{"count":0,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/posts\/94\/revisions"}],"wp:attachment":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/media?parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/categories?post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/tags?post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}