How to take on a programming assignment

From ArticleWorld


Picking up a Computer Science class is quite brave nowadays. Computer Science is very abstract and requires some understanding of other sciences (math being somewhere in the first place for sure). Therefore, completing your assignments can be considered crucial.

If you have problems getting started with these assignments, this does not mean you are a bad students. Maybe the problem is really laying in the way you are planning and doing rather than in what you know. Putting a little bit of order in what you do can be helpful, and going along the following steps may prove a good idea.

It is important to note that these steps are just a starting point. You may find better alternatives: after all, everyone has their own way of solving problems. You may skip or add steps as you please. Use this not as a set of handcuffs. Use it as a guide.

Steps

1. Read the assignment a few times. Make sure you know exactly what you need to do, that you know exactly what your final product will do.

Let us take this as an example: Write a program that reads lines from a given file, and prints only those lines that contain a certain given word".

2. Start by breaking everything down into little pieces. Outline every step your program has to do. In our example, it should:

  • Read the name of the file and the word
  • Read lines, one by one, while the end of the file has not been reached yet
  • Search every of these lines for the word and decide whether the line should be printed.

Of course, this is only a small example. In the end, even these "small problems" will be easy to solve. The general rule is: break the programs to pieces that are smaller and smaller, until you end up with pieces you can solve thoroughly. For example, if you are dealing with a program that looks up persons in the database, one of the step you outline will be "find that name in the database". However, there is a specific algorithm for this (a search algorithm). If you do not know how to implement that algorithm, break it down, too.

3. Evaluate what you will need. What algorithms will you use? How will you bind everything together?

4. Evaluate the skills you need. For example, you will need to know about pointers if you will implement linked lists. If you do not have the skills, find alternative ways, or learn them.

It is important to remember that you are here to learn. You got this assignment because you were not expected to be able to do it in a matter of seconds while feeding your cat, but you have the skills you need to find out how to do it.

5. Write the program. If it helps, write pseudo-code at first. If you are just starting out with programmers, draw flowcharts, make notes, explain, and use a lot of comments. In time, you will need less pseudo-code and flowcharts. Comments should stay.

Notes

If you get stuck somewhere, get help. Read articles, go through textbooks, and, if allowed, ask friends, instructors or public forums. You are there to learn and study hard by yourself: do not ask for someone else to do your homework, but do ask for hints.