Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

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

I have decided to rewrite a badly written program of mine ... The main reason it was so badly written was that I did not fully plan out how the program would work.

Although I greatly support your desire to rewrite, I wouldn't beat yourself up too much on this. In fact I'd probably argue that this isn't why your program ended up badly written.

It's intensely diffiuclt to properly plan out software. If you're lucky enough to have a detailed specification of exactly what's required, excellent. But even then, are you sure it'll never change. This applies whether you're writing for your employer or for yourself. Requirements always change. So don't worry too much about planning for that.

Just develop what you need, when you need it. The important thing is to never hack yourself into a corner. Any time you're developing and you think "If only this piece of code had been more abstract / less tightly coupled / whatever", resist the temptation to hack around it. If you do that, then very soon you have unwieldly code that'll be a nightmare to maintain.

Instead, refactor that piece of code so that it works for what you had, and also for what you now need. (Good tests are essential). If you do this relentlessly at each stage then you always have a 'good enough' code base.

Does anybody know of some good techniques to plan out code? Which ones work, and which don't?

I'd argue that any technique to plan out code doesn't work! Do what you need as you need it, and keep improving your code as you go. That's all there is.

Tony


In reply to Re: Rewriting some code by salvadors
in thread Rewriting some code by Fingo

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 imbibing at the Monastery: (6)
As of 2024-04-19 16:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found