Presenting at ERubycon in August

I’m extremely excited to announce that ERubycon has accepted my proposal to speak on JRuby testing of JEE. ERubycon is unique in that it is expressly focused on Ruby in the Enterprise. While “enterprise” is a squishy term to me (my take on it is “legacy/internal facing/business-to-business/large scale development”), I suspect that the constituency will be somewhat different than the other Ruby conferences that I’ve attended this past year (i.e., RailsConf, RubyConf, Ruby Hoedown, and Ruby East). As the majority of my work falls clearly into the enterprise space, I’m looking forward to ERubycon.

ERubycon is August 15-17 in Columbus, Ohio. I hope to see you there.

Improving Java unit testing and introducing jrsplenda v0.1.1

Last week, I wrote about the pain of Java unit testing. At the end of it all, I said that I would supply some answers “tomorrow”.

One week and one RailsConf later, I’ll call this “tomorrow”.

In the previous article, I listed a handful of commons Java idioms that reduce testability. Three out of four of the issues may be rolled up into a higher level of abstraction: encapsulation kills. The remaining point may be summarized as Spring XML == code that most developers don’t test. Encapsulation prevents developers from injecting mock objects into their code. Without mocks, the unit under test lacks isolation. Without isolation, your unit test is an integration test at best and a massive FAIL at worse.

If you endured a Computer Science curriculum in college, I’m reasonably sure that the professor of your second or third CS class repeatedly hammered home: encapsulation is a key tenet of good object-oriented design. However, many dynamic languages only provide a brief nod, if any, to the encapsulation gods. For instance, Python does not support private or protected members. While Ruby does, it is trivial to route around those protections. What some may not realize is that, in this respect, Java is little different than Ruby.

Yes, that’s right. Java can be a bit on the promiscuous side of things too.

Continue reading →

Pastie from the Mac Clipboard

Giles Bowkett brought us Pastie of the Mac clipboard from IRB via the Utility Belt gem. If you aren’t using it already, ’sudo gem install utility_belt’. I highly recommend it.

That said, I’ve since longed for the same capability but from the command line.

Continue reading →

Passing Maps in Groovy (or “Groovy did what?!”)

  class Robot 
  { 
    def type 
    def height 
    def width 
    
    def access(location, weight, fragile) 
    { 
      print "Received fragile? ${fragile}, weight: ${weight}, loc: ${location}" 
    } 
  } 
  
  robot = new Robot(type: 'arm', width: 10, height: 40) 
  println "${robot.type}, ${robot.height}, ${robot.width}" 
  robot.access(50, x: 30, y: 20, z: 10, true)

Republished from Venkat Subramaniam’s Programming Groovy (Beta, p. 39)

…outputs the following:

  arm, 40, 10
  Received loc: ["x":30, "y":20, "z":10], weight: 50, fragile? true

If you’re a Ruby programmer, the second line is going to look seriously bizarre. If you’re not, I’ll explain why. In Ruby, you can pass a Hash (think java.util.Map) inline in a method call with the following syntax:

  foo("param1", param2, :hash_key1 => val1, :hash_key2 => val2)

According to Groovy, when a Map is inlined as a argument to a function, by convention, it is the first parameter on the method. If it is not passed in as the first argument then it is coerced into becoming the first argument. The Ruby interpreter will error if you pass an inlined Hash as any argument other than the last. Forgive me but Groovy’s coercion of parameter ordering is just fucking weird.

Rinda or “Hardware is Cheap So Let’s Use More of it!”

Recently, I was writing some simple statistical calculation software running tests on small data sets with a floating sample “window” through the data. Basically, this becomes a O(n^2) over Mann-Whitney U. It was fast enough for small data sets — that is until I was asked to scale the data size by about an order of magnitude.

What to do? We had plenty of hardware and I was developing on a quad-core Xeon (!!!) so why not throw more hardware at it. I was only using one core. So how do I get to the other three?

Enter Rinda — a Ruby implementation of Linda.

Continue reading →

MediaWiki Film lookup gem

After far too much goofing off, I’ve finally gotten off of my tuckus (metaphorically only ;) ) in order to write some code. In a few short hours of work, I’ve almost finished a first pass at my Wikipedia film gem. It’s sole purpose is to help me automate the download of movie synopses and posters for movies stored on iTunes for display on our AppleTV.

I’d left this project fallow for at least a half a year now. It was amusing to return to it later, with far better Ruby chops, and get it working. Now that the unit tests pass and the movie lookup driver seems to handle the majority of the bizarre errors that can occur as a result of the imperfect taxonomy used by Wikipedia, I’ll probably post a link in the next few days.

