{"id":129,"date":"2012-03-26T21:05:04","date_gmt":"2012-03-26T20:05:04","guid":{"rendered":"http:\/\/dev.qualilogy.com\/en\/?p=129"},"modified":"2013-01-04T21:05:48","modified_gmt":"2013-01-04T20:05:48","slug":"critical-city","status":"publish","type":"post","link":"http:\/\/qualilogy.com\/en\/critical-city\/","title":{"rendered":"Critical City"},"content":{"rendered":"<p>I am still playing with the City Model plugin for Sonar made by eXcentia.<\/p>\n<p>For those who missed the previous episodes, you can find them here: <a title=\"City Model\" href=\"http:\/\/qualilogy.com\/en\/city-model\" target=\"_blank\">City Model<\/a>, <a title=\"City Model - Nouvelle version\" href=\"http:\/\/qualilogy.com\/en\/city-model-new-release\" target=\"_blank\">City Model \u2013 New release<\/a>, <a href=\"http:\/\/qualilogy.com\/en\/the-abc-metric\" target=\"_blank\">The ABC metric<\/a>.<\/p>\n<p>This plugin is really fun. And everyone finds fantastic a visual representation of the code in the form of a city. Going to the essential is important when you regularly assess the quality of applications.<\/p>\n<p><!--more--><\/p>\n<p>So I thought to a few simple but common cases, where its use will prove invaluable. This will also give me the opportunity to demonstrate how easy it is to set up.<\/p>\n<p><strong>Critical City<\/strong><\/p>\n<p>A customer asks me an assessment of two applications. I dig a bit to know more precisely the &#8216;why&#8217; of this audit. There may be several reasons, and I need to know a little more in order to accurately answer his request.<\/p>\n<p>For example: he wants to outsource these two quite old applications, and before making a call for tenders, he would like to know what is their quality level. It&#8217;s actually a good idea, which will allow him to better judge the offers that he will be presented and precise maintenance costs. Currently, many providers are willing to do anything to get a contract. Estimate the technical debt on these applications will allow him to reject &#8216;low cost&#8217;, unrealistic offers.<\/p>\n<p>Another case: the head of a development center is asked to take in charge the maintenance of an application. A rather complex one, at first sight: hundreds of thousands of lines of code, .NET proprietary frameworks, no documentation, etc. Enough to be a little bit suspicious. He would like to get some visibility on the quality of this application and the effort to be done before accepting. Or to get some information and good reasons to justify a refusal.<\/p>\n<p>In fact, the customer whom I speak had some problems with one of these &#8216;low cost&#8217; providers who develop these two applications. Delays,  budgets exceeded, many bugs and unhappy users, some crisis situations, the image of the IT diminished &#8230; In fact, he is looking for some reasons to explain to his provider he no longer wants him.<\/p>\n<p>Thus, I know how to go to the essential. Critical violations. Show him some good old critical bugs.<strong><br \/>\n<\/strong><\/p>\n<p>I set a Sonar code analysis from Jenkins. Very simple: <a href=\"http:\/\/qualilogy.com\/en\/sonar-jenkins-plugin\" target=\"_blank\">Sonar \u2013 Jenkins plugin<\/a>. The analysis was quickly done.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_SonarAdmin_Login.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1417\" title=\"Qual_SonarAdmin_Login\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_SonarAdmin_Login.jpg\" alt=\"\" width=\"137\" height=\"33\" \/><\/a>Then, I launched my favorite Sonar dashboard, as an Admin :<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModelTop_Add.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1418\" title=\"Qual_Sonar_CityModelTop_Add\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModelTop_Add.jpg\" alt=\"\" width=\"281\" height=\"94\" \/><\/a>I entered into the configuration page of the widgets and I added a City Model Top widget of eXcentia.<\/p>\n<p>Then, I changed the default values with the following parameters:<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModelTop_params.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1420\" title=\"Qual_Sonar_CityModelTop_params\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModelTop_params.jpg\" alt=\"\" width=\"583\" height=\"177\" \/><\/a><\/p>\n<ul>\n<li>title : Blocker<\/li>\n<li>topListLength : 5. I want to see the 5 most important &#8216;Blocker&#8217; violations&#8217;.<\/li>\n<li>formula : {blocker_violations}.<\/li>\n<\/ul>\n<p>In the &#8216;formula&#8217; field, the Sonar metric corresponding to the highest violations, those that present as most risk for the users. Those that demonstrate that the outsourcer is producing code of the worst possible quality.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel_Add.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1422\" title=\"Qual_Sonar_CityModel_Add\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel_Add.jpg\" alt=\"\" width=\"282\" height=\"94\" \/><\/a> Then I add the widget City Model and change its settings.<br \/>\nThe first field &#8216;heightExp&#8217; contains a formula to define the height of each building depending on the size of each class, expressed in number of lines of code (LOC).<\/p>\n<p>This measure uses a logarithmic function to avoid this size to grow too fast and therefore have a difference that would cause some &#8216;skyscrapers&#8217; to be out of the visual field and other buildings to appear too tiny.<\/p>\n<p>I will modify this formula for a different metric: the number of &#8216;violations&#8217; of good practices, that is to say the number of defects encountered in the code.<\/p>\n<address>Math.pow(Math.E &#8211; 0.25, Math.log({violations}))<\/address>\n<address> <\/address>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel_params.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1435\" title=\"Qual_Sonar_CityModel_params\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel_params.jpg\" alt=\"\" width=\"583\" height=\"178\" \/><\/a>The other parameters are:<\/p>\n<ul>\n<li>title : Blocker<\/li>\n<li>colorExp : num2col({blocker_violations}, 0, 1).<\/li>\n<li>widthExp : {functions}.<\/li>\n<\/ul>\n<p>I want the buildings representing java classes to be displayed in red when there exists at least one critical &#8216;Blocker&#8217; violation. So the formula &#8216;colorExp&#8217; admits a very narrow range of values\u200b\u200b: green for 0 &#8216;blocker&#8217;, red when there is at least 1 blocking defect, measured by the metric {blocker_violations}.<\/p>\n<p>The width of each building will be calculated according to the number of methods with the metric {functions}.<\/p>\n<p>Save the settings. Here is what looks like my &#8216;critical City&#8217;:<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1437\" title=\"Qual_Sonar_CityModel1\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel1.jpg\" alt=\"\" width=\"583\" height=\"463\" \/><\/a><\/p>\n<p>Remember that you can zoom in the representation and rotate it horizontally or vertically, which will allow to identify more &#8216;Blocker&#8217; classes.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1438\" title=\"Qual_Sonar_CityModel2\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel2.jpg\" alt=\"\" width=\"367\" height=\"363\" \/><\/a>This large green tower on the right has many defects but none critical. Other classes, even with a larger number of methods, have at least one blocking violation.<\/p>\n<p>It is imperative to correct these defects before the application goes to test phase or, a fortiori, is installed in a production environment.<\/p>\n<p>Navigating within the 3D modelization, one can encounter classes that would otherwise be undetectable due to their small size, in number of lines of code or methods or complexity, but which nevertheless have a blocking bug.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel31.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1443\" title=\"Qual_Sonar_CityModel3\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel31.jpg\" alt=\"\" width=\"564\" height=\"425\" \/><\/a><\/p>\n<p>We can see in the lower left corner three small classes with only two methods and at least a blocking defect.<\/p>\n<p>Now we also want to identify classes with a high number of critical or major defects. Here are the rules I agreed with the client:<\/p>\n<ol>\n<li>One class is red if it has at least one &#8216;Blocker&#8217; violation<\/li>\n<li>One class is red if it has at least 4 &#8216;Critical&#8217; violations. Otherwise, its color will go gradually from green to red depending on a scale of 1 to 4 of these violations.<\/li>\n<li>Otherwise, the color of the class will be defined according to the number of &#8216;Major&#8217; defects on a scale of 1 to 100.<\/li>\n<\/ol>\n<p>If I put these three rules on a scale of 1 to 100:<\/p>\n<ul>\n<li>A blocking violation = 100.<\/li>\n<li>4 critical violations = 100, 3 critical violations = 75, 2 critical violations = 50 et 1 critical violation = 25.<\/li>\n<li>Major violations are measured without multiplicative factor.<\/li>\n<\/ul>\n<p>And final rule, the color of the building will be defined according to the highest of these values\u200b\u200b. For example:<\/p>\n<ul>\n<li>A class with 30 major violations without blocking or critical violation will have a color (from green to red) equal to 30 on a scale of 1 to 100.<\/li>\n<li>A class with 2 critical violations without blocking or major violation will have a color equal to 50 or 2 violations x 25.<\/li>\n<li>A class with 2 critical violations and 30 major violations will be worth 50 (the highest of the two values\u200b\u200b).<\/li>\n<li>A class with 2 critical violations and 60 major violations will be worth 60.<\/li>\n<\/ul>\n<p>And here the formula corresponding to these rules:<\/p>\n<address>num2col(Math.max(({blocker_violations}*100), ({critical_violations}*25), {major_violations}), 0, 100)<\/address>\n<address> <\/address>\n<p>And the result:<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel41.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1448\" title=\"Qual_Sonar_CityModel4\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel41.jpg\" alt=\"\" width=\"557\" height=\"372\" \/><\/a><\/p>\n<div id=\"gt-res-content\">\n<p dir=\"ltr\">I customized my dashboard with three City Model Top lists for these three categories of defects:<\/p>\n<\/div>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1449\" title=\"Qual_Sonar_CityModel5\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2012\/03\/Qual_Sonar_CityModel5.jpg\" alt=\"\" width=\"1173\" height=\"465\" \/><\/a><\/p>\n<p>Some classes with &#8216;Blockers&#8217; also have a high number of major defects.<\/p>\n<h3><strong>Conclusion<\/strong><\/h3>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">I<\/span><span class=\"hps\">f you are<\/span> <span class=\"hps\">an outsourcer<\/span><span>, I<\/span> <span class=\"hps\">think you could<\/span> <span class=\"hps\">take advantage of these<\/span> <span class=\"hps\">plugins<\/span><span>.<\/span> <span class=\"hps\">For example<\/span><span>,<\/span> <span class=\"hps\">let&#8217;s imagine you <\/span><span class=\"hps\">answer a call<\/span> <span class=\"hps\">for tenders<\/span><span>:<\/span><\/span><\/p>\n<ul>\n<li><span class=\"hps\">Arrange<\/span> <span class=\"hps\">a meeting<\/span> <span class=\"hps\">with<\/span> <span class=\"hps\">your potential customer<\/span> <span class=\"hps\">and ask<\/span> <span class=\"hps\">him<\/span> <span class=\"hps\">to prepare<\/span> <span class=\"hps\">some code extraction from<\/span> <span class=\"hps\">the application<\/span> <span class=\"hps\">that he<\/span> <span class=\"hps\">wishes to<\/span> <span class=\"hps\">outsource<\/span><span>,<\/span> <span class=\"hps\">if possible<\/span> <span class=\"hps\">with<\/span> <span class=\"hps\">the most<\/span> <span class=\"hps\">defects<\/span><span>.<\/span><\/li>\n<li><span class=\"hps\">Analyze<\/span> <span class=\"hps\">this code live during<\/span> <span class=\"hps\">the meeting<\/span> <span class=\"hps\">and show<\/span> <span class=\"hps\">him<\/span> <span class=\"hps\">the results<\/span><span>.<\/span> <span class=\"hps\">You can play with<\/span> <span class=\"hps\">the settings according to the<\/span> <span class=\"hps\">&#8216;top<\/span> <span class=\"hps\">10&#8242;<\/span> <span class=\"hps\">of each category of violations or<\/span> <span class=\"hps\">whether you<\/span> <span class=\"hps\">want<\/span> <span class=\"hps\">a city<\/span> <span class=\"hps\">more or less<\/span> <span class=\"hps\">&#8216;red&#8217;<\/span><span>.<\/span><\/li>\n<li><span class=\"hps\">You can estimate<\/span> <span class=\"hps\">with the customer<\/span> <span class=\"hps\">the effort of<\/span> <span class=\"hps\">correction<\/span> <span class=\"hps\">of these defects<\/span> <span class=\"hps\">or<\/span> <span class=\"hps\">propose a refactoring<\/span> <span class=\"hps\">of these classes<\/span><span>.<\/span><\/li>\n<li>\n<div dir=\"ltr\"><span id=\"result_box\" lang=\"en\"><span class=\"hps\">You can<\/span> <span class=\"hps\">ask the client<\/span> <span class=\"hps\">how this extraction<\/span> is<span class=\"hps\"> representative<\/span> <span class=\"hps\">of the whole code<\/span> <span class=\"hps\">and<\/span> <span class=\"hps\">then<\/span> <span class=\"hps\">assess the overall effort<\/span> <span class=\"hps\">of<\/span> <span class=\"hps\">the maintenance operation<\/span><span>.<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">Your customer<\/span> <span class=\"hps\">will certainly be<\/span> <span class=\"hps\">impressed<\/span><span>.<\/span> <span class=\"hps\">Moreover<\/span><span>,<\/span> <span class=\"hps\">the measurements obtained<\/span> <span class=\"hps\">are a<\/span> <span class=\"hps\">basis of objective information<\/span> <span class=\"hps\">that avoid<\/span> <span class=\"hps\">the<\/span> <span class=\"hps\">typical<\/span> <span class=\"hps atn\">&#8216;<\/span><span>customer-provider<\/span><span>&#8216;<\/span> <\/span><span id=\"result_box\" lang=\"en\"><span class=\"hps\">confrontation<\/span> <\/span><span id=\"result_box\" lang=\"en\"><span class=\"hps\">in favor of a<\/span> <span class=\"hps\">more<\/span> <span class=\"hps\">constructive<\/span> <span class=\"hps\">and realistic<\/span><\/span><span id=\"result_box\" lang=\"en\"><span class=\"hps\"> dialogue<\/span><\/span><span id=\"result_box\" lang=\"en\"><span>.<\/span> <span class=\"hps\">Your customer<\/span> <span class=\"hps\">will remember<\/span> <span class=\"hps\">it when choosing<\/span> <span class=\"hps\">the<\/span> <span class=\"hps\">provider to whom<\/span> <span class=\"hps\">it will entrust<\/span> <span class=\"hps\">its applications<\/span><span>.<\/span><\/span><\/p>\n<p><span class=\"hps\">Another example<\/span><span>, use these<\/span> <span class=\"hps\">plugins<\/span> <span class=\"hps\">as part of<\/span> <span class=\"hps\">a<\/span> <span class=\"hps\">Quality<\/span> <span class=\"hps\">Gate<\/span><span>:<\/span><\/p>\n<ul>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">Scan regularly your<\/span> <span class=\"hps\">code<\/span> <span class=\"hps\">with<\/span> <span class=\"hps\">these plugins.<\/span><\/span><\/li>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">Correct<\/span> <span class=\"hps\">immediately any<\/span> <span class=\"hps\">red class<\/span><span>.<\/span><\/span><\/li>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">Perform a<\/span> <span class=\"hps\">final<\/span> <span class=\"hps\">analysis<\/span> <span class=\"hps\">before delivering<\/span> <span class=\"hps\">a new<\/span> <span class=\"hps\">version of the application<\/span> <span class=\"hps\">or<\/span> <span class=\"hps\">its modules<\/span> <span class=\"hps\">and show<\/span> <span class=\"hps\">the<\/span> <span class=\"hps\">Sonar<\/span> <span class=\"hps\">dashboard<\/span> <span class=\"hps\">with<\/span> <span class=\"hps\">the<\/span> <span class=\"hps\">corresponding<\/span> <span class=\"hps\">city<\/span><span> to your customer.<\/span><\/span><\/li>\n<li><span id=\"result_box\" lang=\"en\"> <span class=\"hps\">You can afford<\/span> <span class=\"hps\">a few<\/span> <span class=\"hps\">major flaws<\/span> im case of <span class=\"hps\">emergency<\/span> <span class=\"hps\">permits,<\/span> <span class=\"hps\">provided that<\/span> <span class=\"hps\">you agree to<\/span> <span class=\"hps\">correct them<\/span> <span class=\"hps\">later<\/span><span>.<\/span><\/span><\/li>\n<\/ul>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">In any case<\/span><span>,<\/span> <span class=\"hps\">I recommend that you<\/span> <span class=\"hps\">use these<\/span> <span class=\"hps\">plugins for<\/span> <span class=\"hps\">Sonar<\/span> <span class=\"hps\">before your<\/span> <span class=\"hps\">customer<\/span> <span class=\"hps\">discovers them<\/span><span>.<\/span> <span class=\"hps\">Or<\/span> <span class=\"hps\">that someone shows<\/span> <span class=\"hps\">him<\/span><span>.<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am still playing with the City Model plugin for Sonar made by eXcentia. For those who missed the previous episodes, you can find them here: City Model, City Model \u2013 New release, The ABC metric. This plugin is really fun. And everyone finds fantastic a visual representation of the code in the form of [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-sonar-360"],"_links":{"self":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/129"}],"collection":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":1,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":130,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/129\/revisions\/130"}],"wp:attachment":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}