{"id":761,"date":"2016-09-07T18:12:43","date_gmt":"2016-09-07T18:12:43","guid":{"rendered":"http:\/\/www.pnambic.com\/home\/?p=761"},"modified":"2016-09-07T18:12:43","modified_gmt":"2016-09-07T18:12:43","slug":"case-study-checking-for-side-effects-with-depan-filters","status":"publish","type":"post","link":"http:\/\/www.pnambic.com\/home\/2016\/09\/07\/case-study-checking-for-side-effects-with-depan-filters\/","title":{"rendered":"Case Study: Checking for Side-effects with DepAn Filters"},"content":{"rendered":"<p>One of the recurring challenges in software maintenance is unexpected interactions between components. Although architectural boundaries should isolate components, large systems often have unexpected couplings between components. In a richly featured application, a full investigation can be prohibitive. This inability to ensure isolation can impede necessary\u00a0changes.<\/p>\n<p>A bug fix in DepAn demonstrates an effective strategy to visualize dependents and to ensure isolation between different components. The most natural fix for a rendering bug included a risk of unforeseen interactions\u00a0between the node rendering and the node tree components. With\u00a0DepAn\u2019s filter and collapse mechanisms, it was straightforward to show\u00a0that no troublesome interdependencies were present.<\/p>\n<div id=\"attachment_765\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Collapse_400x227.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-765\" class=\"size-medium wp-image-765\" src=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Collapse_400x227.png?resize=300%2C170\" alt=\"With call-chains collapsed, isolation among the components is transparent.\" width=\"300\" height=\"170\" srcset=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Collapse_400x227.png?resize=300%2C170 300w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Collapse_400x227.png?w=400 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-765\" class=\"wp-caption-text\">With call-chains collapsed, isolation among the components is transparent.<\/p><\/div>\n<p>The dependency analysis strategy was simple and effective:<\/p>\n<ol>\n<li>Select the nodes for your methods of interest,<\/li>\n<li>Using filters, compute the entire call tree for these nodes,<\/li>\n<li>Collapse the result based on call relations,<\/li>\n<li>Expand the\u00a0collapse roots, incrementally exposing dependencies and side effects.<\/li>\n<\/ol>\n<p>In just a few minutes, I\u00a0was able to confirm safety for a change that involved dozens of interdependent components.<\/p>\n<h3>Problem details<\/h3>\n<p>The initial rendering of a reopened View document (.dvi file) was not using\u00a0the saved collapse-state information. As a result, these reopened documents were cluttered and confusing. One\u00a0method, <tt>collapseChanged()<\/tt>, did render collapse-state changes properly, but only for already opened document. Although the <tt>collapseChanged()<\/tt> method updated several GUI features, the reuse of a <tt>handleCollapseRendering()<\/tt> method within the <tt>prepareView()<\/tt> method appeared to be a natural fix for this problem.<\/p>\n<p>As tempting as this is, the separation between the diagram renderer and the node tree view was suspect. The essential question is whether the node tree handling or dirty-state handling interacts with collapse-state rendering process. These components evolved from a more monolithic architecture where the underlying data structures had multiple access paths. Do the other calls from within the <tt>collapseChanged()<\/tt> method alter collapse-state or rendering-state in an undesirable manner?<\/p>\n<p>In order to address this question, I used DepAn to display the entire call tree for the <tt>collapseChanged()<\/tt> method. In just a\u00a0few seconds, I was able to see all methods that are reached from <tt>collapseChanged()<\/tt>. More importantly, is was clear that the three call trees were independent of each other. DepAn made it obvious that behaviors from the <tt>updateExposedGraph()<\/tt> call were independent from actions of the <tt>handleCollapseRendering()<\/tt> call.<\/p>\n<h3>Analysis Details<\/h3>\n<p>The use of DepAn to determine that the side-effects from <tt>collapseChanged()<\/tt> were independent from <tt>handleCollapseRendering()<\/tt> was quite straightforward.<\/p>\n<ol>\n<li>Using the GraphEditor, open the analysis file (.dgi) and select the <tt>collapseChanged()<\/tt> method.<\/li>\n<li>Create a ViewEditor for this one Java element.<\/li>\n<li>Using the NodeFilter view, select the Call Closure filter.<\/li>\n<li>Computing the results\u00a0reveals 42 nodes (methods) in these call chains.<\/li>\n<li>Open another ViewEditor for the computed results, using a Radial layout over Java Uses relation set.<\/li>\n<\/ol>\n<div id=\"attachment_763\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Closure_crop.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-763\" class=\"size-medium wp-image-763\" src=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Closure_400x323.png?resize=300%2C242\" alt=\"Call closure diagram for collapseChanged() method.\" width=\"300\" height=\"242\" srcset=\"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Closure_400x323.png?resize=300%2C242 300w, https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2016\/09\/collapseChanged-Calls-Closure_400x323.png?w=400 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-763\" class=\"wp-caption-text\">Call closure diagram for collapseChanged() method.<\/p><\/div>\n<p>A little rearranging shows that the call tree from <tt>updateExposedGraph()<\/tt> is completely independent from the methods in the <tt>handleCollapseRendering()<\/tt> call tree. This provides great confidence that these methods do not interact with each other\u2019s side-effects.<\/p>\n<p>Although the rearranged call graph for <tt>collapseChange()<\/tt> is compelling, the 42 nodes are a bit too cluttered to be totally convinced. Using the collapse feature, the independence of these methods becomes stark.<\/p>\n<p>The original call tree diagram is dramatically simplified by using Collapse Hierarchy on the Uses relation set in the NodeFilter view. Initially, everything collapses into the <tt>collapseChanged()<\/tt> node. By expanding that node, and the Java generated accessor methods, the call trees for <tt>updateExposedGraph()<\/tt>, <tt>handleCollapseRendering()<\/tt> and <tt>markDirty()<\/tt> are summarized as individual\u00a0nodes. As seen in the earlier diagram, the independence\u00a0of the call trees is quite striking and transparent. There are no Use edges between any of these collapsed node.<\/p>\n<h3>Conclusion<\/h3>\n<p>Validating that components are isolated is critically\u00a0important when identifying solutions. When components have significant interdependencies, simple strategies may not work. However, complex strategies have other costs and should be avoided unless they are required. The selection of a change strategy is an important engineering decision. DepAn\u2019s filtering and collapse tools provide an effective way to visualize dependencies and to validate cost effective engineering solutions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the recurring challenges in software maintenance is unexpected interactions between components. Although architectural boundaries should isolate components, large systems often have unexpected couplings between components. In a richly featured application, a full investigation can be prohibitive. This inability to ensure isolation can impede necessary\u00a0changes. A bug fix in DepAn demonstrates an effective strategy<a class=\"moretag\" href=\"http:\/\/www.pnambic.com\/home\/2016\/09\/07\/case-study-checking-for-side-effects-with-depan-filters\/\"> [&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":329,"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":[28,31],"tags":[],"class_list":["post-761","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-case-history","category-news"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.pnambic.com\/home\/wp-content\/uploads\/2015\/11\/pnambic_favicon.jpg?fit=60%2C55","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6YqIw-ch","_links":{"self":[{"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/posts\/761","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=761"}],"version-history":[{"count":5,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/posts\/761\/revisions"}],"predecessor-version":[{"id":771,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/posts\/761\/revisions\/771"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/media\/329"}],"wp:attachment":[{"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/media?parent=761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/categories?post=761"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pnambic.com\/home\/wp-json\/wp\/v2\/tags?post=761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}