Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Standardized Interface Design for Search tree

by broquaint (Abbot)
on Jun 25, 2002 at 11:22 UTC ( #177060=note: print w/replies, xml ) Need Help??


in reply to Standardized Interface Design for Search tree

Why not mix and match the OO and the functional? Maybe you have a standard class for performing generic operations on trees, but certain tree-types require particular ops so you can just field those out to coderefs e.g
package Tree::Ops; sub delete { ... } sub join { ... } 1; # ... later sub search { ... } my $tree = Tree::Struct->new( someops => 'Tree::Ops', searchop => \&search );
This has the benefits of re-usability, flexibility and all those funky OO features. Or you could declare the functions straight into the symbol table of said package e.g
sub Tree::Ops::avl_search { ... }
Gaining all the benefits of being in a class while still giving the control to the user[1].
HTH

_________
broquaint

[1] I'm sure I should've used a bunch of OO buzzwords there ... ah well ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://177060]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2022-12-02 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?