Random musings

    A seperation of concerns

    2015-03-05 20:00:00 +0000

    Another antipattern I come across in legacy codebases is a lack of a separation of concern.

    <div id="main" style="width: 330px; border: 1px #ccc solid">
        <h1 onclick="loadList()">Top 5 girls name</h1>
        <ul style="display: none;">
            <li onclick="clickName('Sophia');" 
            style="border-top: 1px #ccc solid; border-left: 1px #ccc solid; border-right: 1px #ccc solid;">Sophia</li>
            <li onclick="clickName('Emma');" 
            style="background-color: #eee; border-left: 1px #ccc solid; border-right: 1px #ccc solid;">Emma</li>
            <li onclick="clickName('Olivia');" 
            style="border-left: 1px #ccc solid; border-right: 1px #ccc solid;">Olivia</li>
            <li onclick="clickName('Ava');" 
            style="background-color: #eee; border-left: 1px #ccc solid; border-right: 1px #ccc solid;">Ava</li>
            <li onclick="clickName('Isabella');" 
            style="border-left: 1px #ccc solid; border-right: 1px #ccc solid; border-bottom: 1px #ccc solid;">Isabella</li>
        </ul>
    </div>

    Here we have a few issues,
    read more

    Don't flatten your ajax calls

    2015-03-04 20:00:00 +0000

    A massive anti-pattern when dealing with Ajax calls in javacript is to send in a success parameter into the ajax options.

    function getInfoByID(id) {
        $.ajax({
            url: "/my-service/data",
            data: { rowID: id },
            success: function(data) {
                console.log("I've just got some data:", data);
            }
        });
    }
    getInfoByID(1);

    Of course a better way
    read more

    The holy grail of javascript loaders

    2015-03-03 20:00:00 +0000

    So I’ve been watching the world of module loaders in javascript over the past few year, too nervous to jump in to either CommonJS or RequireJS in fear of getting it wrong.

    Just as we started to feel like making the jump, ES6 modules seemed to take the world by storm, offering a fresh new and elegant solution. The fear is - es6 modules are not baked into the browsers yet, so is it too risky to jump into ES6 already?

    My answer is no!
    read more

    Move a repository from svn to git

    2015-03-02 20:00:00 +0000

    After recent company changes, it is becoming clear we are migrating some of our SVN repos to git. A collegues was kind enough to push the current codebase up to the shared git space, but sadly the import process lost the full history.

    I was sure this should already be a solved problem and after a little research I found
    read more

    Working with ruby on OSX

    2015-03-01 20:00:00 +0000

    I’ve been trying to get my head around how to be productive on OSX. I often come along script commands to facilitate the development process and take alot of the menial tasks off to a short script in a command line. However I’m often stumbling around in the dark. An example of this is using jekyll to compile my blog.

    Every time I come to write a blog post (once every 3 months going by history) I have to re-rememeber how to compile. Inevitably I think “How do I compile the site?” and type “Jeckyll” into google (Yes my spelling is atrocious).
    read more