Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: What Worked In My 1st Year Of Perl: LOL

by raybies (Chaplain)
on Nov 15, 2010 at 16:55 UTC ( #871506=note: print w/replies, xml ) Need Help??

in reply to What Worked In My 1st Year Of Perl: LOL

Nice meditation. Here's my one addition for a good step missing in this writeup.

8. Try small code examples before sticking them into complex programs and scripts: It's common sense, but it's amazing how often I find beginning programmers who don't do this. I think mostly it is due to the fact that many languages require a whole skeletal framework, or a ridiculous "project" file with makescripts, or IDE dependent metadata, and gui descriptions, and so forth before they can even run the simplest "Hello, World" program. The end result is that people don't write simple test programs to try out a feature of a language, they just go from the documentation and examples and then wonder why they don't quite get it. Yet, Perl is an ideal language for this practice. In a sentence of perl, one can test most features of the language. And there are shortcuts (easy to pick up if you read Perlmonks, cuz they are in most examples) built into the language to allow for sample data, data dumping, and argument stuffing. So do it.

  • Comment on Re: What Worked In My 1st Year Of Perl: LOL

Replies are listed 'Best First'.
Re^2: What Worked In My 1st Year Of Perl: LOL
by sundialsvc4 (Abbot) on Nov 15, 2010 at 19:28 UTC

    This might be a good place to mention test-suites like Test::More.   Get into the habit of building test-suites for your code as you develop it.   It can be rather ridiculous just how many errors creep into “a simple bit of code that you just whipped out.”   I wrote just such a “little module” last week and, wouldn’t ya know it, every one of the methods had one or more bugs in it.

    I also painfully learned this maxim, and so never forgot it during all the many years since:  

    “Code defensively.   Put self-checks into your code as you write it.   Check every parameter, test every assumption.   Keep them there until you are positive that there are no more bugs.   Then, and only then ... keep them there (forever).
Re^2: What Worked In My 1st Year Of Perl: LOL
by DrWhy (Chaplain) on Nov 19, 2010 at 00:15 UTC
    This also works when you are trying to understand someone else's obscure code. Isolate the part you don't understand and wrap it in something simple that lets you poke and prod it to see how it behaves.


    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Re^2: What Worked In My 1st Year Of Perl: LOL
by ack (Deacon) on Nov 19, 2010 at 18:54 UTC

    I concur completely with vroom.

    Having the ability to try small code examples was an absolutely invaluable part of my learning Perl.

    Having learned many langauages in my career, the most "bang for the buck" always came from writing code...especially little exploratory snippets that would let me more clearly understand and see the nuances of different constructs and strategies.

    But all early ones were compiled languages and involved a lot of work to go from editor, to compiler to linker to running. At the risk of revealing my dinosaur age background, I began with Fortran on an IBM mainframe with punched cards and batch jobs that usually took about 24 hours for turnaround of a job!

    I learned the value of a more interactive approach with Microsoft's early versions of Visual Basic and when I found a freeware Integrated Development Environment (IDE) for Perl, almost immediately found that my learning curve had become nearly vertical.

    I still use that strategy almost every day. It is as valuable to me now as it was almost 7 years ago when I was first learning Perl.

    ack Albuquerque, NM

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://871506]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2018-06-23 14:09 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.