RE: [PHP] What is the practical use of "abstract" and "interface"?
| From: | Daevid Vincent | Date: | Wed, 16 Apr 2008 06:10:33 +0000 |
| Subject: | RE: [PHP] What is the practical use of "abstract" and "interface"? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273026@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Larry Garfield [mailto:larry@garfieldtech.com]
>
> If your code doesn't have an API and clear separation of
> parts, then neither
> abstract classes nor interfaces are useful to you.
>
> If you're coding anything of respectable size, vis, more than
> a one-off 1000
> line script or less, then you either want to have an API and
> clear separation
> of parts or I don't want to hire you, because your code is
> going to be an unmaintainable mess.
That is soooo not true. My last company had nearly 15 developers and we never used either of these
concepts in the six years the company existed. We had perhaps 50+ classes and some had upwards of
5-KLOC each. We had three databases with almost 300 tables. We had an external XML API that hooked
into these classes with 'set', 'get', 'add', 'delete' and
all the commands you would expect. And we weren't doing simple stuff either. This was an
extremely complex appliance that was HEAVILY PHP/Ruby driven (http://www.lockdownnetworks.com).
I'm not trying to start a war here, I just really don't see how any PHP project other than
the very fringe examples such as a DB abstraction project or huge PEAR project has any _real_ need
for this. Sure, it's all text-book and "proper" perhaps, but to me it just seems like
bloat and if you intend to extend a given class, you STILL have to read the source code and examine
the abstract class or interface anyways to know what you have to implement in your derived class
(right?)
90% of the LAMP projects amount to some website/service, some user registration, some blogs or
threaded discussion, some database entries. They're really not all that complex in the big
picture.
I can sort of see the use for these if you were designing an operating system or a device driver or
something HUGE. But come on -- a website is really not that big (code wise). It may have thousands
of pages, but they're built from a relatively small amount of dynamic PHP pages.
In any event, thanks for your detailed reply Larry. I get the concepts. I just don't see the
general-use-case need in PHP's OOP world. Maybe sometime the light-switch will flip on for me
and I'll realize I've been skating uphill all these years...
Daevid.
P.S. you should look at my resume before you decide not to hire me ;-p
http://resume.daevid.com