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

comment on

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

So, here I am again, looking at a script that's grown larger than I expected. It's loaded with a page or two of file-scope lexicals at the top, followed by a bunch of functions that operate on them (many take no arguments and return no values), followed by a short "main" section at the end that uses those functions.

This happened because the script started out as just a short shell-scripty thing. "Do this, ask if I should do that, then do the other thing, and so on. Oh, but I need to save some state, so here's a global for that... and also a global for this... well, may as well rope this bunch of logic off in a function...". It all started so innocently.

The program doesn't (yet?) have many things in it that could be thought of as "objects", per se. Though, even if I did create a class and pulled a few strands of the bowl, there still would be plenty of spaghetti left over that needs straightening out.

So, what are the core points of good procedural design? I realize that functions modifying globals is not a terribly good idea, but am not sure how to escape it. I also realize that OOP isn't the cure for everything, and don't want to rush headlong into creating classes unnecessarily.


In reply to What are the core points of good procedural software design? (functions, code structuring) by Anonymous Monk

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 pondering the Monastery: (3)
As of 2024-04-26 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found