note 77944 added to language.oop5.abstract

From: Date: Thu, 20 Sep 2007 20:22:04 +0000
Subject: note 77944 added to language.oop5.abstract
Groups: php.notes 
Request: Send a blank email to php-notes+get-130639@lists.php.net to get a copy of this message
This should be a lot more obvious than people make it out to be. The difference between an interface and an abstract class, is that an interface does not define the behavior of an object. Rather, it defines how you work with a class. You use interfaces to decouple the behavior of a class from the accessors and mutators which make up the class. With an abstract class, you are saying that "Method X should work like this", "Variable Y should be used", an interface could be used to do something completely different. A well-known usage is that of the proxy. A proxy is used to moderate access to the real object without modifying the class which describes the object. Instead, you create a new class, implementing the same interface, adding the new behaviour in the new class. This could be security checks, accessing a remote object through a TCP/UDP connection, or simply using a light object to avoid creating the heavier one unless it's explicitly necessary depending on the accessed functions. Either way, the abstract class does not allow this, as it has already decided how the class should work. The interface is much more open-ended in this way and would allow for the same, as it never decides anything about the object implementing it. ---- Server IP: 69.147.83.197 Probable Submitter: 81.224.115.42 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php Edit -- https://master.php.net/note/edit/77944 Del: integrated -- https://master.php.net/note/delete/77944/integrated Del: useless -- https://master.php.net/note/delete/77944/useless Del: bad code -- https://master.php.net/note/delete/77944/bad+code Del: spam -- https://master.php.net/note/delete/77944/spam Del: non-english -- https://master.php.net/note/delete/77944/non-english Del: in docs -- https://master.php.net/note/delete/77944/in+docs Del: other reasons-- https://master.php.net/note/delete/77944 Reject -- https://master.php.net/note/reject/77944 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130639) next »