in reply to Re: Re: evolving an OO solution for a bitstream
in thread evolving an OO solution for a bitstream

Let's say that BitStream inherits from Stream::Generic. If you call BitStream's new() your way, you cannot do my $self = $class->SUPER::new(@_); to have some intialization deferred to the parent. Better is my $stream = BitStream->new("bigbinfile"); - much easier to extend, now. Plus, you could do something like:
# This way of dealing with meg and gig is a poor way, used only for de +monstration. # Supersearch for a better way. my $KB = 1024; my $MB = 1024 * $KB; my $GB = 1024 * $MB; my %Classes = ( $MB => 'BitStream::Vec', $GB => 'BitStream::Buffered', ); my $filesize = -s $filename; my $classname = 'BitStream::InMemory'; foreach my $min_size (sort { $a <=> $b } keys %Classes) { last unless $filesize >= $min_size; $classname = $classes{$min_size}; } my $stream = $classname->new($filename);

That way, you can choose your BitStream::* class based on the size of your file. If it's under a meg, use the instream. Between a meg and a gig, use the hybrid vec option. Over a gig, you need to use the slow buffered method.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.