Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I use packages and break out into subs for two major reasons: maintainability and reuse.

That way, I can break out items that I use often, as you have done with PassMaster, and have a single place to fix bugs. Imagine if you had used PassMaster instead as simply a cut and paste snippet, and put it in some 12 scripts. Then, later along, you realize that the masking becomes ineffective if the user sends a certain excape sequence! Sure, fixing 12 scripts can be done, but we're lazy, aren't we? Yes.

I also tend to start my projects by starting a bit on each major component, and put things into packages as I go. That way, if I realize that I've already written something, all I have to do is use it. Boy am I making things easy for myself ;)

When done right, using subs and packages also makes it easy to expand your code, or refactor it (to an extent). If you haven't noticed the real point yet, it's all about making things easier on you. It's just a little effort for a big payoff.

P.S.: I don't believe you need the brackets in the DataBase Interface section -- the package statement applies until the next package or end of file. diagnostics should probably left out when the code goes to production, too. :)

Update: Oh also, ++ for the question! I expect some great responses coming soon!

mhoward - at - hattmoward.org

In reply to Re: When Is Dividing Code Into Different Subroutines/Packages Important? by meredith
in thread When Is Dividing Code Into Different Subroutines/Packages Important? by Missing Words

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 examining the Monastery: (7)
As of 2024-04-19 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found