
{"id":9,"date":"2008-01-06T16:18:14","date_gmt":"2008-01-06T21:18:14","guid":{"rendered":"http:\/\/ikriv.com:8765\/blog\/?p=9"},"modified":"2008-01-06T16:18:14","modified_gmt":"2008-01-06T21:18:14","slug":"framework-design-guidelines-book-part-ii","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=9","title":{"rendered":"Framework Design Guidelines Book &#8211; Part II, Interfaces vs. Abstract Classes"},"content":{"rendered":"<p>This is a second portion of my comments on the &#8220;Framework Design Guidelines&#8221; book. See also <a href=\"http:\/\/www.ikriv.com\/blog\/?p=8\">Part I<\/a>. This post is devoted to the following recommendation we find on page 81 of the book:<\/p>\n<p><strong>DO favor defining (abstract) classes over interfaces<\/strong><\/p>\n<p>This is an often quoted guideline, that can be found in MSDN and elsewhere. It is probably the most controversial guideline in the book, especially given its near-mandatory strength (&#8220;DO&#8221;) as opposed to more lenient &#8220;CONSIDER&#8221;. The book itself contains descending opinions ranging from &#8220;I agree in general, but&#8230;&#8221; (Jeffrey Richter) to &#8220;you can see interfaces coming back&#8221; (Chris Anderson).<\/p>\n<p>The author demonstrates this guideline on an example of the Stream class. <em>&#8220;The <code>System.IO.Stream<\/code> abstract class shipped in version 1.0 of the framework without any support of timing out pending I\/O operations. In version 2.0, several  members were added to<code><br \/>\nStream<\/code> to allow subclasses to support timeout-related operations.&#8221;<\/em><\/p>\n<pre><code>public abstract class Stream\n{\n    public virtual bool CanTimeout { get { return false; } }\n\n    public virtual int ReadTimeout\n        { get { throw new NotSupportedException(); } }\n        { set { throw new NotSupportedException(); } }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a second portion of my comments on the &#8220;Framework Design Guidelines&#8221; book. See also Part I. This post is devoted to the following recommendation we find on page <a href=\"https:\/\/ikriv.com\/blog\/?p=9\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[6],"tags":[],"class_list":["entry","author-ikriv","post-9","post","type-post","status-publish","format-standard","category-books"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}