Top Programming Tips

1. Be consistent in use of variable names and spacing.

Lowercase for Class objects:

Example sequence_search1 = SequenceSearch()

2. Use meaningful variable names.

Using variable names like x and y don't say much. Use names with meaning, like height and width instead. Or better yet, height_of_box, width_of_box. More typing now, less headache later.

 

3. Adding Comments: Can you read and understand the code without comments? If you can't figure out what things do without comments, add comments.

4. Plan Ahead: What are you going to do, and how are you going to do it? Pseudo-code first.

5. Make functions useful but concise. Don't have one function do everything at once. This allows greater flexibility.

6. Break up code into modules. Classes make this easy!

7. Avoid code duplication. (This refers to tips 4,5, and 6.)

8. Use pre-conditions and post-conditions to check your code. Does the function receive the correct input? Does it produce the correct output?

9. Refactoring: Just like in a paper, you can make your programs cleaner with a second draft.