{"id":27,"date":"1998-06-02T02:10:00","date_gmt":"1998-06-02T02:10:00","guid":{"rendered":"http:\/\/billwake.com\/index.php\/1998\/06\/02\/pattern-patter-interface-abstract-default\/"},"modified":"1998-06-02T02:10:00","modified_gmt":"1998-06-02T02:10:00","slug":"pattern-patter-interface-abstract-default","status":"publish","type":"post","link":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/","title":{"rendered":"Pattern Patter: Interface-Abstract-Default"},"content":{"rendered":"<p><b>Summary: Provide three &#8220;classes&#8221;: an interface, an abstract      class, and a default implementation. [Design Pattern]<\/b>     <\/p>\n<h2>Context<\/h2>\n<p>You are developing a framework of cooperating classes. <\/p>\n<h2>Forces<\/h2>\n<ul>\n<li>You want to make things easy for the user, so you want to provide    implementations.<\/li>\n<li>But you want your design clean, and you want the user to provide    implementations where appropriate.<\/li>\n<\/ul>\n<h2>Resolution<\/h2>\n<p>Provide three &#8220;classes&#8221;: <\/p>\n<ul>\n<li>An interface (fully abstract class), to keep the design clean.<\/li>\n<li>An abstract class (that conforms to the interface), that implements the    &#8220;bookkeepping part of the class, but has abstract methods for the    &#8220;interesting&#8221; parts.<\/li>\n<li>A fully-implemented class (probably a subclass of the abstract class,    definitely conforming to the interface). This should provide a useful default    implementation.<\/li>\n<\/ul>\n<h2>Discussion<\/h2>\n<p>This gives the user several places to &#8220;plug in.&#8221; The first cut (or a naive  programmer) can work with the default implementation. A more sophisticated  implementation can extend the abstract class, and avoid copying data into and  out of the default implementation. An implementation for which the abstract  version&#8217;s bookkeepping is too much overhead can replace everything. Finally, the  interface provides a barrier to ensure clients don&#8217;t care (depend on) which  actual types they&#8217;re working with. <\/p>\n<h2>Examples<\/h2>\n<ul>\n<li>The <a href=\"http:\/\/java.sun.com\/products\/jdk\/1.2\/docs\/guide\/swing\/\">Swing    libraries for Java<\/a> use this pattern. For instance, TableModel provides the    interface. AbstractTableModel handles the change notification, and lets you    wrap your own table structure with it. DefaultTableModel provides a table that    uses Vector for storage.<\/li>\n<\/ul>\n<p><small>[Written 6-1-98]<\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Provide three &#8220;classes&#8221;: an interface, an abstract class, and a default implementation. [Design Pattern] Context You are developing a framework of cooperating classes. Forces You want to make things easy for the user, so you want to provide implementations. But you want your design clean, and you want the user to provide implementations where [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-patterns"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pattern Patter: Interface-Abstract-Default - Bill Wake&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pattern Patter: Interface-Abstract-Default - Bill Wake&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"Summary: Provide three &#8220;classes&#8221;: an interface, an abstract class, and a default implementation. [Design Pattern] Context You are developing a framework of cooperating classes. Forces You want to make things easy for the user, so you want to provide implementations. But you want your design clean, and you want the user to provide implementations where [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/\" \/>\n<meta property=\"og:site_name\" content=\"Bill Wake&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"1998-06-02T02:10:00+00:00\" \/>\n<meta name=\"author\" content=\"Bill Wake\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bill Wake\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/\"},\"author\":{\"name\":\"Bill Wake\",\"@id\":\"https:\\\/\\\/billwake.com\\\/#\\\/schema\\\/person\\\/b551cc572ce5d025b081e031a73eec0c\"},\"headline\":\"Pattern Patter: Interface-Abstract-Default\",\"datePublished\":\"1998-06-02T02:10:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/\"},\"wordCount\":238,\"commentCount\":0,\"articleSection\":[\"patterns\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/\",\"url\":\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/\",\"name\":\"Pattern Patter: Interface-Abstract-Default - Bill Wake&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/billwake.com\\\/#website\"},\"datePublished\":\"1998-06-02T02:10:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/billwake.com\\\/#\\\/schema\\\/person\\\/b551cc572ce5d025b081e031a73eec0c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/billwake.com\\\/pattern-patter-interface-abstract-default\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/billwake.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pattern Patter: Interface-Abstract-Default\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/billwake.com\\\/#website\",\"url\":\"https:\\\/\\\/billwake.com\\\/\",\"name\":\"Bill Wake&#039;s Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/billwake.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/billwake.com\\\/#\\\/schema\\\/person\\\/b551cc572ce5d025b081e031a73eec0c\",\"name\":\"Bill Wake\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e2b28fe375cac050dad2f141da886dde7ff7a1edc00116f801ec96cf3849fa1?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e2b28fe375cac050dad2f141da886dde7ff7a1edc00116f801ec96cf3849fa1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e2b28fe375cac050dad2f141da886dde7ff7a1edc00116f801ec96cf3849fa1?s=96&d=mm&r=g\",\"caption\":\"Bill Wake\"},\"url\":\"https:\\\/\\\/billwake.com\\\/author\\\/bill-wake\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pattern Patter: Interface-Abstract-Default - Bill Wake&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/","og_locale":"en_US","og_type":"article","og_title":"Pattern Patter: Interface-Abstract-Default - Bill Wake&#039;s Blog","og_description":"Summary: Provide three &#8220;classes&#8221;: an interface, an abstract class, and a default implementation. [Design Pattern] Context You are developing a framework of cooperating classes. Forces You want to make things easy for the user, so you want to provide implementations. But you want your design clean, and you want the user to provide implementations where [&hellip;]","og_url":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/","og_site_name":"Bill Wake&#039;s Blog","article_published_time":"1998-06-02T02:10:00+00:00","author":"Bill Wake","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Bill Wake","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/#article","isPartOf":{"@id":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/"},"author":{"name":"Bill Wake","@id":"https:\/\/billwake.com\/#\/schema\/person\/b551cc572ce5d025b081e031a73eec0c"},"headline":"Pattern Patter: Interface-Abstract-Default","datePublished":"1998-06-02T02:10:00+00:00","mainEntityOfPage":{"@id":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/"},"wordCount":238,"commentCount":0,"articleSection":["patterns"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/","url":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/","name":"Pattern Patter: Interface-Abstract-Default - Bill Wake&#039;s Blog","isPartOf":{"@id":"https:\/\/billwake.com\/#website"},"datePublished":"1998-06-02T02:10:00+00:00","author":{"@id":"https:\/\/billwake.com\/#\/schema\/person\/b551cc572ce5d025b081e031a73eec0c"},"breadcrumb":{"@id":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/billwake.com\/pattern-patter-interface-abstract-default\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/billwake.com\/"},{"@type":"ListItem","position":2,"name":"Pattern Patter: Interface-Abstract-Default"}]},{"@type":"WebSite","@id":"https:\/\/billwake.com\/#website","url":"https:\/\/billwake.com\/","name":"Bill Wake&#039;s Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/billwake.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/billwake.com\/#\/schema\/person\/b551cc572ce5d025b081e031a73eec0c","name":"Bill Wake","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8e2b28fe375cac050dad2f141da886dde7ff7a1edc00116f801ec96cf3849fa1?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e2b28fe375cac050dad2f141da886dde7ff7a1edc00116f801ec96cf3849fa1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e2b28fe375cac050dad2f141da886dde7ff7a1edc00116f801ec96cf3849fa1?s=96&d=mm&r=g","caption":"Bill Wake"},"url":"https:\/\/billwake.com\/author\/bill-wake\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":0,"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/billwake.com\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}