NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Dangerous inside-out examples (Score:1)
First, let me say that's a great presentation -- I really like the focus on design issues, rather than the usual construction issues. I also like how you avoided the "religious" wars on getter/setter styles and just advised "pick a method and stick with it".
However, while I know you were intentionally using simplified examples, the inside-out examples have a subtle, but potentially dangerous flaw:
This will silently "break" if $self is overloaded to stringify as something other t
Re: (Score:2)
You're absolutely right about the problems (of course). But, in my defence, I didn't have the time to go into that level of detail. All I was trying to do was to give people a high-level overview of the concepts.
I think that in future, I'll end that section with something along the lines of "that's basically how it works, but don't try to build classes like these yourself - instead use one of these modules as a base as they solve a number of problems that I haven't had the time to explain here."
Re: (Score:1)
You don’t have to explain the issues in any detail. Something like the following should suffice: “That
refaddrthere gives us the memory address of the reference, much like if you stringify it – but it guards against some issues I don’t have the time to expound on. Note that this isn’t thread-safe due to the use of addresses, but can be made so – again, I don’t have time to explain how. In practice, just use the Foo module and that’ll take care of these things