grabbing value of a variabe by its name?

Ragnar Hojland Espinosa ragnar at linalco.com
Fri Jul 26 09:33:28 UTC 2002


On Thu, Jul 25, 2002 at 09:07:45AM -0700, Randal L. Schwartz wrote:
> And it's evil magick.  The kind of which I will rip out if I'm ever
> forced to maintain your code.  If I don't just get frustrated and
> erase your code and start over when forced to maintain it.
>
> Please.  Most of the business cost of code is *maintenance*, not
> *development*.  If you do tricks like you've asked, you've just
> shot yourself in your future foot.

If I got to choose which code to maintain, this:

execute 'insert into table1 (firstName,lastName,position,address,zip,country) values (',
        firstName asQuotedPostgres,',',
        lastName asQuotedPostgres,',',
        position asQuotedPostgres,',',
        address asQuotedPostgres,',',
        zip asQuotedPostgres,','
        country asQuotedPostgres,')'.
	"ad nauseum"
			
or this:
			
fields _ SQLFields new: #(firstName lastName position address zip country).
execute 'insert into table1 (', fields asNames, ') values (', fields asValues, ')'.
	
I know which I would choose.  Not only its quicker and cleaner, its also
safer safer and encourages a coherent homogeneus naming convention across
classes for data extracted from the database with a localized "trick"

> Pick a different strategy.  Please.

I'm open to suggestions.

-- 
Ragnar Hojland - Project Manager
Linalco "Especialistas Linux y en Software Libre"
Tel: +34-91-5970074 Fax: +34-91-5970083



More information about the Squeak-dev mailing list