{"id":562,"date":"2010-01-20T14:24:31","date_gmt":"2010-01-20T05:24:31","guid":{"rendered":"http:\/\/www.codedojo.com\/?p=562"},"modified":"2010-01-20T14:24:31","modified_gmt":"2010-01-20T05:24:31","slug":"useful-tools-refactoring-code-the-easy-way","status":"publish","type":"post","link":"https:\/\/www.codedojo.com\/?p=562","title":{"rendered":"Useful Tools: Refactoring code the easy way"},"content":{"rendered":"<p>Everybody has their own favorite development IDE.\u00a0 Some love Eclipse, others adore Xcode, and a few old school types swear by simple text editors and shell scripts.  (Hi Pov!)<\/p>\n<p>While cleaning up the Dink source I&#8217;ve been really getting my money&#8217;s worth out of Visual C++ with the <a href=\"http:\/\/www.wholetomato.com\/\">Visual Assist<\/a> add-on.<\/p>\n<h2><strong>Safely renaming variables<\/strong><\/h2>\n<p>One of the more useful features of Visual Assist is intelligently renaming a variable or function name across a project.<\/p>\n<p>As an example, I could safely rename the horribly named global int variable &#8220;mode&#8221; to &#8220;g_gameMode&#8221; .\u00a0  It&#8217;s smart enough to ignore locally defined &#8220;mode&#8221; variables or the word mode used in other contexts, such as functions or comments.<\/p>\n<p>With its new name it will be safer use Search and Replace to make it GetGlobals-&gt;GetMode() later or something if I want to later.<\/p>\n<h2><strong>Renaming library functions across multiple projects<\/strong><\/h2>\n<p><a href=\"http:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-563\" title=\"refactor_1\" src=\"https:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_1-255x300.png\" alt=\"\" width=\"255\" height=\"300\" srcset=\"https:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_1-255x300.png 255w, https:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_1.png 636w\" sizes=\"auto, (max-width: 255px) 100vw, 255px\" \/><\/a><\/p>\n<p>Let&#8217;s say for some reason you wanted to rename RTFont::Load to RTFont::LoadTrueType but you don&#8217;t want to break things in old projects.<\/p>\n<p>Here is a trick to safely rename things across multiple projects:<\/p>\n<ul>\n<li>Create a new solution called AllProjects and add each existing project to it<\/li>\n<li>Use Visual Assist&#8217;s rename or other refactoring tools to modify them all at once<\/li>\n<li>Keep the solution around for anytime you need to globally modify things<\/li>\n<\/ul>\n<p><a href=\"http:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-564\" title=\"refactor_2\" src=\"https:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_2-300x218.png\" alt=\"\" width=\"300\" height=\"218\" srcset=\"https:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_2-300x218.png 300w, https:\/\/www.codedojo.com\/wp-content\/uploads\/2010\/01\/refactor_2.png 936w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>When you have tools to make normally monotonous chores a breeze, you&#8217;re that much more likely to actually do it!<\/p>\n<p>If your IDE can&#8217;t do stuff like that it might be time to find one that can.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everybody has their own favorite development IDE.\u00a0 Some love Eclipse, others adore Xcode, and a few old school types swear by simple text editors and shell scripts. (Hi Pov!) While cleaning up the Dink source I&#8217;ve been really getting my money&#8217;s worth out of Visual C++ with the Visual Assist add-on. Safely renaming variables One [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[],"class_list":["post-562","post","type-post","status-publish","format-standard","hentry","category-development","category-tech-tips"],"_links":{"self":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts\/562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=562"}],"version-history":[{"count":8,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts\/562\/revisions"}],"predecessor-version":[{"id":572,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts\/562\/revisions\/572"}],"wp:attachment":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}