http://www.perlmonks.org?node_id=219086


in reply to A guide to coding Perl

I like the coding guidelines, they are not really strict - like the placement of curly braces etc ... - but they catch more software engineer lifestyle guidelines then coding guidelines. Professional coding is just that, programming with a professional mind set and using common sense. There is one tip I really think is not a so good idea, the code generation part. I'm convinced that generated code is more difficult to maintain than hand crafted code, especially if you rely on a IDE that inserts tags in the generated code to do, e.g. folding or stuff like that. Wht if two developers use different editors?

Johan

Replies are listed 'Best First'.
Re: Lifestyle versus coding guidelines ...
by rir (Vicar) on Dec 11, 2002 at 18:14 UTC
    Well perltidy takes care of the grunt work of formatting code, I'm not that fussy: I've used perltidy for about a year and haven't yet played with the options for it. I like an early K&R C type formatting.

    As for strictness of rules it doesn't really apply to a one man show. But if I were leading a team I'd prefer consensus on coding standards then my standards would not change too much in style.

    If the culture would not allow that then I think very clear standards are good. Clear like: Use perltidy with these options. Use strict always. If people aren't on the same page there is no point to statements like: Try to avoid deep indent levels. Avoid complex regexes if possible. The first are clear and enforceable, the latter are not. Piddly little rules like the former may indicate a sick work environment. But a business can't stop just because the work culture is diseased.

    If I talk of pointy haired bosses, I am showing that I am infected.

    As regards code generation we disagree. But it does seem that we are talking about different things. My generated code is distinguishable from by my hand code only in the header comment that says it is generated and that it may be slightly differently formatted. If I ran it though perltidy you could not tell the difference.

    I have fooled with IDE's but have never overcome the initial learning curve. Smalltalk was really tempting me, then java became the hot OO alternative to too-complex C++ and killed off the Smalltalk companies.

    I started serious generation with the Jeeves generator described in Advanced Perl Programming by Srinivasan. It is not completely implemented as described, so I found myself descending into Perl to set up stuff for Jeeves. Eventually I decided that Jeeves was unnecessary, that using straight Perl to generate code would be faster, clearer, and more flexible. Just a little uglier in syntax.

    This has allowed me to create more code, more consistent code, and less buggy code. By continually finding the differences between the entities in my code and defining them in one place I find that finding one bug and fixing it, fixes many bugs. Or points to further refinement of my meta-data. So my experience with code generation is very different than yours.

    Yum, yum meta-data gooood.

    Yes it does get to that viseral a level.