I l@ve RuBoard Previous Section Next Section

30.1 General

  • Comment, comment, comment. Put a lot of comments in your program. They tell other programmers what you did, and they also tell you what you did.

  • Use the "KISS" principle (Keep It Simple, Stupid). Clear and simple is better than complex and wonderful.

  • Avoid side effects. Use ++ and -- on lines by themselves.

  • Never put an assignment inside a conditional. Never put an assignment inside any other statement.

  • Know the difference between = and = =. Using = for = = is a very common mistake and is difficult to find.

  • Never do "nothing" silently:

    // Don't program like this
    for (index = 0; data[index] < key; ++index); 
    // Did you see the semicolon at the end of the last line?

    Always put in a comment:

    for (index = 0; data[index] < key; ++index) 
            /* Do nothing */; 
  • Practice coding. Practice is crucial for people involved in almost every other profession that requires a significant level of skill and creativity (e.g., artists, athletes). Help others learn to program. It's good practice for you to go over what you already know, or think you know.

    I l@ve RuBoard Previous Section Next Section