Archive for the ‘Programming’ Category

New York, New York

Monday, November 12th, 2007

I’ve been living in Melbourne for 7 years now, and I have decidely itchy feet.

I moved to Melbourne for work just after the dot-com crash of 2000 and it was always meant to be a temporary stop on my way to New York, which I visited and fell in love with.

I think it’s time to get that dream moving again.

I am happy to work remotely to get a foot in the door, if that suits. Happy to sign up for a short-term contract if it gets me to your fair city.

So, if you’re in New York and need a developer with lots of experience, expert skills in Java, PHP and Ruby, and a penchant for user experience, drop me a line.

Software Federations - the philosophy of Web 2.0 can help solve issues in the Enterprise

Friday, October 26th, 2007

I’ve been pondering the recent spate of comments and discussions about the State of the Software Nation.

Enterprise Systems seem to be broken by design. As SvN declares: Enterprise Software Sucks because the buyers aren’t the users. Khoi Vin recently detailed some of the issues and Sig at Thingamy has been talking about the philosophy of contemporary business software for a couple of years, so none of this comes as much of a surprise.

However, the problem is much deeper and broader than the amorphous cloud of “Enterprise” applications. Lots of consumer-level software has real problems. Jeff at Coding Horror has been posting recently about the troubles with consumer software (Are Features the Enemy? and Why Does Software Spoil?) .
Small, Light, Vertical
———————————————————–

Web 2.0 is a terribly misused term, but the broad sweep of the “philosophy”, rather than the marketing hype is what I am referring to here.

