Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Control flow revisited

by dragonchild (Archbishop)
on Sep 05, 2003 at 16:33 UTC ( [id://289267]=note: print w/replies, xml ) Need Help??


in reply to Control flow revisited

After reading a lot of the responses, as well as some of your other questions, I am coming to a very important conclusion. You are not really designing your code. You're throwing stuff together and getting very confused when it doesn't work.

You really need to get away from the keyboard and put down on paper exactly the steps you want your code to achieve from the user's perspective. Treat your code as a black box and write down the actual specifications. Important questions you need answers to:

  • What inputs are expected?
  • Are these inputs user-specified? Hard-coded? Figured out on the fly?
  • Which inputs are mandatory? Which are optional?
  • How are the inputs specified?
  • What format(s), if any, will these inputs be in? What parsing capabilities already exist? (For example, HTML::Parser, XML::Parser, Spreadsheet::ParseExcel ...)
  • What outputs are expected?
  • Are these outputs user-specified? Hard-coded? Figured out on the fly?
  • Which outputs are mandatory? Which are optional?
  • What format(s), if any, will these outs be in? What templating capabilities already exist? (For example, HTML::Template, PDF::Template, Spreadsheet::WriteExcel ...)
  • How are the outputs specified?
  • (This is the big one) What am I expected to do?
  • What steps do I need to take to achieve my goal?
  • What error conditions should I be checking for?
  • If I encounter a specific error, what should I do with it? Should I
    • fail?
    • recover and continue?
    • write to a logfile?
    • display a message to the user?
    • do something else?
    • do some combination of the above choices?
  • (This is another big one) How am I going to validate that my implementation meets the above specifications?

And, that's only a subset of the questions you need to ask. Remember - you are telling a being with a 0 IQ exactly what it needs to do. Unless you explicitly tell it, it won't know to do it. If you don't check for a situation, you cannot expect it to do so. So, if you're not sure of what you want to do, you have absolutely no way of telling the computer what to do.

Programming, in my mind, should be 75% design and 25% coding. Both of those tasks should be 40% doing the task and 60% verifying you did the task correctly. So, if you do the numbers, you should really be spending your time as such:

  • Design/Specification - 30%
  • Design/Specification verification - 45%
  • Coding - 10%
  • Coding verification - 15%

Yes, design is that important. If you have it right, correct coding is a breeze. If you don't have it at all, correct coding is impossible.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Control flow revisited
by Tricky (Sexton) on Sep 06, 2003 at 11:33 UTC

    Cheers for the advice, dragonchild. Haven't seen the wood for the trees. So glad I visit the Monastery! I've set the guidelines down in stone (again). If I posted material to the monastery, would you folks be willing to critique?

    Regarding the coding problem I posted - it's now sorted! Time to get back to the drawing board... : )

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found