Tips and Tricks

  1. Start early -
    Even the best programmers need to debug. Being a good programmer does not mean that you can write flawless code the first time through, it means that you can efficiently and completely solve any problems you encounter. Unfortunately, this process takes time. There is no substitute for starting early so that you have plenty of time to address problems as they come up. Start designing your programs as soon as they are assigned. Don't wait until the night before the due date to start writing the code. Give yourself plenty of time to ask questions of your peers, the TA, and me!
  2. One function at a time -
    As your programs get larger, it is very important that you write and debug them a small piece at a time. For example, write one function , compile it, and test it. In order to test it, you may have to write some special code that calls the function and checks to see that the function has performed the correct activity and returns the correct result. Make sure it works completely before you start writing the next function.
  3. Look it up -
    If you come across something that you don't know how to do, look it up. Your book is the first place you can look. It can provide you with lots of examples which help you to understand what the syntax should look like for a particular statement. There are also lots of great resources online. I've included a few links below. Finally, the library also has lots of resources, such as C++ reference books. One of your goals for this class should be to improve your ability to find, understand, and use new information.
  4. Be the program -
    If you cannot figure out why a particular piece of your program is not working, trace through it step by step, acting as the computer would. Make sure you understand what every statement does, and how each statement changes the state of the program. Make sure you evaluate every expression and execute every statement.
  5. Practice good design -
    As you improve your programming skills, you should focus on developing good designs for your programs. Think carefully about how to break your problem down into subproblems that can be more easily solved. Also, think about how each piece of your program may be reused for other kinds of programs. Finally, think carefully about how the pieces of your program will interact.
  6. Write good test cases -
    Before you submit a program, you should test it against every possible set of inputs. This requires you to think very carefully about what inputs might be. Try lots of different examples. Once you finish your program, pretend your new goal is to break it. You are not done with your program until it works for every input.
  7. Take a break -
    If you find yourself getting too frustrated, take a break. Get up and walk around, get something to eat or drink, or exercise. Sometimes a fresh perspective can help you see your program in a completely different way.
  8. A few sources of help -
    http://www.cppreference.com/
    http://www.parl.clemson.edu/~vpatil/docs/c_programming.pdf - skip the middle
    http://faculty.ccbcmd.edu/~bhoffm30/links/compsci/cprogram.html
    http://cplus.about.com/library/blcplustut.htm

Sami Rollins