[Israel.pm] Design Question

Shmuel Fomberg semuelf at 012.net.il
Wed Nov 19 12:39:35 PST 2008


Hi.

More details for my question:
The "action" gets a tree as input, that corresponds the object tree, and 
each node in the object tree have equivalent in the input tree.
Some of the nodes need to pre-process the input tree for their children, 
or post-process the result.

So, any advice?
Shmuel.

Shmuel Fomberg wrote:
> I need a design advice on my module, Data::ParseBinary.
> 
> The module works in the Composite design pattern, which means that all 
> the classes inherent from one base class "base", and each object may 
> have zero or more "children".
> The base class defines two methods, build and destroy, and each 
> sub-class must implement them, optionally calling the same method in 
> it's children, if exists and if it decides to.
> 
> The current operation is pretty naive, that the program calls the root 
> object, and it calls it's children's methods and so on.
> 
> The problem is that this design is not flexible. what if I want to print 
> a debug message before and after every object in the hierarchy? What if 
> I want to also print what each action returned?
> 
> After a talk with Shlomo, I'm thinking about modifying the system to 
> iterator-style, where the iterator will traverse the object tree, and 
> each object will queue it's children in the iterator.
> 
> What do you think? How would you do it?



More information about the Perl mailing list