tag:blogger.com,1999:blog-306371632024-02-28T18:29:28.373+00:00Tony Byrne's BlogMusings on Software Development and Life in GeneralTony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-30637163.post-41216423530145339882010-11-15T10:32:00.004+00:002010-11-15T10:52:32.551+00:00Jarre's 'Laser Harp' Sound for Propellerheads ReasonThose of you familiar with the music of Jean Michel Jarre will probably have heard, and possibly seen, his <a href="http://en.wikipedia.org/wiki/Laser_harp">Laser Harp</a>. It's a crazy instrument played by passing the hands through laser beams. The Laser Harp has been a feature at many of his concerts over the years and while it's mostly for show, I've always loved the sound, which is generated by an <a href="http://www.vintagesynth.com/elka/elkasyn.php">Elka Synthex</a> synthesizer.<br /><br />I set about recreating the Laser Harp sound in <a href="http://www.propellerheads.se/products/reason/">Propellerheads Reason</a>, using Reason's Thor synthesizer and a few supporting effects. I'm very happy with the results and thought I'd share them. <br /><br />If you have Reason Version 4 or higher, you can download a copy of the Reason patch <a href="http://www.byrnehq.com/public/laser_harp_for_reason.zip">here</a>. If you can improve upon it, then please let me know.<br /><br />Have fun.Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com4tag:blogger.com,1999:blog-30637163.post-9713426909646988232010-11-03T15:23:00.005+00:002010-11-03T15:38:02.923+00:00Mac OS X Java Update breakage.I just <i>knew</i> I shouldn't have let Mac OS X apply the recent Java update. Just a couple of days after the update I had reason to upgrade the rjb ('Ruby Java Bridge') gem. The upgrade process exploded in my face with the following error:<br /><pre><br />checking for jni.h... no<br />*** extconf.rb failed ***<br />Could not create Makefile due to some reason, probably lack of<br />necessary libraries and/or headers. Check the mkmf.log file for more<br />details. You may need configuration options.<br /></pre><br />The problem appears to be missing Java supporting sources that the most recent Java update removed. Luckily, I found the solution over at the nicely named <a href="http://lookfirst.com/2010/10/how-to-fix-missing-source-for-latest.html">Kick me in the nuts</a> blog. For your convenience here are the magic incantations:<br /><br />Step 1: Go to <a href="http://connect.apple.com">http://connect.apple.com and download</a> and download Java for Mac OS X 10.6 Update 3 Developer Package. You'll need a registered Apple Developer account, but it's free.<br /><br />Step 2: Install it.<br /><br />Step 3: Open a Terminal.app window and type:<br /><pre><br />sudo -s<br />cd /System/Library/Frameworks/JavaVM.framework/Home<br />ln -s /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/src.jar .<br />ln -s /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/docs.jar .<br /></pre><br />After the above, developer calm should be restored.Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com0tag:blogger.com,1999:blog-30637163.post-84366976838293061872010-10-31T12:37:00.018+00:002010-11-01T11:12:13.723+00:00Using StormMQs Messaging Cloud with RubyA little while back I was asked by Ross Cooney of <a href="http://www.stormmq.com/">StormMQ</a> to write a Ruby client for their enterprise class managed message queueing service. It was a fun little project. The client code is open source and is hosted on <a href="http://github.com/tonybyrne/StormMQ-Ruby-Client">GitHub</a> and we've also published it as a <a href="http://rubygems.org/gems/stormmq-client">gem</a> for easy installation. What follows is a tutorial explaining how to get up and running with StormMQ's service using the Ruby client.<br /><br />The first thing you'll need is an account with StormMQ, so head on over to their site and <a href="https://stormmq.com/register">register</a>. Registration is free, non-binding and gives you access to the free cloud based message queue service.<br /><br />Next you'll need to install the Ruby client. The easiest way to do this is via the gem. Open a command line and type:<br /><br /><code><br />gem install stormmq-client<br /></code><br /><br />This will install the client and its dependencies on your system.<br /><br />For this tutorial we're going to write some simple code to publish a test message to a queue and then read it back. Since message queues are most often used to build loosely coupled systems that communicate asynchronously via one of more queues, we'll separate the publisher and consumer of the test message by writing each as an independent script.<br /><br />Let's start with the publisher. Launch your favourite text editor, or IDE, paste in the following code and save it as 'publish.rb':<br /><br /><pre><br />#!/usr/bin/env ruby<br /><br /># Before we can call the client we need to require it!<br />require 'rubygems'<br />require 'stormmq/amqp'<br /><br /># For convenience we'll create a hash of the required connection options.<br />client_options = {<br /> :user => 'my_username',<br /> :pass => 'a_very_looooooong_password',<br /> :company => 'my_username',<br /> :system => 'my_username',<br /> :environment => 'development'<br />}<br /><br /># Connect to the AMQP service using the options configured above. <br /># Note, the run() method creates the connection and executes<br /># the code in the block. When the block terminates, the connection<br /># is closed.<br />StormMQ::AMQPClient.run(client_options) do |client|<br /><br /> # Declare a queue on the exchange<br /> queue = client.queue('test1')<br /><br /> # Publish (submit) our test message to the new queue.<br /> queue.publish('Hello World!')<br />end<br /></pre><br /><br />The above code will open a connection to StormMQ's service, using your account details (you did use your account details, right?). It will then declare a queue called 'test1', publish the traditional 'Hello World' to the queue and close the connection.<br /><br />Run it from the command line with<br /><code><br />ruby publish.rb<br /></code><br /><br />That's all well and good, but let's see if we can re-connect to the queue and read the message from it. Returning to the text editor or IDE, open a new file and paste in the following:<br /><br /> <pre><br />#!/usr/bin/env ruby<br /><br />require 'rubygems'<br />require 'stormmq/amqp'<br /><br /># Use the same settings as before<br />client_options = {<br /> :user => 'my_username',<br /> :pass => 'a_very_looooooong_password',<br /> :company => 'my_username',<br /> :system => 'my_username',<br /> :environment => 'development'<br />}<br /><br />StormMQ::AMQPClient.run(client_options) do |client|<br /> queue = client.queue('test1')<br /><br /> # Read the message from the queue and display it.<br /> puts queue.pop[:payload]<br />end<br /></pre><br /><br />Save the new file as 'subscribe.rb' and run it as follows:<br /><br /><code><br />ruby subscribe.rb<br /></code><br /><br />All going well, this should print 'Hello World!' on screen. Congratulations! You've just written your first code to talk to an enterprise class message queuing system.<br /><br />The Ruby client is actually a thin wrapper around the Bunny library, which is an AMQP compliant ruby client. My contribution provides the extra bits needed to support StormMQ's virtual host configuration. My client is also a REST client for StormMQ's configuration system to allow customers to manage their systems. We'll take a look at the REST component of the client in a future blog post.Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com0tag:blogger.com,1999:blog-30637163.post-22579634454367717522009-04-14T15:18:00.003+01:002009-04-14T15:45:49.195+01:00Rails foreign key assignment and belongs_to associationsI keep getting bitten by some odd behaviour in the way Rails handles assignment to the foreign key attribute of a belongs_to association. Specifically, assigning the foreign key id directly, as one might do when processing a form submission with mass attribute assignment, only works for new records or records where the belongs_to association has not already been loaded. <br /><br />There's a long-standing ticket for this issue <a href="https://rails.lighthouseapp.com/projects/8994/tickets/142-patch-belongs_to-association-not-updated-when-assigning-to-foreign-key">here</a>, but little progress seems to have been made in resolving it.<br /><br />Frankly, this is a pain in the ass. I wasted a ton of effort on trying to workaround this problem, finally resorting to monkey patching ActiveRecord, which then broke when we tried to upgrade our application to Rails 2.2.2.<br /><br />On another trip on the merry-go-round this morning, I got lucky and finally spotted a solution that I'd missed before. While others were debating the merits / demerits of various patches and whether all cases were adequately covered, Matt West who opened the ticket, provided a fix in the form of a plugin:<br /><br /><a href="http://code.torchbox.com/svn/rails/plugins/belongs_to_synchronisation/">http://code.torchbox.com/svn/rails/plugins/belongs_to_synchronisation/</a><br /><br />Unfortunately, it was hidden in a blog post linked from the ticker. See the original blog post <a href="http://matt.west.co.tt/rants/opinionated-plugins/">here</a>.Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com0tag:blogger.com,1999:blog-30637163.post-15570615526847650572009-03-30T08:58:00.007+01:002009-03-30T09:43:08.369+01:00How not to implement a web service using SOAP.Twice in the last six months, I've been faced with implementing a client for a SOAP-based web service. On both occasions there's been a distinct lack of sunshine and rainbows.<br /><br />After the initial optimism ("this should be easy - it uses SOAP") faded, things went downhill fast. It's an anti-pattern that I expect to see again soon.<br /><br />The initial exploratory exchange for getting two systems talking over web services, typically goes something like this:<br /><br />Our Business People: "We'd like our Fobniculator system to be able to talk to your FooBarWidget web application so that going forward we leverage the synergies to bring about a positive sales variance."<br /><br />Their Business People: "Sure! We'll get our nerds to talk to your nerds."<br /><br />Some considerable time passes...<br /><br />Me: "What platform is your FooBarWidget web application built on?"<br /><br />One of Their nerds: "VB.NET. What about your Fobniculator system?"<br /><br />Me: "Ruby on Rails."<br /><br />One of Their nerds: "That's okay! Our web service uses SOAP. SOAP is platform and language independent and is great for interoperability. Oh, and our interface is so simple. I'm sure Ruby on Rails can talk SOAP?"<br /><br />Me: "It sure can! Ruby on Rails prefers RESTful web services, but SOAP will work. This should be very easy, I'll be done by lunch. Hey! Talk to me a bit about the interface that allows us to update a FooBarWidget's data."<br /><br />OoTN: "No problem. You call the FooBarWidgetUpdate() method and pass an instance of a .<span style="font-weight:bold;">NET DataSet</span> containing the data for the FooBarWidget."<br /><br />Me: "Um, in what way is that platform independent?"<br /><br />Awkward silence...<br /><br />OoTN: "What do you mean? It's SOAP ain't it?"<br /><br />Please, if you are going to tie your web service to .NET by using proprietary objects that shun the platform independence of SOAP, then please don't pretend that you are doing the rest of us any favours.Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com0tag:blogger.com,1999:blog-30637163.post-18558106893407334792007-05-08T13:33:00.000+01:002007-05-08T14:48:24.598+01:00Acceptance Testing in RubyI'm teaching myself Ruby with the help of a 'toy' project. Sometime ago I wrote <a href="http://search.cpan.org/~tjbyrne/PerlActor-0.02/">PerlActor</a>, an Acceptance Testing framework that was inspired by <a href="http://www.exoftware.com/">Exoftware</a>'s <a href="http://exactor.sourceforge.net/">Exactor</a> open source project. I thought it would be educational and fun for me to port my Perl effort to Ruby. I've made good progress to date and I've learnt a lot about Ruby along the way. However, a question arises: Is an Exactor / PerlActor style testing framework useful for Ruby projects? <br /><br />Exactor and PerlActor express tests in a simple language specific to the domain under test. They take an approach similar to FIT, but with test cases stored in simple text files, rather than embedded in HTML tables. By way of an example, a typical PerlActor test, in this case for a web application, might look like the following: <br /><br /><code><br />NewUserAgent<br />GoTo http://www.google.com/<br />PageTitleShouldContain Google<br /></code><br /><br />'GoTo','NewUserAgent' and 'PageTitleShouldContain' are commands, which are domain specific and either provided by the framework or implemented by the user of the framework. Exactor comes with a library of such commands. PerlActor is more basic, with the supplied commands really just being examples.<br /><br />IMHO, a big selling point of this approach to testing is the customer-friendliness (in the Agile sense) of the tests. The test cases are very readable and it's possible for customers to write their own acceptance tests without needing to learn a complex syntax.<br /><br />With Ruby's excellent support for meta programming, it may be possible to express such tests in Ruby code, while keeping the syntax as clean as the above. I'm not sure how to acheive this level of simplicity in Ruby and so I would be interested in hearing your opinions.Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com4tag:blogger.com,1999:blog-30637163.post-64893214511586833552007-04-13T15:12:00.000+01:002007-04-13T15:48:29.459+01:00Ruby IrelandRuby is a fascinating language whose star is rising thanks to the buzz being generated by the Ruby on Rails web development framework. I've been itching to try Ruby on a real world project for quite some time, but alas the day job is stubbornly Perl-centric.<br /><br />To get a much needed Ruby fix, I attended my first <a href="http://groups.google.com/group/ruby_ireland">Ruby Ireland Group</a> meeting last Tuesday at the Morrison Hotel in Dublin. The turnout was good with about a dozen folks in attendance. I thoroughly enjoyed the two presentations and the followup nosebag in the nearby La Taverna di Bacco.<br /><br /><a href="http://ozonesoft.net/">Olivier Ansaldi</a> gave us a whirlwind tour of Why The Luck Stiff's Camping web framework, which manages to be both very weird and very clever. <a href="http://www.davidjrice.co.uk/">David J Rice</a> scared us with his plans for world domination using an army of Giant Robots controlled by Distributed Ruby (Drb) code.<br /><br />The Ruby Ireland group plans to meet on the 2nd Tuesday of every month in the Morrison. If you have an interest in Ruby and related technologies then come along a take part in the fun.Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com0tag:blogger.com,1999:blog-30637163.post-1152108945064813382006-07-05T13:42:00.000+01:002006-07-06T00:46:17.000+01:00The Transaction Script Pattern<div align="justify">I recently called upon the services of the Transaction Script pattern to organise new business logic for my current software project. I had a bunch of procedural and database-centric logic to implement and needed a way to structure it so that it would be maintainable. I appear to have chosen a reasonable solution, because this pattern has helped me create a simple design that, so far, has proved easy to work with. I also ended up with code that is more readable than I could have hoped for. Go me! <br/><br/>The Transaction Script pattern is as simple as they come. It organizes multi-step business logic into discrete procedures with each procedure implemented either by a single method, or by a group of methods within a dedicated class. The pattern takes its name from the fact that most often a procedure will be executed within the scope of a single database transaction.<br/><br/>Martin Fowler presents the Transaction Script pattern in his book <a href="http://www.amazon.com/gp/product/0321127420/sr=8-1/qid=1152142776/ref=pd_bbs_1/103-6388593-6871805?ie=UTF8">Patterns of Enterprise Application Architecture</a> and it is also catalogued on his <a href="http://www.martinfowler.com/eaaCatalog/transactionScript.html">site</a>.<br/><br/>In adopting the pattern for my own code, I opted to give each procedure its own class, a la the Command pattern / Object Method refactoring. I think that this decision has been central to my success with the Transaction Script pattern. <br/><br/>I found that partitioning the procedures into their own dedicated classes made for rapid progress, because it facilitated ‘coding by intention’ and refactoring. I was able to decompose each procedure into a set of small and cohesive methods that found a natural home within the class implementing that procedure. These methods could thus share state via instance variables, which removed the need pass data around. Where logic was duplicated across procedures, I found that I was able to extract the duplicated code into a method and pull it up to the base class. <br/><br/>I’m very happy with how it’s playing out so far, but it will be interesting to see the long-term maintainability of this design.<br/></div><br/><br/><br/><br/>Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com2tag:blogger.com,1999:blog-30637163.post-1152047173225023852006-07-04T21:08:00.000+01:002006-07-06T00:46:57.970+01:00WTF?<div align="justify">If you're a Software Developer, or you work with developers, then you'll probably get a kick out of <a href="http://thedailywtf.com/">The Daily WTF</a>, a look at "Curious Perversions in Information Technology". I came across the site a few weeks back and became hooked. I read it every day with my morning coffee (I find it's best not to attempt to drink the coffee until after you've read the post).</div>Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com0tag:blogger.com,1999:blog-30637163.post-1152013616437648282006-07-04T12:46:00.000+01:002006-07-04T21:04:41.366+01:00A Blog is Born<div align="justify">Well I've done it now! I've created a blog. A chain of events has been set in motion that can lead to only one of two outcomes. Either: a) I'll become famous and have riches beyond measure, or, b) I'll experience abject public humiliation and be forced to slink back into the shadows. Okay, so maybe these aren't the <i>only</i> possible outcomes.<br /><br />So why have I to created this blog? Before embarking on this project, I did some brief <a href="http://home.comcast.net/~diane.schiano/Blog.draft.pdf">Googling</a> into motivations for blogging. I wanted to understand why I was attracted to the idea of writing a blog. I discovered that I fall squarely into the 'Blog as Muse' camp, which sees blogging as 'thinking' through 'writing'. I look at blogging as an opportunity for me to stop and think on a regular basis. Hopefully, sometime in the future I'll be able to look back at my collected musings and see how my thinking has evolved.<br /><br />What will I be writing about? Well, I'm a Software Developer and I tend to think quite a bit about the practice of my trade. For the last few years I've been learning about Agile Software development - mostly in the form of Extreme Programming (XP) - and how Agile techniques can improve the chances of success on software development projects. I expect this blog will have a fair amount to say on my experiences of software development and agile methods. </div><div align="justify"><br />No, wait! Come back! I'll throw in some other stuff, if you promise to hang around.</div>Tony Byrnehttp://www.blogger.com/profile/08422253792461424212noreply@blogger.com0