A time to revisit old gunk

Steven Bristol noted that the posted version of my “Change IM Status” script doesn’t work in Leopard. That may be as I’ve tweaked the heck out of it over the past several months but never posted the updates.

Hell, this is the first that I’ve heard of anyone else using the little beast. Cool!

What I really want to do with my IM/messaging apps is selectively block contacts programatically. This would let me build an “I’m Working” state where I could block out the world except for my immediate colleagues, for instance. Being somewhat ADD-ish (show me a developer who isn’t!) and a nearly-compulsive checker of incoming e-mail/IMs, this would be huge for me. I’m DYING for this.

Sadly, neither app seems to provide that level of event to OSA such that I could “veto” an incoming chat. I’m probably SoL regarding Skype but perhaps not so with Adium. I taught myself Objective-C for shits and giggles a few months ago after a chat with uber-hacker Marcel Molina. Maybe the Adium folks would be amenable to a new feature?

I’d still prefer for an event-based architecture where I could register my app for OSA events from Skype/Adium and use them to effect Skype/Adium.

Hrm. I wonder if iChat provides a more robust OSA model? Worth a looksy.

P.S. I’m ticked that the “Current Application” -> “Show Menu Items” feature of Quicksilver seems to be broken in Leopard. I loved this feature for blog posting from TextMate…

Ruby East

Ruby East, on the whole, was a fine conference. I, and several other conference attendees, noted that the local Ruby conferences seem to be just that: Ruby conferences. They seem to eschew addressing Rails and prefer to discuss a wide range of topcs.

I really like this.

I was among many who expressed disappointment with the high level of abstraction in the RailsConf ‘07 talks. Very few of them got into the weeds, talked about the code, and challenged the listener technically. I’m not sure about the (extremely few) rest of you but I go to these conferences to hear what my peers are doing, why, and determine if I should consider trying new technologies and techniques. For that to occur, I need to obtain at least a certain minimum depth of technical knowledge of a topic. Hoedown (especially) and Ruby East proved satisfying in that regard.

And, of course, there was Werewolf. Travel to exciting conferences, meet new and interesting people, and lynch and/or eat them. Who would imagine that a game involving argument, bluffing, and outright coercion could be such a team building exercise? It was a pleasure meeting, eviscerating, and being eviscerated by everyone.

Anyhow, below are my notes from Ezra’s Ruby East talk — far and away my favorite talk. For more notes from Ruby East, see Giles Bowkett’s notes on Pastie.

Continue reading →

RubyOSA presentation to Northern Virginia Ruby Users Group

This evening’s NoVaRUG was a good time. Rodney Degracia spoke first about RubyCLR, which provides a dynamically generated bridge between a Ruby VM and the RubyCLR. If I ever need to get at .NET internals again, now I know how I’m going to do it. In fact, I dropped an e-mail to a colleague in the office about it — except that his assembly is executed from Python. A quick Google turned up “Python for .NET” as an option.

Then it was my turn to talk to RubyOSA and RB-AppScript.  Admittedly, after using both, I'm strongly biased toward RubyOSA.  I have the distinct feeling that, after my presentation, the audience felt the same way.

Well, the Mac users in the audience.

Out of twenty or so people in the room, it turned out that I was really presenting to perhaps five or six Mac users.  I suppose that RailsConf is in no way representative of your average Right Coast Ruby developer.  However, oddly, nearly everyone stayed for my presentation.  I even fielded several good questions.  All in all, I had a blast.

When Xandy asked for topics for next time, I asked if someone would present on RSpec.  His next words were, "Thanks for volunteering, Evan."

Time to learn RSpec...

Slides available here: OS X Scripting with Ruby

Return values in RubyOSA

While holding the Ruby Hoedown BoF about RubyOSA and AppScript, I mentioned how I’ve never gotten a return value out of RubyOSA — which is why I used AppScript when I needed a return value.

Shoot me now.

A quick google of “rubyosa applescript return value” yielded this post to ruby-talk-google. Woops…

It’s this simple:

require 'rubygems'
require 'rbosa'
skype = OSA.app('Skype')
OSA.wait_reply = true
call = skype.send2 "call echo123"

And call is non-nil.

Admittedly, I’m somewhat at a loss as to why wait_reply is defaulted to nil…

Update 8/11/04 1609: Laurent tells me that, if the Applescript definition is correct, RubyOSA should correctly provide return values. Chalk that up as yet another bug in the Skype Applescript API. I’ll report it soon (it’s going into iGTD now…).

– Thanks, Laurent!