Re: To Reference or not to reference
- From: marilyn-sander@xxxxxxxxxxxxx (Marilyn Sander)
- Date: Thu, 29 Mar 2007 10:16:52 -0700
Chas,
You mention an issue that i've been pondering for a while. When and why should you
use an OO style instead of a hash? If your basic data structure (or several) is a hash,
what is to be gained by refactoring as OO? Isn't OO just a large amount of syntactic
sugar surrounding some simple data constructs?
I'm not being facetious or sarcastic. I characterize OO as "syntactic sugar" only as a
straw man to knock down. I really would like to know what people see as
the advantage to OO in this situation.
thanks,
--Marilyn Sander
On Mar 29, 2007, at 5:57 AM, Chas Owens wrote:
On 3/29/07, Dukelow, Don <don.dukelow@xxxxxx> wrote:I've written a Perl program that declares a hash at the top of the
program "%myHask;". It has worked great until now when one sub program
seams to be making its own copy of the hash. I can find no typo's or
anything but there my still be one there. My question is would it be
better to pass the global hash by reference to each sub program to cut
down on possible typo errors or just leave it global and fix the problem
I have?
Don Dukelow
I can say with near 100% certainty that passing a ref is better than
using a global. Also, if you are finding your self writing code that
is focused around a hash that you are calling a number of functions on
then what you are really doing is writing OO code in a non-OO fashion.
Consider refactoring the code as object based instead of hash based.
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
.
- Follow-Ups:
- Re: To Reference or not to reference
- From: Chas Owens
- Re: To Reference or not to reference
- References:
- To Reference or not to reference
- From: Don Dukelow
- Re: To Reference or not to reference
- From: Chas Owens
- To Reference or not to reference
- Prev by Date: RE: Exiting loops
- Next by Date: Prepend + to search words
- Previous by thread: Re: To Reference or not to reference
- Next by thread: Re: To Reference or not to reference
- Index(es):
Relevant Pages
|
|