Colour Diary

My family spent a week in Finland this summer as part of our summer holiday. One of the many highlights was a visit to the design museum in Helsinki which is excellent and well worth a visit if you go there. The ground floor was dedicated to the work of Margrethe Odgaard, an artist/artisan from Copenhagen who has an exquisite eye for colour, particularly, but not exclusively, in textiles. One of the things presented were colour diaries that she’d kept on visits to Morocco and Cuba that were fascinating and beautiful. It gave me an idea for a simple phone app that I could build that would allow me to do the same thing, so I created it using Meteor. If you have an android phone, you can download it for yourself from the Google Play store. It’s in beta because Ive not done this before and at the moment I only know that it works on my phone. I’d love to hear any feedback you might have.

Coffeescript constructor options with defaults

Coffeescript has a nice way of destructuring assignment in a class constructor, e.g.

class Person
  constructor: (options) ->
    {@name, @age, @height} = options

This is elegant and efficient and has the additional benefit of explicitly communicating anticipated class attributes, cf:

class Person
  constructor: (options={}) ->
    for key, val of options
      @[key] = val

which allows any old thing to be added to your object (although admittedly this is sometimes desirable).

Coffeescript also has a neat way of setting default values for functions, e.g.

fill = (container, liquid = "coffee") ->
  "Filling the #{container} with #{liquid}..."

But this pattern doesnt seem to transfer to destructuring class assignment.  I can’t for instance use any of these approaches:

class Person
  constructor: (options) ->
    {@name = "Ken", @age, @height} = options # (yields an "UNEXPECTED=" error) or
    {@name: "Ken", @age, @height} = options # (yields a "Ken" CANNOT BE ASSIGNED error)
    {@name ?= "Ken", @age, @height} = options # (yields an "UNEXPECTED COMPOUND ASSIGN" error)
    {@name? "Ken", @age, @height} = options # (yields an "UNEXPECTED LOGIC" error)
    {@name || "Ken", @age, @height} = options # (yields an "UNEXPECTED LOGIC" error)

It turns out that the best way (IMO) is:

class Person
  constructor: (options={}) ->
    {@age, @height} = options;
    @name = options.name ? "Ken"

Note that the default value for options is included, so as not to force a parameter on the constructor.  As always, stack overflow provides a deeper picture.

Woodentrack

Last year in a slow period I knocked up a javascript library for making wooden toy train designs as a useful/interesting exercise.  After getting some implicit feedback on it last week (somewhat baffled), I decided to review it, give it a spruce up and add some more explanation.  It’s still barely a proof of concept but you can see the results here.

The next pieces of work (should I get the chance) will probably focus on:

  1. finessing the API, i.e.   “Create a track at the browser command prompt, attach a track painter and watch the drawn track change as you add/remove pieces and edit the track properties” and
  2. adding annotations to the free ends of track drawn in the DSL demo so it’s clear how to add more track to them.

Netbeans file type integration tutorial comments

Netbeans 7.1rc1 has been released. When I went through the file type tutorial (which has been updated for 7.1) I found a couple of minor niggles which needed more than a couple of lines in a comment to express, hence this post.  In Summary, it’s a good tutorial, but there a few rough edges that could be ironed out:

  • A design bug in the properties window section,
  • Missing the visual library api dependency,
  • Excessive overiding the default action on file context menu,

and it would really benefit from some extensions, particularly:

  • implementing a navigation window instead of a node tree under the file node,
  • real-time synchronisation across all views.

Continue reading “Netbeans file type integration tutorial comments”

Installing Padrino on Ubuntu / Debian

I’ve been tinkering with Padrino this week. Padrino is a ruby web framework built on top of the delightful sinatra microframework. I found it attractive because

  • it appears to have a simple design, as you’d expect of something built on top of sinatra,
  • it rolls in the various elements that you’d expect for a fully fledged web framework (i.e. orm, database, mailer) but makes no commitments to the particular modules used for each *
  • it had a default Admin interface (which is a huge win for Django IMO).

There’s quite a bit of supporting material on the web, but my impression after a few hours is that it’s still pretty beta and has a strong leaning towards RHEL linux. So this post details the steps I had to take to be able to work through the basic project guide with Ubuntu Lucid Lynx. Continue reading “Installing Padrino on Ubuntu / Debian”

Eclipse + Ubuntu + Groovy pain

A couple of days ago the v2 Groovy Eclipse plugin was released, but sadly I’m still not able to use it on my Ubuntu desktop because of a fairly convoluted set of configuration problems.

The first is that the linux download of eclipse doesnt work very well in the latest version of Ubuntu (Karmic Koala). A work around is described here with further links to Ubuntu’s issuelist. But actually the work around is only a partial fix because Eclipse sometimes starts a copy of itself and, when it does, it ignores the work around. This affects me as I’m currently trying to develop plugins.

One alternative approach that has worked for me so far is to use the version of eclipse that’s in the Ubuntu repositories. However, this version wasn’t taken from the final release of the eclipse codebase and the groovy plugin install, which patches the JDT (Java Development Toolkit) just wont install in this version.

So to use the groovy plugin it looks as though I’ll have to wait for Eclipse 3.5.2 (which is due on February 29th).

Scripting languages in Java – manipulating an EMF model

I’m currently attempting to embed a scripting engine into a Java application. The Java Scripting API means this exercise should be quite straightforward (at least to get something up and running) and there is a huge choice of script languages to choose from so one of them ought to match my requirements, right?

I’m taking baby steps while I explore the space of possible options.  So far I’ve prototyped an expression evaluator that accepts data in the form of simple Java  framework objects and allows boolean expressions to be evaluated over them. In today’s baby step I thought I’d try and manipulate some non-framework Java objects built with an EMF model that I’m currently working on and two different scripting languages, Groovy and Rhino. Groovy is a scripting language that has grown out of the Java community in response to Python and Ruby.  Rhino is a Javascript engine implemented in Java from the Mozilla foundation that is bundled as the default scripting engine in the Java6 JDK.  I got somewhere with Groovy but got completely stumped with Rhino because I just couldn’t load my custom classes.

Continue reading “Scripting languages in Java – manipulating an EMF model”

ArgKit: An argumentation toolkit

ArgKit websiteLast week I released an open source project: ArgKit. It’s the synthesis of some work that I’ve been doing in the last couple of years and I’m very pleased with it. I’ve released early (ish) on this one, so there is more work to come in the same vein, time and attention allowing. One thing that ArgKit’s website misses is some background on “what is argumentation?” so I thought I’d just blog something about Dungine – the only tool in the toolkit at the moment, based on an email I sent to a friend recently (thanks for the question Steve).

Continue reading “ArgKit: An argumentation toolkit”