On 12 Sep 2002, Uri Guttman wrote:

> >>>>> "SR" == Stephen Reppucci <[EMAIL PROTECTED]> writes:
>   >> $self->{'fh'}->print( $text ) ;
>
>   SR> Directly accessing members of your object??? Ewww...!
>   SR> Who invited you into my living room?  ;^)
>
>   SR> I know this is bordering (stomping?) on the pedantic, but wouldn't
>   SR> '$self->print($text);' be a clearer way of doing this?
>
> pedantic and wrong. :)
>
> $self is not a handle but contains a handle and other info as well.
> that is a line from within a write() method in the Stem::Log::File
> class.

No, $self isn't a "handle" (if by handle, you mean filehandle), but
it *is* an object ref, right? It seems silly to me to store the file
handle in the object, but then access it directly -- there oughta
be a method 'print' that knows about the fh.

Of course, now that you've given us some context (it's being called
within the class, so you're not in *my* living room, we're looking
in the window at what you're doing in *your* living room...;^),
yeah, that's more acceptable. But unless you're *really* on the TomC
side of "don't use objects 'cause there's a performance cost", then
I maintain that using a method when one's available is not only
valid, but has benefits.

E.g., what if you decided to change this class to provide a buffered
(internally buffered within the object, not buffered like stdio...)
implementation?  If you use those as file handles all over the
place, you've got to go hunt down all of the places you do so, and
change them. If you've just used the 'print' method, that's all you
have to change.

Again, I can buy either one (inside the class, not out...), I just
think if you're writing perl, the performance difference between the
two doesn't matter, and you should favor clarity.

As Drew voiced, I'd also be interested in hearing what others' ideas
are on the "correctness" of either approach. I'm no huge OO bigot,
so I'd love to hear what someone who *is* one thinks of this...

<Steve>

-- 
Steve Reppucci                                       [EMAIL PROTECTED] |
Logical Choice Software                          http://logsoft.com/ |
=-=-=-=-=-=-=-=-=-=-  My God!  What have I done?  -=-=-=-=-=-=-=-=-=-=


_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to