Programming Advice from the TAs |
Read over the assignment in full before you begin coding.
Only code once you have at least a general idea of what your plan of action is, and preferably only once you're sure of your data structures and algorithms.
Once you start coding, make sure you compile after every 3 or 4 lines of code you write. This way, if there is a compilation error, you know exactly where it is occurring.
When you write a piece of functionality, test it fully before you move on to the next one. Make sure every small piece of code you write does what you want it to, and that way when things aren't working later in your code you can assume the error is not in the functionality you've already written and tested, but rather in something new.
When compiling, always look at the first error, fix it, and recompile. Oftentimes, the first error causes several more.
Learn what the more common errors mean. Nine times out of ten, the same error is caused by the same mistake.
Comment the top of every function, because:
commenting is worth points, and
it will help you remember what you were thinking when you wrote that function when you have to edit it.
Break code into logical small pieces; this allows easier debugging and code re-use.
Learn how to use a debugger and take advantage of this tool.
Do not come to Thursday's (due date) office hours, download the assignment in front of the TA, and expect help. Start early, and come to office hours with specific questions.
Do not submit code that does not compile. If incomplete, submit code that compiles with limited functionality. (See earlier point about compiling often.)
Read over the assignment again in full after you have finished coding to make sure you haven't missed any requirements.
Backup your work before adding functionality or making major changes.
Proper formatting will make your code much more readable. Learn how to control the indentation settings in your C++ development environment so that it helps format and even auto-color your code for you.
Install and learn how to compile & test your program on your code with the same g++ compiler that the homework submission server uses.
Get to know your graduate TAs and undergraduate programming mentors by name ... they are invaluable resources.
When asking for help in person or sending email to your TA or professor, be thorough and polite and remember that we receive hundreds of emails each semester from students.