The core ideas underpining Web 2.0 is that the web is a platform, driven by data and enabling systems and sites to be composed by pulling together features (http://en.wikipedia.org/wiki/Web_2).

At the moment we’re seeing the effects of this vision largely in social and personal applications - Flickr, Facebook, Twitter.

But

One of the most interesting recent developments is a slew of small, light, and tightly-focussed applications targeted toward very specific functions. One of the most well-known examples of such an application is the Basecamp Project Management tool.

Although most people seem to associate sites like Flickr and Facebook with Web 2.0, I think the real revolution is in these small vertical applications - common focussed on perfoming a single business function incredibly well. Coupled with elegant, sophistciated interfaces, most of this class of application also offer open access through an API.

Software Federations
———————————————————–

I propose thinking about your “enterprise” software as a loose federation of individual applications.

A Software Federation isĀ  a set of small, light, vertical applications coupled together.

Software Federation

Data flows between your applications through the use of APIs and process flows can be ad-hoc and are focussed on being “good enough” rather than being perfect. Ideally, the Federation is constructed with lightweight frameworks rather than high-end “Enterprise Platforms”.

One of the important ramificationsĀ  of this type of thinking is on the role of the developer. Software Federations require developers who are capable of both understanding the business and creating the code that ties the pieces together. There are some and opportunities here for Domain Specific Languages to help drive developmt and the advances in the handling of REST in Rails 2.0 look like making much of this style of development simpler.

The Republic
———————————————————–

I’ve been thinking about what would be required to assist developing Software Federations. Consuming APIs is already pretty simple and parsing XML data is very definitely a solved problem. What seems to be missing is a lightweight system for managing process flows - something that would allow developers to easily define a flow through an series of applications, combining many small simple scripts to massage and process the data into a single Software Federation. Although “lightweight” and “workflow” don’t really seem to go together - the workflow system I have experienced are all in the category of “Enterprise Software Sucks”, it seems like it may be possible to create a framework that provides support to developers.

What do you think?

Timesheets - the secret to software estimation for Freelancers

Friday, October 26th, 2007

I realised when I started developing projects as a freelance contractor that the real trick was going to be estimation. Software estimation is incredibly difficult, and the only real way of doing it effectively is through an empirical approach:

  • Guess
  • Measure
  • Refine your guess
  • Repeat until you approach accuracy/reality

I’ve been using 14Dayz to track my projects. The Free Plan is more than enough for a solo operator like myself. You can track up to 4 Projects with 10 Categories of work. Categories can have dollar values assigned, and you can generate reports in both time and total dollar values.

The reporting means I can track my budgets for individual projects, as well as track my weekly workload (good for figuring out if you can pay the rent, for example) and I can also gain a precise insight into exactly how long particular tasks take me.
On my current project I have only a couple of final pieces of work to go, and I am am currently only 5% off the budget. At the moment I think I will hit smack on the budget. Not too shabby.

Being able to estimate effectively means you can bid for project work with confidence that you will be on time, and on budget.

This is great for both you and your clients.

Now Hiring!

Tuesday, October 2nd, 2007

Been very swamped with contract work, but I have managed to roll a Facebook App called Now Hiring into production for Taleo.

I had a list of updates, but the blog died a horrible and fatal death, and I can’t for the life of me remember what they where.

Except pagination in Rails with will_paginate is so good it’s terribly terribly frightening

Mock testing with mocha

Wednesday, September 12th, 2007

Mocha is a library designed to let you mock objects in your test environment. It’s very useful for testing around external dependencies

Inside one of my controllers I am calling a SOAP Service:

message_result = SOAPService.send_message(message)

This leaves me with a problem in my functional test - external dependencies are not conduive to self-contained test. Enter Mocha to the rescue!

Mocha lets me create a stub for a method on any instance of my object. This means that I can intercept the calls in my test, without needing to touch the code inside my controller.

SOAPService.any_instance.stubs(:send_message).returns( MessageResult.new )
get :respond
assert_match(/1<\/status>/, @response.body)

The get :respond call above would normally invoke a SOAP call, but using any_instance.stubs(:send_message).returns( MessageResult.new ) means that the SOAPService.send_message method now will return a new MessageResult. My controller doesn’t care and now my functional test is tight and focussed, and tests the controller logic without the external dependency being a factor.

Did you find this Ruby on Rails article useful? Why not recommend Toby at Working With Rails?

RailsRumble: distro decisions decisions

Friday, September 7th, 2007

I received my Linode account for the Rails Rumble.

I logged in and the first thing I have to do is pick the Linux distro I want to install and use for the Rumble.

There are far too many options!

The available distros are:

  • Arch 0.7.1
  • Debian 4.0 (Etch)
  • Finnix 86.1
  • Ubuntu 6.06
  • Ubuntu 7.04
  • CentOS 5.0 (RHEL rebuild)
  • Fedora Core 6 (FC6)
  • Slackware 12.0 (-new-)
  • Mandrake 9.1 (Bamboo)
  • Gentoo Linux 2006.1

I’m not really a systems person … I know my way around Linux, but I don’t have a whole lot of experience setting a machine up from scratch. I’ve been lucky that for the last several years I’ve worked with truly awesome sys admins who take care of all this stuff for us.

So what to use?

I am leaning toward Ubuntu 6.06 (Dapper Drake) because it looks like there are some good tutorials around (I even think the Peepcode guys have been using Ubuntu for some of their work - it might be time to subscribe).

Any ideas are appreciated. I am definitely going to learn a lot this weekend.

Facebook Apps are very hard to debug

Tuesday, September 4th, 2007

I am working on a Facebook Application for a client and although the Facebook API itself is rich and elegant, debugging the app is very difficult. Facebook uses it’s own markup called FBML, which is pulled from your app, translated into HTML and Facebook commands and then displayed. This means that applications have to actually run on a remote server that is accesible by the Facebook back-end.

The development process reminds me of the halycon days of my J2EE days (test,fix,build,jar,war,ear,undeploy,waitdeploy,wait,swear):

  1. Make minor change in code
  2. Push the change to the server
  3. Undeploy the application from the test Facebook profile
    1. Remove application
    2. Delete all sessions and cookies
    3. Clear the local database
  4. Redeploy the application
  5. Find another ******** problem!
  6. Repeat

There has to be an easier way. I am going to look at some DNS magic so I can develop on my local machine and point Facebook to it. Problem with that, of course, is you need to reconfigure the application so the client can see it on a public server. Or run your dev box as public a server.

RailsRumble Notes - WoR! by self.Team

Saturday, September 1st, 2007

You can find all my notes for the RailsRumble in Backpack.

I changed my mind, I am going to keep my notes here in the blog.

Go self.Team!

Rake Task for MySQL Backup to Amazon S3

Saturday, August 25th, 2007

There are a couple of these around, but I rolled my own because I wanted something quite simple.

# S3 Backup Task for MySQL
# Assumes InnoDB tables
# Database User needs the "reload" permission on the database (for --flush-logs in mysqldump)
#
# Stores files in Amazon S3 using the excellent AWS Gem: http://amazon.rubyforge.org/
# For information about Amazon S3: http://aws.amazon.com/s3
#
# Installation
# 1) Install AWS Gem
# 2) Enter your S3 Bucket, access_key_id and secret_access_key in this file
# 3) Run (rake db:backup)
#
# Inspired by code from:
#   http://blog.craigambrose.com/articles/2007/03/01/a-rake-task-for-database-backups
#   http://www.rubyinside.com/advent2006/15-s3rake.html

namespace :db do
  require "aws/s3"

  desc "Backup database to Amazon S3"

  task :backup => :environment do
    BUCKET = "bucket"

    begin
      AWS::S3::Base.establish_connection!(
        :access_key_id     => "access_key_id ",
        :secret_access_key => "secret_access_key "
      )

      db_config = ActiveRecord::Base.configurations[RAILS_ENV]

      backup_path = "db/backup"
      File.makedirs(backup_path)

      datestamp = Time.now.strftime("%Y%m%d%H%M%S")
      file_name = "#{RAILS_ENV}_#{db_config['database']}_#{datestamp}.sql.gz"

      backup_file = File.join(backup_path, file_name)

      sh "mysqldump -u #{db_config['username']} -p#{db_config['password']} --single-transaction --flush-logs --add-drop-table --add-locks --create-options --disable-keys --extended-insert --quick #{db_config['database']} | gzip -c > #{backup_file}"
      puts "Created backup: #{file_name}"

      puts "Storing file in S3: #{BUCKET}"
      AWS::S3::S3Object.store(file_name, open(backup_file), BUCKET)

      puts "Backup Complete"
    rescue AWS::S3::ResponseError => error
      puts error.response.code.to_s + ": " + error.message
    end

  end

end

Snippets: dynamic CSS classes

Tuesday, August 14th, 2007

I found myself over the weekend needing to create CSS classes dynamically. Not just add a class to a DOM element, which is easy, but actually building a CSS class based on user input and attaching it to selected elements.

Proved to be harder than it sounds.

  var green = {
    color: "#00FF00"
  };

  Object.extend(Element.Methods, {
    setClass:function(element, className) {
      element = $(element);
      element.addClassName(className);
      klass = eval(className);
      for (var property in klass) {
        element.style[property] = klass[property];
      }
    }
  });
  Element.addMethods();

  function changeClass() {
    elements = document.getElementsByClassName("red");
    elements.each(function(e) {
      e.setClass("green");
    });
  }

This code lets you specify a “CSS Class” as a Javascript object. Then you can use the Element.setClass to add the properties to the element style. The changeClass() function finds all the “red” elements and sets them to use the “green” Virtual CSS class. I use addClassName to add the new class name, which may cause conflicts with existing CSS classes.

The name is added because I was thinking that I would need a way to remove the class. At the moment I don’t, but it wouldn’t be all that hard to implement. You would store the element’s original properties and remove the class name, and reset all the overridden styles. The disadvantage of what I am doing is overriding the styles at the element level - these will take precedence in CSS.

I am positive there is an easier way of doing this with Prototype and Scriptaculous, so let me know if find one. I looked at interacting with the styles directly using the DOM, but it’s pretty messy.