{"id":1086,"date":"2011-09-01T16:45:46","date_gmt":"2011-09-01T14:45:46","guid":{"rendered":"http:\/\/blog.eweibel.net\/?p=1086"},"modified":"2011-09-03T18:36:06","modified_gmt":"2011-09-03T16:36:06","slug":"grooming-your-code-base","status":"publish","type":"post","link":"https:\/\/blog.eweibel.net\/?p=1086","title":{"rendered":"Grooming your code base"},"content":{"rendered":"<p><a href=\"http:\/\/blog.eweibel.net\/wp-content\/uploads\/Fotolia_32643902_S1.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Fotolia_32643902_S\" border=\"0\" alt=\"Fotolia_32643902_S\" align=\"right\" src=\"http:\/\/blog.eweibel.net\/wp-content\/uploads\/Fotolia_32643902_S_thumb1.jpg\" width=\"344\" height=\"231\" \/><\/a>When you&#8217;re doing Test Driven Development (TDD), it&#8217;s in the process: Red-Green-Refactor. Refactoring doesn&#8217;t only mean to improve your new code, it is also important to make your existing code nicer.<\/p>\n<p>If you are a .NET Developer, then you should have the Visual Studio Add-on ReSharper. With this tool you get a marker bar which you see right hand side of your editor. On top of this marker bar you have a little square which shows the worst found item (error or warning). In our company we introduced recently this tool and we also introduced a new rule: &quot;Check-in only green code!&quot;    <br \/>This rule means that the square has to be green: no errors and no warnings are allowed in the current file.<\/p>\n<p><strong>Reality check<\/strong><\/p>\n<p>New tools and rules are nice, but we know all the pearl of wisdom &quot;A fool with a tool still a fool&quot;. You aren&#8217;t immediately a better software developer when you do TDD or using ReSharper. You have to know how to use it.    <br \/>All of us have in our code base a lot of legacy code, I mean really bad code and a remarkable collection of anti-patterns: god object, Swiss army knife, etc. and the ReSharper shows tons of warnings and errors. Now you can start to fix that code base, but be honest, that will be a project of its own. So, should we just resign or try to improve our code base?<\/p>\n<p><strong>Grooming your code base<\/strong><\/p>\n<p>When you know Scrum, then you know also the term grooming the product backlog. It is essential to make progress and to do the right things. The same goal we should have with our code base. We want to implement fast new features or change quickly with no risk breaking current behaviour.<br \/>The word risk here is critical: Don&#8217;t try to improve your code base at once, it&#8217;ll be a huge task (or even a project) and maybe you will fix things which will change in the near future. So, the right way is step by step or just following the boy scout rule: &quot;Leave your code better than you found it&quot;.     <br \/>If you doing TDD, then try during the refactor step to groom your code base. If not, then just clean up the code you touch and make it green (ReSharper marker bar). Don&#8217;t try to fix a whole class, just improve the needed methods.<\/p>\n<p><strong>Make the field a bit more green<\/strong><\/p>\n<p>In a classical brownfield project, there will be just bad legacy code. So it is important to plan some bigger refactoring tasks to make the code base better and decrease the technical debt. If the code coverage is very low then those tasks are a good start to increase the number of tests and the code coverage. But be aware of those tests: They could document wrong behaviour as correct.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you&#8217;re doing Test Driven Development (TDD), it&#8217;s in the process: Red-Green-Refactor. Refactoring doesn&#8217;t only mean to improve your new code, it is also important to make your existing code nicer. If you are a .NET Developer, then you should have the Visual Studio Add-on ReSharper. With this tool you get a marker bar which you see right hand side of your editor. On top of this marker bar you have a little square which shows the worst found item&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/blog.eweibel.net\/?p=1086\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13,17,5,14],"tags":[],"class_list":["post-1086","post","type-post","status-publish","format-standard","hentry","category-net","category-agile","category-good-practices","category-software-engineering"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/plOV9-hw","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":34,"url":"https:\/\/blog.eweibel.net\/?p=34","url_meta":{"origin":1086,"position":0},"title":"Are 100% code coverage reasonable?","author":"Patrick","date":"2. Mar 2009","format":false,"excerpt":"When you use a code coverage tool one of the first question is what is a good code coverage. Recently I listened to different podcasts (stackoverflow, scott hanselman) where they discuss this topic. I wasn't really surprised that there wasn't one unique opinion.One opinion was that 100% is a good\u2026","rel":"","context":"In &quot;Software architecture&quot;","block_context":{"text":"Software architecture","link":"https:\/\/blog.eweibel.net\/?cat=4"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":487,"url":"https:\/\/blog.eweibel.net\/?p=487","url_meta":{"origin":1086,"position":1},"title":"WordPress and SyntaxHighlighter","author":"Patrick","date":"8. Jan 2010","format":false,"excerpt":"I often post code in my blog posts, so the SyntaxHighlighter by is very useful. But there are several plug-ins for WordPress, the question is which one is the most comfortable and has the most configuration options: Google Syntax Highlighter for Wordpress Syntax Highlighter and Code Colorizer for Wordpress SyntaxHighlighter\u2026","rel":"","context":"In &quot;Good practices&quot;","block_context":{"text":"Good practices","link":"https:\/\/blog.eweibel.net\/?cat=5"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":281,"url":"https:\/\/blog.eweibel.net\/?p=281","url_meta":{"origin":1086,"position":2},"title":"VB-stereotype: Are there programmers who fit any more?","author":"Patrick","date":"29. Jun 2009","format":false,"excerpt":"I saw recently the talk \"Comparing Java Web Framworks\" on Parleys.com and when the speaker talks about JSF, he used the word \"VB\". I was a little bit surprised, that also in the java world the VB-stereotype is known. But what about is this VB-stereotype? Are there programmers who fit\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":942,"url":"https:\/\/blog.eweibel.net\/?p=942","url_meta":{"origin":1086,"position":3},"title":"Enums and inheritance in .Net","author":"Patrick","date":"9. Feb 2011","format":false,"excerpt":"In one of my current projects I had the following code (I simplified the code a bit): public string ConnectionString { get { switch(this.Importer) { case Importer.SqlServer: return \"Server=localhost;Database=Northwind\"; case Importer.SqlServerOleDb: return\"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind\"; default: throw new NotSupportedException( string.Format(\"Importer {0} is not supported yet.\", this.Importer)); } } } After running\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"CodeCoverage","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":8,"url":"https:\/\/blog.eweibel.net\/?p=8","url_meta":{"origin":1086,"position":4},"title":"Offline blogging tools","author":"Patrick","date":"28. Apr 2007","format":false,"excerpt":"There are several offline blogging tools, but two of them are interesting: Blogjet Windows Live Writer The Blogjet tool works very fine and I could also formatting my source-code. The microsoft-tool (currently it's for free) looks even better as the blogjet-tool and I think it has more or less the\u2026","rel":"","context":"In &quot;First experiencies&quot;","block_context":{"text":"First experiencies","link":"https:\/\/blog.eweibel.net\/?cat=7"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":890,"url":"https:\/\/blog.eweibel.net\/?p=890","url_meta":{"origin":1086,"position":5},"title":"Hunting performance issues","author":"Patrick","date":"17. Jan 2011","format":false,"excerpt":"Recently I received the lead over a performance optimization project for a software product.\u00a0 It isn't something extraordinary for a software architect, because as a software architect you have to know what's critical for a software system in a specific environment. Some of my co-workers may now smile a bit:\u2026","rel":"","context":"In &quot;Software architecture&quot;","block_context":{"text":"Software architecture","link":"https:\/\/blog.eweibel.net\/?cat=4"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/image_thumb9.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/1086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1086"}],"version-history":[{"count":11,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/1086\/revisions"}],"predecessor-version":[{"id":1104,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/1086\/revisions\/1104"}],"wp:attachment":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}