[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: array of here documents

Leonard Cuff

2/15/2008 7:10:00 PM




On 2/9/08 3:09 AM, "Robert Klemme" <shortcutter@googlemail.com> wrote:

>> On 09.02.2008 12:04, Mark Woodward wrote:
>> On Fri, 8 Feb 2008 18:17:28 -0500
>> Xavier Noria <fxn@hashref.com> wrote:
>>
>> Is there any reason you wouldn't set up the heredocs first and then add
>> them to an array?
>>
>> HD1 = <<ENDHD1
>> This is a heredoc.
>> The first of 2.
>> ENDHD1
>>
>> HD2 = <<ENDHD2
>> This is the second heredoc.
>> ie the last.
>> ENDHD2
>>
>> a=[HD1,HD2]
>
> Waste of constants / variables.
>
> robert
>

I didn't know constants and variables were in short supply, I'll try to be
more frugal. :-) :-)

I hope you laugh rather than take offense.

I do want to make the point that code that is easier to understand by
novices is inherently more maintainable. Writing "compact" code is often
over valued, IMHO. I would much prefer to see Marks code, because of the
ease of understanding it.

Leonard


4 Answers

Robert Klemme

2/15/2008 10:00:00 PM

0

On 15.02.2008 20:09, Leonard Cuff wrote:
>
>
> On 2/9/08 3:09 AM, "Robert Klemme" <shortcutter@googlemail.com> wrote:
>
>>> On 09.02.2008 12:04, Mark Woodward wrote:
>>> On Fri, 8 Feb 2008 18:17:28 -0500
>>> Xavier Noria <fxn@hashref.com> wrote:
>>>
>>> Is there any reason you wouldn't set up the heredocs first and then add
>>> them to an array?
>>>
>>> HD1 = <<ENDHD1
>>> This is a heredoc.
>>> The first of 2.
>>> ENDHD1
>>>
>>> HD2 = <<ENDHD2
>>> This is the second heredoc.
>>> ie the last.
>>> ENDHD2
>>>
>>> a=[HD1,HD2]
>> Waste of constants / variables.
>>
>> robert
>>
>
> I didn't know constants and variables were in short supply, I'll try to be
> more frugal. :-) :-)

Simpler is often better so frugality might not be the worst course you
could take. :-)

> I hope you laugh rather than take offense.

No offense taken and it definitively made me smile. (-:

> I do want to make the point that code that is easier to understand by
> novices is inherently more maintainable. Writing "compact" code is often
> over valued, IMHO. I would much prefer to see Marks code, because of the
> ease of understanding it.

Completely agreed. There is of course room for interpretation. If code
is very elaborate to make understanding easier for novices it can defy
the purpose of ease of reading. If code gets compacted for compactness
reasons (famous one liners) then it usually becomes hard to read. A
simple example: some people (former C programmers?) like to use
assignments in if conditions, which is completely unnecessary and can
easily be confused with equivalence checks:

1. bad

if foo = calc_foo()
....

2. good

foo = calc_foo()

if foo
....

There is really only one reason where assignment in conditions makes
sense because the code becomes easier that way: in loops:

1. nice and short

while line = gets()
....
end

2. awful, because redundant

line = gets()
while line
....
line = gets()
end


Back to the particular example at hand: in this case I would at least
replace constants with regular local variables. If you use constants as
shown above, you would have to justify exposing these strings. This
usually only makes sense, if they are reused individually. If they are
not and are just temporarily there then local helper variables are
definitively preferred. I would even go as far as to put those here
docs directly into the array.

Kind regards

robert

%

6/7/2013 8:52:00 PM

0

The Peeler wrote:
> On Fri, 7 Jun 2013 12:53:08 -0700, "%" <persent@gmail.com> wrote:
>
>> The Peeler wrote:
>>> On Fri, 7 Jun 2013 12:26:15 -0700, "%" <persent@gmail.com> wrote:
>>>
>>>> The Peeler wrote:
>>>>> On Fri, 07 Jun 2013 12:01:41 -0700, The Rectum, the resident
>>>>> psychopath of sci and scj, FAKING his time zone again and
>>>>> IMPERSONATING his master, The Peeler, wrote:
>>>>>
>>>>>>>>> what a you know what you are
>>>>>>>>
>>>>>>>> What a what? <G>
>>>>>>>
>>>>>>> yes you are
>>>>>>
>>>>>> Post proof psycho!
>>>>>
>>>>> Not necessary, YOU keep proving it yourself, even if unwares,
>>>>> every day! You ARE such a retard! ;-)
>>>>
>>>>
>>>> told ya
>>>
>>> No I, told YOU innit!
>>
>>
>> and there you are , told
>
> Who, told you that?

peeler

The Peeler

6/7/2013 8:58:00 PM

0

On Fri, 07 Jun 2013 13:31:33 -0700, The Rectum, the resident psychopath of
sci and scj, FAKING his time zone again and IMPERSONATING his master, The
Peeler, wrote:

>>>> No I, told YOU innit!
>>>
>>> Like I just said and many said before me: you ARE a retard!
>>
>>told ya
>
> I, told YA!

You didn't! You only made an ass of yourself. You NEVER do ANYTHING ELSE!
<BG>

--
Retarded, anal, subnormal and extremely proud of it: our resident
psychopath, The Retard (aka "The Rectum").

The Peeler

6/7/2013 9:00:00 PM

0

On Fri, 07 Jun 2013 13:31:13 -0700, The Rectum, the resident psychopath of
sci and scj, FAKING his time zone again and IMPERSONATING his master, The
Peeler, wrote:


>>
>>
>>and there you are , told
>
> Who, told you that?

Take a guess, little idiot! <BG>

--
sully to our resident psychopath (aka "The Rectum"):
"frankly you're a dingleberry on usenet's ass"
MID: <be3854ef-b0ea-4bfa-b002-0d19bbdd200b@g5g2000pbp.googlegroups.com>