{"id":665,"date":"2015-12-28T22:19:05","date_gmt":"2015-12-28T22:19:05","guid":{"rendered":"http:\/\/www.pnambic.com\/home\/?p=665"},"modified":"2015-12-28T22:35:03","modified_gmt":"2015-12-28T22:35:03","slug":"the-power-of-visualization","status":"publish","type":"post","link":"http:\/\/www.pnambic.com\/home\/2015\/12\/28\/the-power-of-visualization\/","title":{"rendered":"The Power of Visualization"},"content":{"rendered":"<p>It\u2019s always interesting to use DepAn on a new body of code. \u00a0I\u2019m constantly amazed at the power of visualization to expose hidden details. \u00a0The human eye is well tuned to pick-up on subtle variations, and DepAn\u2019s rich rendering capabilities can help you see details that are invisible\u00a0when scanning source code. \u00a0In this case study, DepAn readily exposed some dead code in the the Guava libraries.<\/p>\n<p>During a recent demo of DepAn, I fairly randomly decided to perform a Java Analysis on the Guava libraries. \u00a0These are a collection of ~500 Java utility class that Google makes available. \u00a0\u00a0My expectation was that the Guava libraries would have some instructive examples of good code structure. These classes are very well w1ritten, and receive intense scrutiny from top-tier software engineers.<\/p>\n<p>There\u2019s a lot of code here, and even DepAn has challenges displaying the entire set of software elements in an illuminating manner. However, the package <tt>com.google.common.xml<\/tt> has only one class with 12 software elements (nodes). \u00a0With the default FRLayout, DepAn\u2019s View Editor generates a pretty little picture for our review:<\/p>\n<div id=\"attachment_669\" style=\"width: 510px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-frlayout.png\" rel=\"attachment wp-att-669\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-669\" class=\"wp-image-669\" src=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-frlayout.png?resize=500%2C486\" alt=\"Initial DepAn layout for the XML Escapers package\" width=\"500\" height=\"486\" srcset=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-frlayout.png?resize=300%2C292 300w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-frlayout.png?resize=768%2C747 768w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-frlayout.png?resize=1024%2C996 1024w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-frlayout.png?w=1334 1334w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-669\" class=\"wp-caption-text\">Initial DepAn layout for the XML Escapers package.<\/p><\/div>\n<p>In this little diagram, notice how the <tt>XmlEscaper.XML_ESCAPER<\/tt> node stands out as very distinctive. \u00a0Not only is the <tt>XML_ESCAPER<\/tt> node yellow, it is also the only circle (i.e. member field) that is yellow. \u00a0That yellow indicates that <tt>XML_ESCAPER<\/tt> has an in-degree of 2, and other similar fields (<tt>XML_CONTENT_ESCAPER<\/tt> and <tt>XML_ATTRIBUTE_ESCAPER<\/tt>) have a in-degree of three.<\/p>\n<div style=\"clear: both;\"><\/div>\n<p>With a little re-arrangement, the lack of parallel structure is more obvious:<\/p>\n<div id=\"attachment_670\" style=\"width: 510px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-manual.png\" rel=\"attachment wp-att-670\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-670\" class=\"wp-image-670\" src=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-manual.png?resize=500%2C486\" alt=\"Manual DepAn layout for the XML Escapers package\" width=\"500\" height=\"486\" srcset=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-manual.png?resize=300%2C292 300w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-manual.png?resize=768%2C747 768w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-manual.png?resize=1024%2C996 1024w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/xml-manual.png?w=1334 1334w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-670\" class=\"wp-caption-text\">Manual DepAn layout for the XML Escapers package, showing the lack of parallelism for the different XML escaper instances.<\/p><\/div>\n<p>For some reason, <tt>XML_ESCAPER<\/tt> is lacking the <tt>xmlEscaper()<\/tt> method (i.e. rounded squares) that would parallel the structure of the other escaper fields. A little investigation into the source code reveals that <tt>XML_ESCAPER<\/tt> is unused internally and inaccessible externally. \u00a0It is dead code.<\/p>\n<p>A\u00a0<a href=\"https:\/\/github.com\/google\/guava\/pull\/2344\" target=\"_blank\">pull-request<\/a> to remove field was been sent to the Guava maintainers, and produced this curious response:<\/p>\n<blockquote><p><em>So this is actually some deprecated code that we have internally, and is publicly accessible for our internal users (the method is deprecated).<\/em><\/p>\n<p><em>Usually we&#8217;re able to strip out that stuff, but since it&#8217;s being constructed in a static block, it&#8217;s a little more difficult. Since it&#8217;s not hurting anything, I&#8217;m inclined to leave it as-is.<\/em><\/p><\/blockquote>\n<div style=\"clear: both;\"><\/div>\n<p>Once again, DepAn\u2019s ability to visualize complex interdependencies demonstrates its effectiveness at software analysis. \u00a0The git logs suggest that Escapers have had a mixed history in the Guava libraries, and they were added and removed around release 12.0. \u00a0During this process, it appears that an old bit of legacy code was left in but abandoned. \u00a0The abandoned code meant that some of the dependencies were inconsistent, and DepAn makes it simple for us mortals to see these inconsistencies.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s always interesting to use DepAn on a new body of code. \u00a0I\u2019m constantly amazed at the power of visualization to expose hidden details. \u00a0The human eye is well tuned to pick-up on subtle variations, and DepAn\u2019s rich rendering capabilities can help you see details that are invisible\u00a0when scanning source code. \u00a0In this case study,<a class=\"moretag\" href=\"http:\/\/www.pnambic.com\/home\/2015\/12\/28\/the-power-of-visualization\/\"> [&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":677,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[31,23],"tags":[33,32],"class_list":["post-665","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-reports","tag-case-study","tag-depan"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/12\/depan-icon-60x60.png?fit=60%2C60","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6YqIw-aJ","_links":{"self":[{"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/posts\/665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/comments?post=665"}],"version-history":[{"count":5,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":678,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/posts\/665\/revisions\/678"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/media\/677"}],"wp:attachment":[{"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/media?parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/categories?post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/tags?post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}