tag:blogger.com,1999:blog-1347211857845165663.post9051340254080542902..comments2023-07-01T10:18:05.490-05:00Comments on mike.mainguy: When to refactor codeMike Mainguyhttp://www.blogger.com/profile/00301743167330794774noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-1347211857845165663.post-74116773165590881852015-09-15T07:52:43.441-05:002015-09-15T07:52:43.441-05:00Note to all, the 11 items in the checklist was a d...Note to all, the 11 items in the checklist was a deliberate attempt at irony...perhaps too subtle even for me on rereading.Mike Mainguyhttps://www.blogger.com/profile/00301743167330794774noreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-37169439854013139652013-06-15T18:40:36.189-05:002013-06-15T18:40:36.189-05:00Excellent work. Thank you for the time you took ...Excellent work. Thank you for the time you took to share your knowledge! +1 for @dylans suggested inversion to positive.brian.danthttps://www.blogger.com/profile/07059771775627430784noreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-37136263434456969342013-05-19T21:55:13.393-05:002013-05-19T21:55:13.393-05:00"#2 doesn't say anything about the code. ..."#2 doesn't say anything about the code. But it says something about your qualifications to refactor it and, thus, I think is a valid consideration."<br /><br /><br />In that case the question is backwards.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-6879939995035511762013-05-18T09:04:30.561-05:002013-05-18T09:04:30.561-05:00@Dylan, I struggled with this. In retrospect I th...@Dylan, I struggled with this. In retrospect I think rewording as you suggested might be a better approach. Frankly I'm still a little on the fence, but appreciate the feedback!Mike Mainguyhttps://www.blogger.com/profile/00301743167330794774noreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-88073708185971989402013-05-17T16:45:50.362-05:002013-05-17T16:45:50.362-05:00I think your list is effective when you're tal...I think your list is effective when you're talking about medium to large refactorings. For small refactorings I'd say the only criteria is: Is there something you can do to improve the code? Yes? Do it! (disclaimer: full testing should be available, and maybe not do it the day before your release...)Kenneth Truyershttp://www.kenneth-truyers.netnoreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-26033332544762929272013-05-17T08:57:26.888-05:002013-05-17T08:57:26.888-05:00#2 doesn't say anything about the code. But i...#2 doesn't say anything about the code. But it says something about your qualifications to refactor it and, thus, I think is a valid consideration.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-56844339986410266122013-05-17T08:27:40.458-05:002013-05-17T08:27:40.458-05:00Great list. As with other commenters, I'm not ...Great list. As with other commenters, I'm not sure what #2 has to do with a specific piece of code... <br /><br />I also found it much easier to grasp the significance of the questions by inverting them, so that you're counting "yes" answers instead of "no" answers - which makes the list read more like:<br /><br />1) Is the cyclomatic complexity of the function above 5?<br />2) Are there missing tests for execution paths through the function?<br />3) Are existing test cases failing or broken?<br />4) Would explaining this function to me take more than a minute?<br />5) Five minutes?<br />6) Ten minutes?<br />7) Does the function - including comments - include more than 100 lines of code?<br />8) Are your developers still worried about bugs even after visually inspecting the code?<br />9) Is this function used in more than one place?<br />10) Do you have a verified performance problem (time/memory/CPU) with this code?Dylan Beattiehttps://www.blogger.com/profile/06437484057047871824noreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-15181507304437517992013-05-17T08:14:18.586-05:002013-05-17T08:14:18.586-05:00Great article. Cyclomatic complexity is a great to...Great article. Cyclomatic complexity is a great tool; it snuffs out both obvious and subtle devils! On the less analytic side, a rule of thumb for me is that if I can quickly and obviously see a need or a WAY to improve the code (function is can't be seen on one screen, can't see or understand all the branches / cases simultaneously, code tiling, etc.) it may be a candidate.Anonymoushttps://www.blogger.com/profile/02179699059428652428noreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-71378460095259936142013-05-17T03:48:46.955-05:002013-05-17T03:48:46.955-05:00Thanks, great article, I enjoyed it!
Don't mi...Thanks, great article, I enjoyed it!<br /><br />Don't mind the usual negative assholes.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-61623214202365420572013-05-17T03:36:50.725-05:002013-05-17T03:36:50.725-05:0012. Do I know the difference between "its&quo...12. Do I know the difference between "its" and "it's", and how annoying it is to many readers when I get it wrong?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-50027522701585684512013-05-17T02:26:11.745-05:002013-05-17T02:26:11.745-05:00Red, Green, Refactor... #TDDRed, Green, Refactor... #TDDAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-69685409585130984252013-05-16T12:19:47.641-05:002013-05-16T12:19:47.641-05:00I think that's why the 10 item checklist has 1...I think that's why the 10 item checklist has 11 items.Cory Kilgerhttps://www.blogger.com/profile/02633643730015317681noreply@blogger.comtag:blogger.com,1999:blog-1347211857845165663.post-41703615335236437682013-05-16T11:07:26.240-05:002013-05-16T11:07:26.240-05:00What does #2 have to do with whether a piece of co...What does #2 have to do with whether a piece of code is suitable for refactoring?Anonymousnoreply@blogger.com