note 93687 added to language.oop5.abstract
| From: | CheeseDoodle at osu1 dot php dot net | Date: | Tue, 22 Sep 2009 23:13:37 +0000 |
| Subject: | note 93687 added to language.oop5.abstract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160958@lists.php.net to get a copy of this message | ||
There isn't really that much of a great hurdle in understanding these things, there really
isn't.
If you're defining a new class that is abstract, it means that you can make some non-abstract
functions that you can use to define the general underlying behavior of that class along side
abstract ones.
In interfaces, you can't do that since functions defined therewithin cannot have a body.
Abstract functions you use for classes that must define more specific behavior when
"extending" your class.
So for a crude example - define by your non-abstract functions how that particular object (which may
be part of a larger class hierarchy) would store and process it's data in SQL, XML, etc.
Then define abstract functions which allow someone implementing that class to specifically
manipulate the data that is to be stored. Then require a format which this data must be returned in,
and then in your non-abstract functions call those functions on destruction, in normal runtime, and
so on.
Again, non-abstract functions, or even another class could implement the finer points of ensuring
that data is in the correct format, and so on, ad infinitum.
It isn't too much of a reach to say that if you used a normal class instead of an abstract
class, then there isn't much intrinsic requirement between the two classes.
Assuming that you wanted the functions to use each-others functions and you'd need to use them
specifically by name, you'd have to write some code which checked to see -- lamely using
function_exists() and other lamery -- if that class has the function you require for
interoperability, when you could avoid all possible confusion and headaches by simply using the
right tool for the job.
And reading a decent OOP book.
----
Server IP: 208.69.120.35
Probable Submitter: 82.3.243.233
----
Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php
Edit -- https://master.php.net/note/edit/93687
Del: integrated -- https://master.php.net/note/delete/93687/integrated
Del: useless -- https://master.php.net/note/delete/93687/useless
Del: bad code -- https://master.php.net/note/delete/93687/bad+code
Del: spam -- https://master.php.net/note/delete/93687/spam
Del: non-english -- https://master.php.net/note/delete/93687/non-english
Del: in docs -- https://master.php.net/note/delete/93687/in+docs
Del: other reasons-- https://master.php.net/note/delete/93687
Reject -- https://master.php.net/note/reject/93687
Search -- https://master.php.net/manage/user-notes.php