Janek Schleicher said:
Am 07.02.2014 21:47, schrieb Rainer Weikusat:
Even copy+paste means more work than just using HTTP::Status.
It's not like you try to get Angular.js to run.
This seems like a patently absurd statement to me ...
The 'bulk' of HTTP::Status is
sub status_message ($) { $StatusCode{$_[0]}; }
ok, that's still shorter than any hand written code and much easier to
maintain.
The exact equivalents would:
print(status_message(200));
vs
print($http_status{200});
That's less code for the second case. Of course, using a name a la
$htsc{200}
would be as possible. But the difference is really rather negligent on
the 'coding side'. Using direct hash lookups is - however - faster,
which might have noticable effect when 'processing log files' as these
can easily be 'large' (millions of lines) and it offers some otherwise
unavailable features, eg, get access to a list of all status codes.
[intelligible text restored]
a method call status_message
is very unlikely to get called in list contet
If it was called as a method (which would require creating an
out-of-module constructor for HTTP::Status objects first), this wouldn't
matter because prototypes aren't checked on method calls. Also, I didn't
said that I'd agree this was a problem (I'm using prototypes myself,
just not when posting code here), I just pointed out that there's a
double standard applied here: Someone who posts code with prototypes
used for something else than "enabling hand-optimized 'chaotic' syntax"
is invariable told that he shouldn't be doing this. If this was a
measure of 'bad code quality', it should surely apply to code written by
"module authors" as well.
Well, HTTP::Status doesn't claim to be rocket science, it solves one
little problem, but it solves ist.
In the context of "too difficult to solve the problem without the
module", this doesn't seem to make sense. I didn't claim that the hash
lookup subroutine wouldn't work, just that 'using a hash lookup
instead' would amount to using a basic language feature.
You can use it of course. But do you update it also?
And even if you use it, it's still more time, more work and less
maintainable than to use this module direct.
I was specifically writing about the problem of maintaining the
table. This is easy for a separate database file, fairly easy if the
code using the table contains it directly, and problematic when the
table comes 'internally hard-coded' with some software distribution as
any 'naive' update of that would overwrite local changes.
You've now made the 'more work and less maintainable' statement
twice. Would you care to elaborate why you consider this to be true?
It's not self-evident to me.
Copy+Paste makes it even worse
Why?
So you have to write your own documentation.
Come on, it's past 1975, an undocumented, untested part of our code is
a bug, nor a feature.
Documentation about 'using hashes' already comes with Perl. Also, your
idea about 'documentation' seems a little unrealistic to me: Assuming
that documentation is written at all (I assure you that the people who
pay the salaries for me an my colleagues considers this a better spare
time activity which should rather be avoided in order to perform 'useful
work'), it is pretty certain that no one will ever read it on the
grounds that this is just too much effort
It still has to work.
Even when installed in customers environment or whereever.
Again, 1975 is over.
I'm unaware if 'software written in 1975' wasn't supposed to work as I
was three by that time. I'm, however, inclined to believe that it was.
So, it's better if you copy+paste them??
In case the useful part of a module is smaller than the module itself
and more useful without it, yes. There's - of course - also the option
of putting the table into a proper database file and use that.
What's the problem.
If you want, you can add any Memorize-ic function to avoid it.
The function call itself? How?
There is no non-trivial code in this module. Because of this, the
assumption isn't applicable here.
Because 9. is an 'lone' assertion without any to substantiate it.
O.K., so you copy+pastied it, what is better than?
I don't understand what this is supposed to communicate in the given
context.
File::Temp is a module usually distributed,
it's part of perldoc.
Wow, you are using standard installed modules.
The statement about me you deleted contained the claim that I was
principally opposed to using third-party developed modules. This is
wrong, as pointed out above.
HTTP::Status works and does what it claims.
Year, people tried to build perpetuum mobile, well, they nether worked
and aren't part of CPAN IIRC.
That's besides the point: The original statement was "lots of people put
lots of time and effort into developing CPAN modules". As shown by the
two examples itself, this is irrelevant in the given context: The result
matters.
Nobody said that,
but most of the time it's worth to use it,
and often it's at least better than to reinvent it,
Well, you just said that.