How to write a decent program

August 9, 2007

Writing a program can be fun and painful (sometimes at the same time). In order to produce a successful program, there are a few things that need to be worked out before your write your first line of code. Here are a few simple steps to get you in the right direction:

  1. Get the specs: Find out what is needed in your program. Often times you are writing a program for someone other than yourself, so it’s good to get all of the details in advanced. There are too many times that I start a project and half way the client decides to add or take away something. As painful as this can be, it can be (somewhat) avoided with good planning.
  2. Design your interface: Even before touching a database (if your using one, of course), you have to find out what is supposed to go in it. Designing the interface first allows you to get all of the inputs (and outputs) you’ll need for your program. Sometimes you’ll have to design several interfaces for one program, so it’s always a good idea to get all of them out of the way first.
  3. Determine what attributes and properties are needed: Your program can go from a few lines to a few hundred very quickly. It’s good practice to determine all of your functions, variables, attributes, and interactivity between them before actually writing your program. You don’t even have to complete the functions or even give your variables any values; just as long as your making note of what is needed, you can take care of the details later.
  4. Fill in the details: This is where you should really take your time to craft your art. In this step you have to give your program life by adding functionality to your code. A program can consists of tons of variables, functions, and classes. You have to get your stuff together and organize your code so that everything is working in unity with one another. This step is crucial to the success of your program.
  5. Test it: As you progress with your program, you have to test it in every way possible. Try to find an error in your code by testing every scenario that you can think of. For example if you are calculating two values, try to calculate a letter and a number. If you have an error, than you better make sure that the user can’t enter a letter (or any other weird character that can mess up your code). Think of your self as a complete novice when your testing your program and try to mess it up. A big mistake programmers often make is to assume that your user knows how to use their program. You basically have to make it idiot proof. If only the user could be as cool as you (**sigh**).
  6. Test it again. And again. And then one more time (for good luck).
  7. Update: Keep your client up to speed with the progress and provide them with prototypes of your work. That last think you need is for them to say “Oh, I said add all of the fields?!, what I meant to say was take each value, get the square root, multiply it by 0.9, then divide that by the number of fields. Oops!”. Yeah, big oops. You could have told me that 200 lines ago.
  8. Deploy: Once everyone is happy, build your application and send your baby into the world. They can’t be at home forever, you have to let go sometime.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: