On Sun, 26 Aug 2001, Chuck Hagenbuch wrote:

> Quoting Sterling Hughes <[EMAIL PROTECTED]>:
>
> >     Jep -- I'm writing PEAR OO wrappers for every ADT that I implement
> >     in a functional manner.  I'm think for the OO wrappers, seperate
> >     class names wouldn't be horrible, something like:
> >
> >     $tree = new AVLTree;
>
> Please stick to the naming conventions, which would make this:
>
> $tree = new ADT_Tree_AVL();
>
> ... or something similar. Also, you could easily have a factory method:
>
> $tree = ADT::factory('tree_avl');
>
> or:
>
> $tree = ADT_Tree::factory('avl');
>

    The above are imho pretty ugly, and this is meant as more of a language
    level feature, I'm thinking of using PEAR as more of a method of
    distribution than a mindset.  I'd prefer to code the OO wrapper in
    PHP -- it stops me from having to be aware of changes to the Zend OO
    model and writing code that works with both the functional interface
    and the OO interface (some form of automatic handling of this would
    be a very cool/useful feature for Zend, imho).

    The current way I have it organized is as follows:

    php4/pear/ADT.php
    php4/pear/ADT/LList.php
    php4/pear/ADT/Stack.php
    php4/pear/ADT/Queue.php
    php4/pear/ADT/AVLtree.php
    php4/pear/ADT/BTree.php
    php4/pear/ADT/RBTree.php
    php4/pear/ADT/Heap.php
    php4/pear/ADT/Set.php

    then you could do something like:

    <?php
    require_once('ADT/Queue.php');

    $sounds = new Queue;
    $sounds->push("Bing");
    $sounds->push("Bamm");
    $sounds->push("Booom");

    while ($sounds->count() > 0) {
        echo $sounds->shift();
    }
    ?>

    Which I think works quite nicely :)

    -Sterling


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to