At 11:20 AM 5/16/01 -0400, Craig Moynes/Markham/IBM wrote:
>I am wondering about the 'perl way' or using variables.  I have created a
>class for a generic 'logfile'.  I then have a series of instance variables
>such as the name of the logfile, the record seperator regular expression, a
>series of date formatting values, etc.
>
>Now I have methods that I am calling such as:
>      $self->read_log();

Great, so far so good.

>I do this to access the instance variables. I don't mind this it keeps it
>nice and clean.  However I start to get into cases like:
>$self->prune_log( $num_of_records );

Nothing wrong with that.

>I may decide later on to put all the log manipulators in a seperate
>package, for re-usability in other programs.  In that case I would have to
>change all the log manipulators to accepts parameters for each instance
>variable that is now used.

Why can't they take as parameter a logfile object from which they can 
extract that information?  Or inherit from a logfile object?

>So I guess all this boils down to is the following question:
>
>Is it acceptable practice to use instance methods that access instance
>variables (essentially global variables from a pure look of the code) or is
>it better to pass in a slew of variables to a function for
>ease-of-reusability later on, which in turn makes the code a little uglier

The question, of course, is not related to Perl, but to object-oriented 
design and analysis.  Asking the question without the Perl syntax in one of 
those newsgroups ought to get a more fruitful response.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com

Reply via email to