views:

58

answers:

2

I recently asked a question regarding the resolution of dependencies between Unit of Work and Data Mapper classes: http://stackoverflow.com/questions/3012657/dependency-injection-and-unit-of-work-pattern - (which was answered by Gabor de Mooij - thx)

In PoEAA, Martin Fowler suggests using Separated Interface to manage these dependencies. My question is simple - is it actually possible to implement this pattern in PHP, or is it specific to Java interfaces? I've searched high and low and it's hard to find references to this pattern anywhere outside of PoEAA.

A: 

Have you tried Google? First result:

http://www.ibm.com/developerworks/opensource/library/os-advphpobj/#N101E7

This essentially says to use an abstract class that acts like an interface.

Scrolling down a bit, it shows that you can do it interfaces

interface Exportable {
    public function export();
}

class OurNews extends ThirdPartyNews 
              implements Exportable {
    // ...
    function export() {
        print "OurNews export\n";
    }
}

class Dictionary implements Exportable, Iterator {
    function export() {
        //...
    }
}
TheLQ
I think the OP does not want to know whether interfaces are possible at all, but asked for an example on the *Separated Interface* pattern, as given at http://martinfowler.com/eaaCatalog/separatedInterface.html
Gordon
Thank you Gordon. This was not the droid I was looking for Lord Quackstar (;)
sunwukung
A: 

Yes, it is possible (why would you doubt that?). If you're looking for an example, you could check out the Cookie Pattern blog.

wimvds
2 reasons: 1 - information on the pattern is hard to find. 2 - the UML for the pattern omits a crucial detail - the dependency on an external configuration file.
sunwukung