How to do your Homework: 10 easy steps

(borrowed from Alexandra Bokinsky)

Writing a program can be a lot of fun. In many ways it is like solving a puzzle. You will wrestle with a program, with the complier, with the computer, but when you finally get it working you will feel... well wait and see, it's too great a feeling to describe.

Writing a program can also be a very mysterious process. At first you will write code that doesn't work, then you will make a seemingly random change -- maybe just changing one line or one word or even just one punctuation mark -- and suddenly the program will work. And you won't know why. Learning how to program can be very confusing. You may feel like you are writing random statements, not really knowing what you are doing. This is normal, and it will get better. One day the light will dawn.

One way to avoid wasting a lot of time hacking is to spend time thinking about your program away from the computer before you start programming.

Often, you will read the assignment and think that you understand it well enough to program it, so you start writing right away. You get halfway into the program and you realize that there are many issues that you didn't consider before your started. Complexities that you didn't realize were part of the solution. But you have already started the program, so you don't want to throw away the code you've written, no matter how badly it fits the solution. So you continue trying to patch in new functions and new code, desparate to make it work. This technique never works

If only you had taken the time to think through your program before you started working, you would have discovered the tricky parts and would have planned for them from the beginning. Preplanning, desiging an algorithm before you code, is an essential step in writing a working program.

The reason this step must be done away from the keyboard is that thinking about a new program is exciting. When you think you know the first step of the solution, you want to write the code right away, and so you start typing before you have thought the whole algorithm through. It happens to everyone.

Here are 10 steps for doing your homework.  I will be much more able (and more willing) to help you if you are on step 4 or 5.

  1. Read the current web page lecture notes and assignment

  2.  
  3. Spend some time thinking about the program. Try to design a good algrithm. Do this Away from the computer. As you think, jot down ideas: what Java constructs do you need, what variables, what methods... At this time you may want to refer to sample code in the book or from the lectures

  4.  
  5. Program a first attempt ( this attempt will most likely fail ).

  6.  
  7. Rethink your algorithm -- again away from the computer.

  8.  
  9. Program a second attempt ( this attempt will most likely fail ).

  10.  
  11. If this fails, talk with the Instructor or LA in the lab, or send email.

  12.  
  13. Program a third attempt ( should be almost working now ).

  14.  
  15. Fix any minor bugs and copy your working code onto your disk to turn in.

  16.  
  17. Read the next day's web page in preparation for class.

  18.  
  19. Read the next reading assignment in the book.