Long story short, documentation has to match, even if its across multiple sites. Current official pureMVC JavaScript port is messy and definitely does not match the documentation at MooTools.

Simply put:
Here’s how mootools show their Class usage example:

[cc lang="javascript"]var Animal = new Class({
	initialize: function(options){
		this.options = options;
		this.isAlive = true;
	}
});
 
var Mammal = new Class({
	Extends: Animal,
	initialize: function(options){
		this.parent(options); 
		this.isWarmBlooded = true;
		this.hasFur = true;
		this.producesMilk = true;
	},
	sleep: function() {
		this.isAsleep = true;
	},
	awake: function(){
		this.isAsleep = false;
	}
});
[/cc]

Implementation at pureMVC_JS

[cc lang="javascript"]var SimpleCommand = function(){
    this.Extends = Notifier;
    /**
     * @ignore
     */
    this.initialize = function()
    {
	this.parent();
    }
    /**
     * Fulfill the use-case initiated by the given Notification.
     *
     * 

* In the Command Pattern, an application use-case typically * begins with some user action, which results in a Notification being broadcast, which * is handled by business logic in the execute method of an * ICommand.

* * @param {Notification} notification the Notification to handle. */ this.execute = function(notification /* Notification */){} } SimpleCommand = new Class(new SimpleCommand());[/cc]

My implementation pureMVC-oop.js

[cc lang="javascript"]SimpleCommand = new Class({
    Extends : Notifier,

    /**
     * @ignore
     */
    initialize : function(){
		this.parent();
    },
    
    /**
     * Fulfill the use-case initiated by the given Notification.
     *
     * 

* In the Command Pattern, an application use-case typically * begins with some user action, which results in a Notification being broadcast, which * is handled by business logic in the execute method of an * ICommand.

* * @param {Notification} notification the Notification to handle. */ execute : function(notification /* Notification */){ } });[/cc]

I have adapted the syntax suggested in MooTools for this port. Why this was not done in the beginning I have no clue. Sure, I had to use a hack here and there when using pureMVC, specially with “static” values, but still its cleaner than the current official version

Categories: Blog

3 Comments

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.