More of an exasperation than a meditation but with a query at the end.

Is it just me that is rather tired of maintaining other peoples' Perl code?
Is it just me that seems to always get landed with poorly written, logically flawed dross to maintain and recover? Is this symptomatic of how easy Perl is to pick up and get working at a basic level?

What I would like to know is the balance of good / bad / indifferent code that other monks have come across in their Perl careers, where they have had to inherit and sort out systems / web applications.

EG If I was to put values on it, Ive moved onto about 8 different existing Perl projects, one was OO and well coded, another was non-OO and ok, the others and the current one look like they've been thrown together by a group of ***** monkeys on crack.

Dont get me wrong, I love Perl, but Im having trouble getting a job where I can enjoy it and wonder what others experiences are?

Replies are listed 'Best First'.
RE: Code Maintenance
by chip (Curate) on Aug 05, 2000 at 00:45 UTC
    OK, 90% of Perl code you have to maintain is crap. This should not surprise you. Sturgeon's Law applies:

    90% of EVERYTHING is crap.

    Perl is an amplifier. It amplifies the bad along with the good.

    At least rewriting programs is easier in Perl than in most other languages.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

      I'd have to disagree with the blanket statement of At least rewriting programs is easier in Perl than in most other languages.

      It all depends on what language you know best. Personally, I find re-writing a badly written straight 'C' program easier than Perl. I write Perl (and at rare times, good Perl), but I'm don't come close to the tight code that someone like yourself, Randal, chromatic, or btrott writes.

      Any sufficient complex process or algorithm poorly implemented in any langauge is going to be difficult to rewrite, particularly if you don't have any idea of what the target algorithm is.

      --Chris

      e-mail jcwren
        Actually I have to agree with jcwren. I write crappy perl-code.
        I started programming perl close to the date I joined PM.
        I don't have years of experience like some of you have here. Actually I started
        programming 6 months ago before that I installed and maintained
        hardware and software.
        So don't expect from me nice code, but with comming to PM I learn
        how not to code. I get sometimes amazed with the solutions given here
        PM to different problems and the comments given on code, with this
        interaction I learn a great deal and sometimes prevent me from
        making mistakes...

        I still hope PM remains like it is a helpfull community and we are
        all willing to help others.
        This is why I think it's important that higher level monks keep
        they're motivation to point out what lower level monks are doing wrong.



        --
        My opinions may have changed,
        but not the fact that I am right

RE: Code Maintenance
by Odud (Pilgrim) on Aug 04, 2000 at 17:07 UTC
    You could almost replace Perl by "any language of your choice" and the above meditation would still be valid. In my view Perl is still youthful enough to suffer from 'flavour of the month' syndrome. Inexperienced coders use Perl to produce badly written (through no fault of their own) code, skilled coders in other languages write Perl code but so heavily flavoured by their 'native' language that it is difficult to understand/maintain.

    Perhaps what you should do is:
    a) rewrite where possible and practicable
    b) or comment and correct if not
    c) or if none of the above apply then post warning notices and retire a safe distance

    The best legacy you can leave for those that follow you is your own code that is clear/succinct/understandable... Don't worry too much about the mess that you inherit - it wasn't your fault and it probably isn't your job to sort it out - just make sure that you don't add to it or make it worse. Odud
      I admit my first effort in Perl would probably give me a fit if I went back and had to maintain it and I agree with your comments on the whole but:

      'Dont worry about the mess you inherit, ... it probably isnt your job to sort out'

      If only, this time it is my job and theres no one to pass that buck to ... :-)

        I found this book useful. Refactoring : Improving the Design of Existing Code
        But the problem is it's OOP oriented with examples in java.
        Anybody have a good book they can recommend for redesigning existing code in a non-OOP/non-OOP->OOP world?
        But it does contain some ways of identifying what exactly in the code feels wrong.
        Bad code smells funny, but sometimes it's harder to isolate what makes it that way.
        I used this to make my college group projects go easier.
        ',this time it is my job' in which case best of luck - but at least you have a clear definition of what you have to do and hopefully you have agreed the resources and timescales before starting...
RE: Code Maintenance
by davorg (Chancellor) on Aug 04, 2000 at 16:47 UTC

    I don't often come across projects where Perl is already used (generally I just get on with it and use Perl whenever possible). I think that in the last five years I've been at three places where Perl was used.

    • At the first the code looked OK to me, but I didn't know much Perl at the time and looking back I'm pretty sure that it was basically shell scripts written using Perl syntax. I think most of it was written under Perl 4.
    • The second one was the back end of large UK-based auction site and it was written by people who knew no Perl. I was brought in as a "Perl Expert" but whenever I suggested better ways to do things I was told that they didn't have time to go back and fix existing code and that as long as it worked they were happy with what they'd got.
    • At the last place I spent months rewriting a system that was in Perl, but that had been written by someone whose Perl wasn't very good.

    So, yes, my experience backs up your theory. I suspect the major problem is that there is so much bad Perl out there on the web that the chances of people coming across merlyn's Web Techniques columns before they find Matt's Script Archive is pretty slim.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>
RE: Code Maintenance
by BigJoe (Curate) on Aug 04, 2000 at 17:37 UTC
    Well when maintaining any code that is not mine I usually go through it and check to figure out if it is easier to do a rewrite or work with what was given to me. I even hate looking at any of my code from before I joined PM. I feel sorry for BigRare because he had to pick up perl to maintain (and complete) the scripts I wrote there. If it uses no modules and it really really needs to then I just tear it up and rewrite it. But that is me..

    --BigJoe

    Learn patience, you must.
    Young PerlMonk, craves Not these things.
RE: Code Maintenance - Insulting
by Kevman (Pilgrim) on Aug 04, 2000 at 19:27 UTC
    Agoth, Thanks for changing your wording. To the person who voted me down I ask why? I expect a /msg please

    Kevman
      exasperation overload, point taken...