{"id":1619,"date":"2010-03-27T21:43:41","date_gmt":"2010-03-27T20:43:41","guid":{"rendered":"http:\/\/www.toomik.net\/helen\/blog\/?p=1619"},"modified":"2020-02-21T23:41:33","modified_gmt":"2020-02-21T22:41:33","slug":"scandevconf_notes_udi_dahan_intentions_and_interfaces","status":"publish","type":"post","link":"https:\/\/www.toomik.net\/helen\/blog\/2010\/03\/27\/scandevconf_notes_udi_dahan_intentions_and_interfaces\/","title":{"rendered":"ScanDevConf notes: Udi Dahan, &#8220;Intentions and Interfaces&#8221;"},"content":{"rendered":"<p>\n<i>This is my summary of Udi Dahan&rsquo;s &ldquo;Intentions and Interfaces&rdquo;, a session I attended at <a href=\"http:\/\/www.scandevconf.se\/2010\/conference\/\">ScanDevConf 2010<\/a>. <b>Please understand that, except for the notes at the top and bottom, this post reflects the opinions of the speaker, not me.<\/b><\/i>\n<\/p>\n<p>\nA core design pattern: intentional interfaces. Whenever you find yourself facing a design problem, tell yourself &ndash; &ldquo;Make roles explicit&rdquo;.\n<\/p>\n<p>\nFor example, a Customer class may be used to validate a customer before persisting it, for making customers preferred, and for adding orders to the customer. Making these roles explicit, the Customer class would implement IValidator&lt;Customer&gt;, IMakeCustomersPreferred, and IAddOrders. Now that these are in place, we may use them, for example, to implement different fetching strategies for #2 and #3 &ndash; lazy vs eager.\n<\/p>\n<p>\nAnother example: there might be a CustomerService class for those same three tasks. Separating out the three responsibilities, the class might implement IMessageHandler&lt;ChangeAddressMsg&gt;, IMessageHandler&lt;AddOrderMsg&gt; and IMessageHandler&lt;MakePreferredMsg&gt;. Now that this is explicit, we may split this into three different classes, which would (among other things) allow us to have several handlers for a single message, in a pipeline.\n<\/p>\n<p>\nAs a rule of thumb, define your interfaces starting from use cases. These tend to be a stable foundation to build on.\n<\/p>\n<p>\nOften we think one interface &ndash; many implementations. With this pattern it&rsquo;s the opposite: one implementation, many interfaces.\n<\/p>\n<p>\n<i><b>My opinion:<\/b> This session is difficult to summarize without all the examples and step-by-step reasoning, so I&rsquo;m afraid the blog post won&rsquo;t do it justice. I found it useful, and the reminder to Make Rules Explicit will probably lead to better design with less sprawling classes in our code.<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is my summary of Udi Dahan&rsquo;s &ldquo;Intentions and Interfaces&rdquo;, a session I attended at ScanDevConf 2010. Please understand that, except for the notes at the top and bottom, this post reflects the opinions of the speaker, not me. A core design pattern: intentional interfaces. Whenever you find yourself facing a design problem, tell yourself [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[207,212,416,415,385,393,394,417],"class_list":["post-1619","post","type-post","status-publish","format-standard","hentry","category-geeky_things","tag-conference","tag-design","tag-design_patterns","tag-interfaces","tag-scandevconf","tag-sdc","tag-software","tag-udi_dahan"],"_links":{"self":[{"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/posts\/1619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/comments?post=1619"}],"version-history":[{"count":5,"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/posts\/1619\/revisions"}],"predecessor-version":[{"id":12389,"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/posts\/1619\/revisions\/12389"}],"wp:attachment":[{"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/media?parent=1619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/categories?post=1619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.toomik.net\/helen\/blog\/wp-json\/wp\/v2\/tags?post=1619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}