Goin' Full Require: Moving To AMD

2012 Nov03

A

MD ( Asyncronous Module Definition ) is a apart of the CommonJS movement. It aims to bring something to javasscript is very much needed in todays world of browser based applications. And that is the idea of modules. A logical way of breaking your apps into smaller, more logical peices and import dependencies only in the situations that you actually need them. RequireJS is at the fore front of JavaScript Module loaders, and for good reason. When you start to dig into RequireJS, you'll find that it isn't just a fancy script loader, but more of a micro-framework for managing large JavaSscript Apps.

Make The Move

Its pretty simple to get started with requireJS - just include the script on the

Read More
filed under:  javascript amd requirejs modules

Fun With Mootools Part 2: Protected Methods

2012 Jul18

P

rivate and protected class methods can come in handy when creating complex applications. While JavaScript doesn't provide these features natively, Mootools provides a mechanism to define protected methods on a class. Protected means that the function can only be called by the originating class or a sub-class of the originating class. An attempt to call a protected function by a different class or from an instance of the class would result in error. Here is how you do that with a mootools classs:

var SecretClass = new Class({  
    Implements:[Options]
    , initialize: function( options ){
        this.setOptions( options );
        var s = this.protectedMethod();
    }

    /**
     * A regular class method 
     */
    ,publicMethod: function( name ){
        alert("Hello" + ( name || "world") + "!");
    }

    /**
     * A protected class method
     */
    ,protectedMethod: function( val ){
        this.stuff
Read More
filed under:  mootools class javascript oop

Pythonic Iterators With Mootools

2012 Jun12

P

ython comes standard with an interesting module called, itertools, which provides a set of functions that make performing complex computations that revolve around iteration much easier. It is actually a invaluable set of tools to have at your disposal when you get comfortable with them. The module itself can work with anything that implements the iterator interface. An iterator is an object wrapper around some sequence that exposes a method called next. When the next method is called, the iterator should return the next item in the sequence and throws a StopIteration exception when there is nothing left in the sequence. While JavaScript doesn't offer anything that would resemble an iterator, that are actually very simple to implement when

Read More

Create A File Watcher With NodeJS and Child Process

2012 Apr16

I

t is not uncommon in the life of a software developer to want to execute a series of tasks every time a file changes. It tends to come up more frequently in development, for example, you might want to concatenate a series of files, or send and email to an administrator, etc. It becomes even more beneficial to be able to watch all of the files in a given directory. Surprisingly, for as much as it seems to creep up, it tends not to be standard machinery it a large number of programming languages and their standard libraries. Luckily, Node.js gives you all of the tools to create a file and or directory watcher.

Now, there are a

Read More

Fun With Mootools Part 1: The Class toElement method

2012 Apr15

T

he MooTools ( My Object Orientated Tools ) JavaScript framework is a pretty sweet piece of software. It's goal is to make developing with JavaScript easier. It provides large set of tools for building complex JavaScript applications. There are a lot of hidden goodies tucked away in the framework that kick off one of those "AHa!" moments. One of those goodies is the toElement method on classes. One of those goodies is the toElement method on classes.

The Class' method, toElement, works in tandem with the MooTools document.id ( $ ) method. In most cases, Classes center around a DOM element for some reason or another. As a convenience, the document.id ( $ ) will call the toElement method when it is passed

Read More
filed under:  dom mootools class javascript oop