Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
demerphq specifically asked me to comment on this thread, which is the only reason I'm wading into what is really a philosophical debate.

In Object Oriented Perl I show a few examples of (what I consider to be) reasonable uses of the ref($class)||$class idiom (e.g .section 4.2.1 and section 12.3.5).

Of course, this does not consistitute "cargo cult" programming because I (presumably) deliberately chose to use the technique and (presumably) know why I'm doing so.

And I guess that's the point: that there's nothing wrong with using just about any technique -- if you know what you're doing and why it's the appropriate thing to do.

For example(s):

  • I rarely use strict in my modules.
  • I often use a roll-my-own export mechanism, rather than Exporter.
  • My code brims over with symbolic references and typeglobbing.
  • I almost never write comments.
  • I'm not averse to using a well-placed goto (or twenty -- e.g. Switch.pm).
  • I often provide multiple interfaces to a module.

Am I cargo cult programmer? I doubt it. After all:

  • I rarely use strict in my modules...because I rarely make the kinds of mistakes that use strict catches and (more importantly) because I know to turn it on when confronted with an otherwise-mysterious bug.
  • I often use a roll-my-own export mechanism, rather than Exporter...because I find it much easier that way to get exactly the behaviour I need.
  • My code brims over with symbolic references and typeglobbing...because that's the kind of under-the-surface program manipulation that my ideas often require.
  • I almost never write comments...because, if the code itself isn't enough of a comment, then I know I probably need to rewrite it.
  • I'm not averse to using a well-placed goto...because it's occasionally the very best solution to a complex control flow problem.
  • I often provide multiple interfaces to a module...because I know that different people like to think -- and code -- differently, and that "intuitiveness" means eleven different things to ten different people.
In other words, someone who is competent with a wide range of programming tools may consciously choose amongst them, without any regard to prevailing fashion or received wisdom. They're actually the opposite of a cargo cultist, even if the visible symptoms are identical.

What about someone else who doesn't use strict, who rolls their own exports, references symbolically, fails to comment, indulges in the occasional goto, and who multiples interfaces without necessity? Are they a cargo cult programmer? Maybe so. Or maybe not. It isn't what you do...it's why you do it.

Rules are not sacred. They're merely social mechanisms, provided to protect the inexperienced, and to streamline things for the experienced-but-working-to-an-impossible-deadline. Cargo cults are just sets of rules with sociological bases, rather than logical ones. They're all about programming the way Granddad used to program, not because I understand why Granddad did things that way, but just because Granddad did things that way...and it never did him any harm!

Is that an acceptable way to operate? Well it wouldn't be for me, but it might well be for you, or for her, or for them. And if it makes your/her/their code harder to maintain, perhaps that's a small price to pay for the valuable lesson that hardship has to offer. And perhaps it's a price the majority are happy to pay in exchange for the emotional comfort of doing things in the familar way.

Is merlyn right to disparage such coding practices? Almost certainly, since that's what he's being paid to do. Does that condemnation translate to a universal proscription? Almost certainly not (nor do I think merlyn thinks it does).

The trouble is, by just looking at the code (absent the coder) there's no way to tell whether one is seeing the results of superstition or satori. But that's the essential issue.

As the Jargon File illustrates in its Zen-like appendix:

A novice was trying to fix a broken Lisp machine by turning the power off and on.

Knight, seeing what the student was doing, spoke sternly: "You cannot fix a machine by just power-cycling it with no understanding of what is going wrong."

Knight turned the machine off and on.

The machine worked.

Or, to misquote from The Fifth Element:
"What" is not important. Only "why" is important.

In reply to Re: Paradigm Shift - Don't use strict by TheDamian
in thread Paradigm Shift - Don't use strict by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-29 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found