Software Development

  • Servers
    • Make sure your servers are set to use UTC/GMT (without Daylight Saving Time)
    • If at all possible use creative names for your servers
      • There’s nothing worse than spending a day trying to diagnose an issue, just to find out that it was a one letter typo on a server name in a config file somewhere
    • Use DNS to your advantage
      • Don’t expect server names and IP addresses to never change!


  • Dates and Times
    • .Net’s libraries are not that great/accurate when dealing with timezones and DST
    • Use the NodaTime libraries instead of the built-in  .Net libraries
    • Use MomentJS instead of the built in JavaScript functions


  • JavaScript
    • Avoid it if you can 😉 JavaScript is by far the most ‘broken’ language I’ve ever worked with.
    • Avoid using the built-in Date and time constructs – they really suck!
      • Use MomentJs instead
    • JavaScript uses lexical scoping
    • GOTYAs to look out for:
      • undefined
        • undefined should probably have been called ‘uninitiated’ really
        • undefined is not the same as undeclared
      • Run in Strick Mode whenever you can.
      • When not running in Strick Mode JavaScript will ‘helpfully’ create global scope variables for you on the fly when you forget to declare them in local scope = BUGS
      • The this keyword is not actually a reference to yourself
      • Catch clauses are block scoped – variables declared inside a catch block can only be used in that catch block
        • Except in IE6 where you can reference the variable outside the block scope
      • with keyword issues:
        • If you try make an assignment to a variable on an object, and that variable doesn’t exist on the object, then JavaScript will look for or create said variable in the outer scope! WTF! Easy route to creating auto globals and bugs.
    • Advantages of using named function expressions over anonymous function expressions:
      • You can reference the function from within it’s own scope, which is useful for things like:
        • Unbinding click handlers
        • Recursion
      • The name won’t pollute the outer scope
      • Helps with debugging through a stacktrace, because you have names to work with instead of just anonymous, anonymous, anonymous…
      • It self-documents code, which makes the code a little mode understandable.
    • eval is evil 😉
      • It will also make your code run slower
    • with keyword is more evil and eval
      • Creates a whole new lexical scope at runtime
      • Disables compiler optimizations
      • Is completely disallowed in Strict Mode anyway 😉
    • Don’t use setTimeout with the string syntax
      • Will get evaled at runtime
    • IIFE Pattern  (Immediately Invoked Function Expression):
      • Helps your code better by hiding stuff from the Global Scope
      • (function iifeName(){ <code here> })();
      • (function iifeName(global){ <code here> })(window);
      • (function iifeName($){ <code here> })(jQuery);
    • let keyword coming in ES6…
      • Forces block scoping
      • Follows the principle of least disclosure 🙂
      • Possible performance optimizations
      • Describes intent better
        • for (let i=0; i<length; i++){}
        • i doesn’t leak into the function scope
      • Fewer bugs


More tips to follow soon….

Comments - Have your say ;-)

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s