Reply to Re: [PHP] interfaces - your opinion

Your name:

Reply:


Posted by "Richard Lynch" on 12/30/05 20:53

On Thu, December 29, 2005 10:31 am, Jochem Maas wrote:
> anyone here work with Interfaces? I do and I like them alot;
>
> I recently ran into a situation where it would be nice to be able to
> specify
> that a given interface is only allowed to be implemented by a certain
> class (and all subclasses thereof) - Anyone have an idea as to how
> to implement such a restraint in a clean way? does anyone think that
> this
> is generally useful?
>
> maybe it's something that should not be done at all.
> maybe the implementation belongs in the engine (with some new syntax)
> e.g:
>
> class MyClass {}
> class MySubClass extends MyClass {}
> class MyOtherClass {}
> class SomebodyElsesClass {}
>
> interface MyIface validfor MyClass, MyOtherClass
> {
> abstract function blabla();
> }
>
> // SomebodyElsesClass would not be able to implement MyIface
>
>
> interested to know if anyone has an opinion on this.

I don't use Interfaces and all that stuff, but...

Seems to me that every explanation I've ever heard for using
Interfaces in the first place was to provide an abstract definition of
what a class was supposed to implement, and that any class that
implemented the required functionality should, in some theoretical
la-la land, be a suitable replacement for any other class.

Seems to me that if you restrict the implementation to a specific
branch of classes, you're kinda defeating the whole purpose of an
Interface, based on my rudimentary understanding of what an Interface
is supposed to be.

I'm sure it makes perfect sense in the context you need, but...

Makes me think maybe an Interface isn't what you ought to be using in
the first place...

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация