×

SparkFun Support and Front Desk will be closed on Thursday 11/14 from 1-2:30pm for a company event. Please plan to pick up your orders before or after this timeframe.

Member #955510

Member Since: April 19, 2017

Country: United States

  • I think you've hit many of the core ideas. As a software engineer, a few things I find will help reduce bugs in code:

    • As mentioned elsewhere, putting constants on the left side of your conditional can help catch some errors (for instance, 7 = a rather than a = 7). This is more obvious to a human eye and compilers can flag this error.

    • Put the shorter condition block first. Rather than:

      if (condition) {
          // Really
          // Long
          // Complex
          // Block
          // Of
          // Code
      } else {
          // Short block
      }
      

      Instead do:

      if (!condition) {
          // Short block of code
      } else {
          // Really
          // Long
          // Complex
          // Block
          // Of
          // Code
      }
      
    • I have watched new programmers learn conditionals, exercises are crucial to this process. In other words, definitely yes to the home works.

No public wish lists :(