Dear Monks:

After a few brief years of using objects made possible by other peope's code, and now intensively working to learn how to do that more and more, and beginning to perhaps wrap my head around how to create my own classes which might inherit from other people's work, effectively and efficiently.

I just had to speak up
and say my hat's off to the people
who's code creates the capacity to
bless an object into being.

Behold, a work of art:

sub new { my $class = shift; my $self = { %fields, }; bless $self, $class; return $self; }
Not of my own making, of course, but one who's magic is beginning to become clear.

And thank you to this community which has created a safe place to ask the questions. Thank you to the janitors who plucked the trolls from the responses when my late night inquiries mistook a => hash assignment for something having to do with performing an object->method. My skin is thick and my intention to learn these tools is undeterred by the folks who'd tell me how much I have yet to learn, instead of simply pointing me to the next thing I was looking for which they had to offer. But it is certainly a pleasure to not be bothered by those distractions as I read the archives available at the ssearch engine.

Its interesting how your reporting of the xp and votes has encouraged me to participate more than I otherwise would if I were simply following google searches in hopes of solid leads. While awaiting answers to the posts of interest to me, I'll puruse other seekers' questions, upvote the ones I learn from and respond to ones I might have something to offer.

I probably should spend more time on my own code, perhaps. But this site has certainly proven a pleasant distraction from staring at unchanging error messages.

-- Hugh

Replies are listed 'Best First'.
Re: A work of art
by spiritway (Vicar) on Feb 14, 2006 at 03:54 UTC

    I agree. I am forever encountering Perl idioms that are effective, efficient, and even eloquent. I am often awed by the cleverness of these idioms, and how people have found ways to make Perl do things its creator (and his many helpers) never imagined. Many of these are so "obvious" once I see them that I wonder why I couldn't think of them - but I couldn't. I'm not yet so fluent in Perl that I can speak it eloquently. Right now I'm happy if I can speak it effectively - get something to work.

    I've found that as I peruse the questions, I learn many things, often unrelated to the questions being answered. Just recently I learned what autobundle is for. Since I had previously painstakingly downloaded every module I needed on each computer, this will be a great help to me. It wasn't something I even knew to look for - but now I have a very useful bit of information. That's one thing that makes PM so helpful. You can learn stuff you didn't even know you needed.

Re: A work of art
by diotalevi (Canon) on Feb 14, 2006 at 00:11 UTC
    sub new { my $class = shift; my $self = { %fields, }; bless $self, $class; return $self; }

    That's not art. It's a bug. %fields is a global. You're creating not actually using any of the parameters to ->new.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      Calling it a bug may be a bit premature. Perhaps %fields holds the default state of a new object, and new isn't intended to take parameters. Those fields should be manipulated otherwise. At the very least, $self isn't a reference to %fields itself, but a copy of the contents of %fields.

      There is a completely plausible explanation for this code, IMO. Without greater context, it's impossible to see. Besides, it doesn't, IMO, detract from the rest of the OP's post and probably didn't need to be singled out.

        Ya sure. I disagree. Oh well? %fields isn't named like it's supposed to provide defaults, it's named like the author intended it to be more local. If the thing really is some defaults then it ought to look like it. It's not good code, as is.

        ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: A work of art
by radiantmatrix (Parson) on Feb 15, 2006 at 17:00 UTC

    I probably should spend more time on my own code, perhaps. But this site has certainly proven a pleasant distraction from staring at unchanging error messages.
    There is a saying in the literary world that disparages writers who produce more than they read. I think that concept applies equally well to writers of code: one who writes more code than they read is a fool.

    Yes, spending time refining your own code and learning through example and trial is exceedingly beneficial. But, reading and understanding others' code is essential to improving your programming ability. Helping those less skilled than you is useful as well, as it helps solidify a concept when we explain it to others.

    Participating in PerlMonks has done more for my Perl ability in the year or so than reading books and trying to write applications did for the previous three. This is only partly resulting from having Sought of Perl Widsom; it's much moreso learning from meditations, trying to answer simple SoPW questions, trying to understand the more advanced questions (and, more importantly, the answers), and so on. Never underestimate the value of exposure to others' work!

    <-radiant.matrix->
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet