Ojay - a chaining wrapper for the YUI

Written by on February 23rd, 2008 in Ajax News.

JavaScript is a language that can be approached from many angles. Historically it was UI-driven web developers that started playing with it, but lately and with the advent of large JS applications “the world’s most misunderstood programming language” is also written by people that feel much more at home in higher programming languages. The nature of JavaScript then can become a barrier for fluid and rapid development.

This is where in the best of cases developer specialization comes in - which is not cheap. Another way to tackle the issue is to use metaprogramming to make the end language behave in the way you want it to.

James Coglan got inspiration from Dustin Diaz’ DED|Chain and wrote a chaining wrapper for the the YUI’s DOM, event, animation and Ajax modules called Ojay.

He wraps up his intentions thus:

To me, expressiveness is not just ’syntactic sugar’, a tool to help you type fewer lines of code. It’s a core factor in how maintainable and well-designed your codebase is. We have a team made up of Java devs, a few Ruby enthusiasts and a couple of JavaScripters, and it’s crucially important to us that anyone can look at a piece of code and figure out what it does. Code should tell a story.

What this translates to is shown in this example:

JAVASCRIPT:

$(’a#run-this-code’).on(’click’, $.stopEvent)
    .setContent(’Running…’)
    ._(’#example’).animate({
        height: {to: 0},
        opacity: {from: 1, to: 0}
    }, 0.5)
    ._($.HTTP).GET(’/service/hello.html’)
    .insertInto(’#example’)
    ._(’#example’).animate({
        height: {to: 80},
        opacity: {from: 0, to: 1}
    }, 0.7);
 

I am not sure about the morale of this story, but I can see that we will see more and more of this sort of metaprogramming and skillset mash-up happening in the nearer future. Therefore it is great to start conversations early about how to tackle multidisciplinary teams writing code.

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/239902777/ojay-a-chaining-wrapper-for-the-yui

Comments are closed.



Site Navigation