{"id":368,"date":"2012-10-31T20:40:02","date_gmt":"2012-10-31T20:40:02","guid":{"rendered":"http:\/\/www.lexicalscope.com\/blog\/?p=368"},"modified":"2012-10-31T22:07:10","modified_gmt":"2012-10-31T22:07:10","slug":"alternative-distance-function-for-stable-abstractions-principle","status":"publish","type":"post","link":"https:\/\/www.lexicalscope.com\/blog\/2012\/10\/31\/alternative-distance-function-for-stable-abstractions-principle\/","title":{"rendered":"Alternative distance function for Stable Abstractions Principle"},"content":{"rendered":"<p>Tools such as <a href=\"http:\/\/stan4j.com\/advanced\/stable-abstractions-principle.html\" title=\"Stan stable-abstractions\">STAN<\/a> use a distance function <strong>D = A + I \u2013 1<\/strong> to measure how well a particular package meets the stable-abstractions design principle. In my opinion this measure includes a lot of points in the design space that are not good places. Specifically, I think that packages should fall into the upper left or lower right corners only. This is particularly importaint if we consider the distance function to be a cost function and we are trying to automatically search for good designs. The <strong>D<\/strong> function can produces packages that are half abstract and half stable, which I would prefer to avoid.<\/p>\n<p>Instead I propose to use the normalised absolute difference in the distance from the two desirable corners of the design space. Specifically I favour designs which are closer to either the stable-abstract or unstable-concrete corners of the design space, over designs which happen to be  near the &#8220;main sequence&#8221; but are further from the desirable corner. I propose the distance function <strong><em>D&#8217;<\/em>=sqrt(2) &#8211; abs(sqrt((1-I)**2 + A**2) &#8211; sqrt(I**2 + (1-A)**2))\/sqrt(2)<\/strong>. This function weighs the desirable corners the highest and provides a watershed so that a search function can converge towards the most desirable part of the design space by cost-minimisation.<\/p>\n<p>Proposed stable-abstractions distance function (<strong><em>D&#8217;<\/em><\/strong>):<\/p>\n<p><a href=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"372\" data-permalink=\"https:\/\/www.lexicalscope.com\/blog\/2012\/10\/31\/alternative-distance-function-for-stable-abstractions-principle\/plot\/\" data-orig-file=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot.png\" data-orig-size=\"600,500\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"improved stable-abstractions cost function\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot.png\" src=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot.png\" alt=\"stable-abstractions cost function which weighs desirable corners higher than half-abstract half-stable packages\" title=\"improved stable-abstractions cost function\" width=\"600\" height=\"500\" class=\"aligncenter size-full wp-image-372\" srcset=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot.png 600w, https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-300x250.png 300w, https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-360x300.png 360w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>For comparison the original stable-abstractions distance function (<strong>D<\/strong>):<\/p>\n<p><a href=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-old.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"371\" data-permalink=\"https:\/\/www.lexicalscope.com\/blog\/2012\/10\/31\/alternative-distance-function-for-stable-abstractions-principle\/plot-old\/\" data-orig-file=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-old.png\" data-orig-size=\"600,500\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"stable abstractions main sequence cost function\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-old.png\" src=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-old.png\" alt=\"plot showing that the main sequence has the lowest cost, but an equal cost to the desirable corners\" title=\"stable abstractions main sequence cost function\" width=\"600\" height=\"500\" class=\"aligncenter size-full wp-image-371\" srcset=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-old.png 600w, https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-old-300x250.png 300w, https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-old-360x300.png 360w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/td>\n<p>To make the difference bettween these two functions concrete: here is a plot of the absolute difference between the functions. The red areas are the areas of most aggreement. You can see that the central disputed area is the area of the design space most affected by the selection of my proposed new function, positive figures are less favoured areas in the proposed <strong><em>D&#8217;<\/em><\/strong> function.<\/p>\n<p><a href=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-diff.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"379\" data-permalink=\"https:\/\/www.lexicalscope.com\/blog\/2012\/10\/31\/alternative-distance-function-for-stable-abstractions-principle\/plot-diff\/\" data-orig-file=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-diff.png\" data-orig-size=\"600,500\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"difference between cost functions\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-diff.png\" src=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-diff.png\" alt=\"shows which areas differ most between the two cost functions\" title=\"difference between cost functions\" width=\"600\" height=\"500\" class=\"aligncenter size-full wp-image-379\" srcset=\"https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-diff.png 600w, https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-diff-300x250.png 300w, https:\/\/www.lexicalscope.com\/blog\/wp-content\/uploads\/2012\/10\/plot-diff-360x300.png 360w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tools such as STAN use a distance function D = A + I \u2013 1 to measure how well a particular package meets the stable-abstractions design principle. In my opinion this measure includes a lot of points in the design &hellip; <a href=\"https:\/\/www.lexicalscope.com\/blog\/2012\/10\/31\/alternative-distance-function-for-stable-abstractions-principle\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13,8],"tags":[],"class_list":["post-368","post","type-post","status-publish","format-standard","hentry","category-design","category-refactoring"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2e3P7-5W","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts\/368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/comments?post=368"}],"version-history":[{"count":10,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts\/368\/revisions"}],"predecessor-version":[{"id":385,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts\/368\/revisions\/385"}],"wp:attachment":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/media?parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/categories?post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/tags?post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}