{"id":697,"date":"2013-03-25T13:05:45","date_gmt":"2013-03-25T13:05:45","guid":{"rendered":"http:\/\/codeatelier.wordpress.com\/?p=491"},"modified":"2013-03-25T13:05:45","modified_gmt":"2013-03-25T13:05:45","slug":"100-abstract-class-vs-interface","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/100-abstract-class-vs-interface\/","title":{"rendered":"100% abstract Class vs Interface"},"content":{"rendered":"<p>You can define an abstract method to be protected, and hence not part of the public API of the class. However, that seems like an odd design.<\/p>\n<p>Another thing &#8211; instance variables. You can have inheritable instance variables in the abstract class.<\/p>\n<p>Abstract class Methods can be defined at various levels down the path.<\/p>\n<p>In a 100% abstract class, you can also define non constant variables that can be herited. It is not possible with interfaces.<\/p>\n<p>The one case where an &#8220;100% abstract class&#8221; may be advantageous over an interface is in places where API stability is a key concern.<\/p>\n<p>If you write an API where other people are expected to implement your interface you have to stick to the interface. You can&#8217;t add any methods to the interface later on because that would break all clients (you would have to work around this by implement a second interface and let your code check againt the usage with instanceof checks and provide an fallback).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can define an abstract method to be protected, and hence not part of the public API of the class. However, that seems like an odd design. Another thing &#8211; instance variables. You can have inheritable instance variables in the abstract class. Abstract class Methods can be defined at various levels down the path. In&hellip; <a href=\"https:\/\/codethataint.com\/blog\/100-abstract-class-vs-interface\/\">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":{"footnotes":""},"categories":[98],"tags":[],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-interface"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=697"}],"version-history":[{"count":0,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/697\/revisions"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}