Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

To the “down-voters” among you, who may mistake brevity for lack of wisdom or experience, I invite your reconsideration.   Here’s why.

The “clever improvements” as suggested cause each of the various if cases to become coupled.   In other words, as long as each and every if-case that could possibly be required, for the entire service lifetime of this application (which could be a decade or more), is identical ... the code is “clever,” and perhaps it may look a wee bit more agreeable to the digestion.

However ...

Change will come.   Some day, a condition will need to be added that will break the rule.   And, when that happens, suddenly the code that is working properly now must be torn-apart, more or less, and recoded.   What was meant to be clever has just turned bad, and it de-stabilized all of the logic that it “cleverly” tied together.   Whereas, if the “ugly” if..elsif structure had simply been retained, no changes to any of the existing code, with its admittedly repetitive structure, would have been required.   You would simply need to add another elsif block at the appropriate point.   You can keep that up indefinitely.

Please bear in mind that I have spent most of my career in “code rescue” and project-turnarounds.   Which means that my perspective on such things is somewhat like that of a coroner.   Such “cleverness,” well-intentioned though it once may have been, after a surprisingly short amount of time attracts a large number of blowflies.   Maintainability is king, and software must be designed in anticipation of a very long service life involving many different people.   You won’t be at that job forever ... but your work will be, and someday I might be called in to have a look.


In reply to Re^2: Short and easy way to write if...elsif syntax by sundialsvc4
in thread Short and easy way to write if...elsif syntax by slayedbylucifer

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 chanting in the Monastery: (6)
As of 2024-03-29 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found