Digiguru.co.uk

Random musings

    The Command Pattern in Javascript and why you should love it

    15 Mar 2015

    One pattern that I love to use in rich javascript applications is the Command Pattern. By embracing it you unlike your program to the ability to have multi-undo events, macro recording, but more and more prevalent in the sort of sites you see today, the way to distribute events to multiple clients (browsers) at once. Another advantage is it makes you app really easy to test - you can fire the Commands at your app and do some very deep tests on rich interfaces.

    The pattern is described by having the following objects…
    read more (2 minutes)

    Fecth API - one more dependency out of your javascript code

    14 Mar 2015

    Ajax requests have been one of the brightest things to happen to the web. It enabled richer applications. Finally the web consortium has agreed on an API to simplify the activity of getting data into a document after it has loaded.

    Back in the day we used XMLHttpRequest() - but different browsers had different implementations.
    read more (1 minute)

    How to refactor javascript when you have too many files

    13 Mar 2015

    You know what I hate? Having to maintain a codebase of thousands of inter-connected javascript files that have layers upon layers of dependencies. Somewhere along the line we thought “It’s good to separate concerns” - but I guess not everyone understood what “separate” means.

    You know what I love? Refactoring.
    read more (2 minutes)

    Don't use an OR statement in your join clause

    12 Mar 2015

    Found an interesting little problem recently. We had a query we wanted to upgrade for the next release, and added an OR statement to allow us to pre-release the functionality for the new code drop. This had a really big impact on performance and caused lots of issues.

    When we investigated it turns out that OR queries in a join are really expensive. Consider the following statement.
    read more (1 minute)

    Rename a git branch

    11 Mar 2015

    After moving our repos from svn to git, we’ve need to rename some of the branches - a simple way of grouping up logical branches.

    We have the following naming conventions for our branches.
    read more (2 minutes)