BazB has asked for the wisdom of the Perl Monks concerning the following question:
Howdy, Monks.
I'm in the process of putting together a couple of OO-based modules that wrap binaries and perform various sorts, subsets and munging operations on files.
The main problem I have is tracking all the files produced by each operation, and using that information to cut back on the amount of the information required by each method call.
In my quest to simplify (at least to the caller) the amount of parameters required I've tried the following:
Both ideas above don't handle the case where the underlying data is held in a number of files, because the code decided to split them up for parallel processing for example.
The user only needs to believe they have one logical file, not all the details underneath.
Anyway, after that rather lengthy introduction, how should I deal with this?
I though of returning some sort of Foo::IO object that contains all of the filenames that had been processed by a method, and all the information we might need.
If the user wants to process the output from an early stage of the code, he just uses the old Foo::IO object.
General example:
my $munger=Munger->new( input => "data" ); # assume the original "data" # since there's no Foo::IO argument my $sort_result = $munger->sort(by => "date"); # Again, just use the input filename stored in # the main object - "data" my $mangle_result = $munger->mangle(); # Use sorted file, and know that it's sorted by date # Give it the sort result Foo::IO state object my $subset_result = $munger->subset( by => date, $sort_result ); # etc.
When I mentioned my problem in the CB, jwest suggested using a object that contained several file objects that could be used for this sort of problem.
So, my questions are:
Hopefully I've explained my problem with sufficient detail.
Thanks in advance.
BazB
If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
That way everyone learns.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tracking processing by returning objects?
by BrowserUk (Patriarch) on May 17, 2003 at 06:31 UTC | |
by dws (Chancellor) on May 19, 2003 at 17:34 UTC | |
by BrowserUk (Patriarch) on May 19, 2003 at 18:28 UTC | |
by BazB (Priest) on May 17, 2003 at 10:51 UTC | |
by BrowserUk (Patriarch) on May 17, 2003 at 12:25 UTC | |
by BazB (Priest) on May 18, 2003 at 17:00 UTC | |
by BrowserUk (Patriarch) on May 19, 2003 at 03:33 UTC | |
| |
by parv (Parson) on May 19, 2003 at 06:13 UTC |