Re: interfaces - your opinion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux