Rules & Tips


Or

Expectations & hopes


Rule #1

Read, learn and follow the coding standards


We need:

  • Consistency
  • Readability
  • Person independent code
  • High quality code
  • Modular and reusable code
 

    Rule #2

    Read, learn and follow the coding standards


    Seriously, read it again. And again.
    You need to follow it by heart. 

      rule #3

      Install the VG coding standard setup for your editor:

      • Netbeans
      • SublimeText 2
      • Vim
      • Zend Studio (somewhere)


      It does not exist, you say? 

      Create it!

      rule #4

      Document your code. 

      ALWAYS. 


      • phpdoc/jsdoc
      • Business logic/magic
      • Not "//Check if string too long" after strlen()
      • Think. What will the new guy need to know?

      rule #5

      Your code should NOT trigger errors, warnings or notices under normal operations 


      • Clean code
      • Initialize variables
      • Don't assume anything ($arrayPassedIn['rareKeyThatIsALWAYSSet'])
      • Catch ALL exceptions

      rule #6

      Your code SHOULD trigger errors, warnings or notices 

      under normal operations


      • Dependencies to external resources

      Pro tip: For cronjobs, trigger warnings when an external resource is unavailable. Set up a Splunk alert to send you an email if the number of occurrences exceed a threshold reflecting a persistent problem (e.g. 24 occurrences in a 25 hours span for an hourly cronjob)

      rule #7

      Know if you're coding for speed or redundancy. 

      At VG it typically is BOTH.


      • Use memcache (cache processing result)
      • Use varnish (cache pages or ESI)
      • Use New Relic to identify performance bottlenecks
       

      • You could also use memcache or varnish to locally cache remotely fetched data (infinite variations, e.g. weather locations)
      • You could fetch data using cronjob, and only read local version (limited variations, e.g. a list of currency prices)

      rule #8

      After launch, use Splunk and New Relic 

      with intent and with a plan.


      • After minutes (real time)
      • After hours, days (dashboards)
      • After months (error alerts)

      tip #1

      NEVER stop assuming you code will fail/be buggy


      • Handle unintended usage
      • Assume every external dependency will fail
      • QA: Attempt to break it before you're done
      • Write unit tests where possible (as small part as possible)
      • Write integration tests where possible (parts combined)
      • That's (one of the reasons) why we multiply estimates with 3.14159

      tip #2

      Position yourself to be the first to know 

      when the shit hits the fan


      Someone says "Your site is down!"


      You say A) "Which site? What's wrong?! Yelp!" 

      or B) "Already working on it, kthxbye."


      Use splunk alerts, daily or instant

        Tip #3

        Be curious. 

        Never stop to challenge yourself. 

        It is human to stagnate - so don't.


        In 1995 the head of the R&D department I worked for had the opinion that C was the language of the future (coming from Cobol). We (recently graduated) tried to persuade him to switch to C++. 

        He was "old" (40+), and had stagnated. 

        Don't become that guy.

        tip #4

        Care. 


        A good definition  of "Result", is: 

        Result = Competence * Effort


        Without Competence you get nothing of value.

        Without effort you get nothing of value.

        tip #5

        Your code is your legacy.

        It is what YOU will be remembered for.


        So, follow the rules and tips. :-)

        Rules & TipsExpectations & hopes

        By jocumsen

        Rules & TipsExpectations & hopes

        • 700