Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Breaking The Rules

by Anonymous Monk
on May 31, 2006 at 21:15 UTC ( #552936=note: print w/ replies, xml ) Need Help??


in reply to Breaking The Rules

A rule is usually a summary of a lot of experience; it explains the common cases, not the edge cases.

For example, "don't parse HTML with regexps" is a good idea in general: you can't do a good job of parsing arbitrary HTML with a regular expression.

On the other hand, if you wrote all the HTML yourself, and know exactly what applying a given regexp will do to your HTML, then go ahead and use the regexp if it does exactly what you want.

If you didn't write the HTML, on the other hand, you probably can't reliably predict what a given regexp will do to the meaning of a page. You might need to carefully parse the HTML, determine carefully what sections are which, and only then make your substitution. This is the safer assumption: and so the rule prevents you from making bad assumptions without knowing what you're doing.

Understanding the summary is a good idea; understanding the full history of why that summary was written is even better. You'll learn why the rule was made, who thought it was a good idea, in what context and to what extent to apply it, what the risks are for not following the rule, and when it doesn't make sense to apply the rule at all.

For example, hurricane insurance is often a good idea. But this rule works much better for people living in New Orleans than it does for, say, people living in the Nevada desert.


Comment on Re: Breaking The Rules

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://552936]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-12-28 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls