Page 1 of 1
Creating interfaces
Posted: Wed Mar 29, 2006 8:33 am
by jmut
I see interfaces is good thing to let know what methods class implements.
And if one wants to use stuff he need to impelement this and that interface to stick together with API or whatever.
So my question is....we now what methods should be implemented (the interface defines this) but we don't know what the result should be.
Is this PHP lacks or is it common problem....maybe I don't get something right.
Posted: Wed Mar 29, 2006 8:39 am
by patrikG
I have not the slightest idea what you're talking about. Care to write out a bit more clearly what you mean?
Posted: Wed Mar 29, 2006 8:45 am
by feyd
jmut wrote:Is this PHP lacks or is it common problem....maybe I don't get something right.
Considering PHP is a typeless language, it's rather retarded to have return types. Good documentation of the code should tell someone building their own interface what should be returned. Unit tests would also help as it would give you a black'n'white definitive as to your implementation falling into expected results. There's the potential for not-so-great test suites however, so good, up-to-date documentation is still important.
Posted: Wed Mar 29, 2006 11:29 am
by Christopher
There is also the broader question of whether Interfaces are really very useful in PHP. From what I have seen they are only really useful in some special cases where a you need to know about the general type of an object -- for Dependency Injection for example. Otherwise they are just extra parsing to provide error messages that should probably be dealt with in other ways, like unit testing.