RE: [PHP-DEV] Re: aggergate vs MI

From: Date: Tue, 09 Apr 2002 10:54:08 +0000
Subject: RE: [PHP-DEV] Re: aggergate vs MI
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-82355@lists.php.net to get a copy of this message
At 12:32 09.04.2002, Pierre-Alain Joye wrote:
Would it be so bad allowing closed source? I really do not care, but I really appreciate and use only ( for my dev ) open sources products, but that is not the question, and was a joke ==> ;) :)) I think having one of MI, aggregation and interfaces is essential for OO modelling. I m not a professionnal of OO design, but do not see how interfaces in php will help us during the design phases. Where do you use interfaces during the modelling phase ? If you use pear::db and an interface is available, how do you will use it ? ( no irony in these questions, just interested). pa
Lets A be a generic interface to do some work. Then A is an abstract object. Lets B be a specific implementation on some other stuff. And let assume that B has to be used for the same work as A was designed for. Then we could have C be totally different from B but able to take its place according to A. Ok. Example: class Collection is a class that allows collection o objects. class A and class B are some classes. Now Collection must store objects in general and it is not able to communicate with the objects it stores. Now implementing sorted lists: Instance Item is an interface that allows comparison of to Items in Collection by a method. interface Item {
        function ItemContent() { ... }
} class Collection {
        ...
        function Sort() {
                ...
                $diff = $a->ItemContent() - $b->ItemContent();
                ...
        }
        function Insert($o) {
                if ( !$o is Item) {
                        echo "Error: O is not Item";
                } else {
                        insert....
                }
        }
} class A implements Item {
        var $a;
        function ItemContent() {
                return $this->a;
        }
} class B implements Item {
        var $b;
        function ItemContent() {
                return $this->b;
        }
} helped? marcus

« previous php.dev (#82355) next »