Archive for the ‘open source’ Category

Add haXe to your toolset

haXe is an amazing project.  I've been looking at it recently as an option for producing swfs that potentially perform better than ones produced with similar code written in AS3.  Even more interesting, however, is the ability to target more than one platform with the same code base.  There are several target platforms but the one that captures my attention at this moment is the Javascript target and the fact that existing Haxe libraries such as Physaxe can be used with the HTML5 Canvas element.

The Physaxe library contains a custom type called JsCanvas that acts as a wrapper for the Canvas element and it's 2d drawing context.  JsCanvas shares the same method names as the graphics property belonging to display objects in Actionscript.  Compiler conditionals are then used in another class called FlashDraw to determine whether or not a member variable will be of type flash.display.Graphics or phx.JsCanvas.

It's worth checking out.

Posted by admin on June 3rd, 2010 1 Comment

PureMVC notes

Here are notes that I wrote down during Javier Julio's PureMVC talk at FITC Amsterdam a couple of weeks ago.  I intend to use pureMVC and they'll be a useful reference when the time arrives.  If I have glaringly misconstrued anything please let me know :-)

The Proxy and Mediator

  • The Proxy typically sends notifications
  • The Mediator receives notifications and can also send notifications
  • The Proxy is located in the Model and is a natural location for domain logic, something that tends to be wrongfully be placed in Commands
  • The Mediator performs the key task of separating the View and Model (which is the responsibility of the Controller in Cairngorm)
  • The Mediator and Proxy have a similar setup
  • Methods to override in the Mediator include;
    • listNotificationInterest(),
    • handleNotification()

About Commands:

  • Since service interaction occurs in the Proxy (located in the Model), commands in the Controller are limited to things like; startup, shutdown.
  • A Command is used when you want to do multiple things in response to a notification.
  • Mediators can directly call methods on the Proxy instead of sending a notification.  You don't have to create a Command for everything.
  • Method to override in Command
    • execute()

The Facade

  • Facade is where you retrieve, register and remove actors.
  • The Proxies, Mediators and Commands all have access to the Facade.
  • Some of the methods to override in Facade:
    • retrieveProxy(proxy)
    • registerMediator(mediator)
    • registerCommand(command)

Update:

Javier got in touch with me and kindly pointed out a couple of things that I had got wrong and also offered some encouragement.  These are a few points he made (I've made the amendments to my notes above):

"The Proxy contains controller-like code but is actually in the Model part of the architecture"

Javier - I'm not sure where you picked up this one but definitely not the case, or at least not for the Proxy. You'll find that the Mediator already acts like a controller and that can trip people up about the framework. The reason for this is that the Mediator already does the key job of separating the View Component from the Model (e.g. a or many Proxy class) thus you don't really have a huge need for commands, in fact very little. This is expected and because the Mediator essentially acts like a controller.

"...Controller are limited to things like; startup, shutdown, database calls."

Javier - I could be misunderstanding database calls here as you could mean that a Proxy that makes a call to the server to fetch data from a database but was triggered by a command. Or say an AIR app that can interact with SQLite. But things like that you want to avoid having in the Command and move into the Proxy. This is one of the big differences between PureMVC and other frameworks because by moving service interaction into the model we can achieve portability and reusability.

"Mediators can directly call methods on the Proxy instead of sending a notification sometimes.  You don't have to create a Command for everything."

Javier - Cliff Hall, the creator of PureMVC, and others, especially myself couldn't be more proud. :) You learned probably one of the most important things to take away from the presentation. A lot of people get this wrong. I use the word "wrong" as Cliff has stated very good reasons why this is not only acceptable in the framework but pushed for you to do. Don't create a command class for an action that only ever happens in one place, you are just doing more work and adding more bloat.

Posted by admin on March 11th, 2010 1 Comment

Setting up Python on my Macbook Pro

I bought a MacBook Pro a couple of months ago (having always worked on Windows) and have started to learn Python.  The first step was to install Python but OSX 10.5.7 actually comes with Python 2.5 pre-installed.  This was handy to get up and running, allowing me to type Python code in the terminal straight away and helping me check that I installed Pydev correctly but I decided to take this advice and upgrade to a newer version.

I opted for ActiveState's Python distribution 2.6.2.2.  I'm really liking the modular nature of Python and using easy_install and pip.  A problem arose, however, when it came to targeting my second Python installation.  The easy_install exe program will target the default installation since it is defined on the System PATH variable.  ActiveState sets up a symbolic link for Python in /usr/local/bin and you can make ActivePython first on your PATH in the terminal window by entering the following:

PATH=/usr/local/bin:$PATH; export PATH

Now when I start Python in the terminal it will be version 2.6.2.2 (i.e., my second installation).  By exiting Python (ctrl+d), I can then add packages (such as numpy) that target this version using either easy_install or pip commands:

easy_install numpy

If I wanted to install a package that I downloaded that has a '.pkg' file extension I found that it also targeted the default Python install for the same reason.  My solution was to also install the package from the terminal by doing the following:

PATH=/usr/local/bin:$PATH; export PATH
cd /Volumes/wxPython2.8-osx-unicode-2.8.10.1-universal-py2.6/
sudo installer -pkg wxPython2.8-osx-unicode-2.8.10.1-universal-py2.6.pkg -target "/"

This is pretty standard stuff but I thought I'd share since it took me a little while to figure out :)

Posted by admin on September 20th, 2009 3 Comments

OSS Barcamp, Dublin; Slides

I gave a lightening talk on Flex using the Flash Develop IDE at OSS Barcamp in Dublin at the weekend.  It was quite a challenge fitting everything into 15 minutes but I just about managed to fit a code demo in.  Here are my slides:


It was great listening to talks and speaking with people involved in technologies other than Flash Development.  Next week I plan on attending the Drupal weekend in Galway after meeting a couple of the Drupal guys on Saturday.

Posted by admin on March 30th, 2009 2 Comments