Wednesday, July 11, 2012

Debugging Python, Get a big can of RAID!

Writing a program is fairly simple,  if you're writing one for a social event, planning a trip or some other pleasant occasion.  Writing a computer program can be an adventure.  Did anyone tell you that it had to be de=bugged if something goes wrong, and it will, you can count on it (song comes to mind here, several of them). 

There are several better practices to writing a program.  Think it out first, draw a picture, do a map (they call these model), ponder over it, then put it to paper.  Whatever you write, save, save, save, (there's a local commericial out there for this one).   Did I say save?  Then run a few lines at a time, write yourself enormous notes using these little #### things.  Tell yourself and others what you expect the program to give back to you for each section.

Type s l o w l y, and accurately.  Looking for typing mistakes is called syntax errors.  Finishing the lines of thought include punctuation ( [ " "  ] } oops see there's one now. A syntax is running rampant. It should have looked like ( [ " " ] ).   It's a good idea to study your file path.   You need to know where you're going.   Did you leave enough crumbs to follow?     Draw a picture if you need to show how the flow of files, variables and pieces connect together.

  A picture can show the next issue out there:   no logic. 

The most hidden of all things to fix are logical errors.   Best said: well, I meant to say it this way but it came out the other. 

Some logic errors are in the order of presentation.   We need to tell the computer the definitions first before it can describe something.    Others are in the methods.  These are probably the hardest to find; especially for a newbie like me.  I know nothing so how am I supposed to know that something was to go there when I  knew nothing about it to begin with.   For those of us who do not perform any math other than everyday things, verbalizing math on paper can be well .....................

Then there are the tools to help you find out your errors.  Idle has a line by line thing which is good.
There's the pywin debugger which looks more window oriented.  How it's applied I'm not really sure. Then there's the pdb thing.  It's messy, maybe it works good, but how, I'm not able to tell you today. Maybe later when I'm more familiar with a little more practice.

There are bugs in python.  Some are big, some are small.  They can all be killed with RAID. But RAID will not make your program sing like a bird that a python would rather eat.

Enough for now. more later.


No comments:

Post a Comment