Archive for the ‘Innovation’ Category

The processes by which innovation occurs. I have a passion for understanding how innovation comes about.

03
Feb

As a good little rspeccer, I try hard to write my specs to verify behaviour rather than any particular implementation of that behaviour, and, for the moment at least, I’m in the “isolate your controllers from the models” camp. If you’re not in that camp (i.e., you don’t mock and prefer to do functional testing alone), this post probably won’t interest you. One case I often had problems with was model instance creation. There are just so many darn ways to create a new model instance! For a few examples:

@order_item = OrderItem.new(:hi => "hem", :ho => "hum")
@order_item.save!

@order_item = order.order_items.create(:hi => "hem", :ho => "hum")

@order_item = OrderItem.some_custom_creation_method(:hi => "hem", :ho => "hum")

The Problem

When you’re writing your spec (up front, of course!), you don’t want to presume too much about how the implementation will unfold. So, do you stub the create method on the model class? But what if we implement using the new/save combo (as above)? Or, what if we create the model instance through an association?

My Solution

My first pass solution to this problem is the following, based on Matthew Heidemann’s association stubbing technique:

module Spec
  module Mocks
    module Methods
      def stub_creators!(association_name, klass, stubs = {}, valid = true)
        target_mock = Spec::Mocks::Mock.new(klass, {:save => valid, :valid? => valid}.merge!(stubs))
        target_mock.stub!(:save!).and_return do
          target_mock.save
          valid || raise(ActiveRecord::RecordNotSaved)
        end
        klass.stub!(:new).and_return(target_mock)
        klass.stub!(:create).and_return do
          target_mock.save
          target_mock
        end
        klass.stub!(:create!).and_return do
          target_mock.save!
          target_mock
        end
        mock_association = Spec::Mocks::Mock.new(association_name.to_s)
        mock_association.stub!(:create).and_return do
          target_mock.save
          target_mock
        end
        mock_association.stub!(:create!).and_return do
          target_mock.save!
          target_mock
        end
        mock_association.stub!(:build).and_return(target_mock)
        self.stub!(association_name).and_return(mock_association)
        target_mock
      end
    end
  end
end

What this is doing

The thinking here is that, when I write my spec, I don’t want to be concerned with whether the implementation takes the create, new/save, build/save, or other route. In my spec I just want to know that at some point the controller asked for a model instance to be created and saved. The above code, which I put in spec_helper.rb, allows my specs to do just that. Essentially, I stub save so that it returns true or false, depending upon the optional valid parameter, and the other creation stubs derive from that: save!, create, create! on the target association class and the association itself. I also stub out new and build for convenience. This code ensures that save is always called, even though we’ve stubbed out create etc. Now if I need to check that a controller action has caused a model instance to be created, I need only ever check that save is called.

An example

In my specs I call stub_creators! on an instance of the association owner (in our example, the association owner is Order), passing it the name of the association I want to stub (order_items), the model class of the association target (OrderItem), optional stubs for instances of the association target, and whether or not we want the returned model instance to be valid (defaults to true). With this in place, I can do this:

describe OrdersController do
  before(:each)
    @current_user = mock_model(User, :login => "me", :logged_in? => true)
    @order = @current_user.stub_creators!(:order_items, Order)
  end

  it "should create a new order_item" do
    @order.should_receive(:save).and_return(true)
    post 'create'
  end
end

And it doesn’t matter which route the implementation takes to create that model instance. As long as save is called at some point, I know the controller has triggered the creation of the instance somehow.

Thoughts

Now, while this seems to work for me, I don’t really know whether this is kosher. Is it a sensible approach to take? I haven’t tested this extensively; as I said, it’s a first pass. Also, there’s bound to be stuff missing from my solution (for example, it doesn’t handle find_or_create_by_). Can a similar approach be taken to the various ways to delete an object, too? I shall continue to experiment.

,

24
Jul

As you probably know, I’m a ubicomp researcher by day. However, on the side, NICTA’s allowed me to allocate some of my time to develop a new way for researchers to review and publish papers. We’ve deployed a very early proof-of-concept of our idea called Citemine. We think Citemine has several nice properties, including a potentially more meaningful measure of research quality than existing indicators such as h index and raw citation counts. You can read all about the underlying mechanism in Citemine here. Until we deploy a feedback mechanism for papers, please leave your comments about Citemine at the official Citemine blog.

Note that we’re experiencing a few difficulties with our Citemine production server environment, which means slow page loads from time to time. And it’s clearly lacking polish, but hopefully it serves its purpose as a proof-of-concept so that you can get a feel for what it’s all about. But please do read the paper. I’ve been told it’s a fun read.

, , , , , , ,

26
Jun

A long time ago, in a Cooperative Research Centre far, far away (well, actually, it used to be just across the road from where I’m writing this post, but it sadly met its demise), a small group of researchers worked on a ubiquitous computing project that came to be known as PACE: Pervasive Autonomic Context-aware Environments. This group produced a framework for context-aware computing, which was the subject of many research papers at Pervasive, PerCom, JPMC and elsewhere. For various reasons, the source code for PACE has only just now come out into the open. Yes, you can now download the PACE framework from SourceForge. Unfortunately, there won’t be a lot of support offered along with the code.

, ,

12
Apr

Queensland Rail will be offering south-east Queensland commuters free wireless access to the internet from early 2010, according to the Minister for Transport, Rachel Nolan. This access will use spare capacity on the infrastructure used to transmit real-time video footage from surveillance cameras to QR’s control room at Central Station.

One thing from that story that caught my attention was this:

She (Rachel Nolan) said people living near train lines or stations would not be able to tap into the free internet service because it would be “firewalled”.

That would have to be one pretty intelligent firewall! Here are some actual possibilities to guard against free-loaders. One not so attractive way to do it would be to set a limit on daily downloads. The theory is that there’s only so much you could download on the longest possible trip on the QR network in south-east Queensland (say, Gold Coast to Nambour, or something like that). The other more attractive solution, in my opinion, would be to tie usage to go cards. Your internet session starts when you swipe on at the beginning of your journey, and it finishes when you swipe off. There’d be some kind of web-based login procedure like you get at hotels and elsewhere, where you enter your go card number to gain access; or regular users could have the option of registering the MAC address of their wireless card with QR/Translink to skip the login procedure. Given that it still takes ages for a credit card top up to find its way onto my go card, I don’t hold out much hope for QR/Translink being able to implement this particular solution within the already very optimistic time frame of early 2010. But I do think it’s a reasonable long term solution. It might even help Translink in their quest to move more commuters over to the go card from paper tickets.

, , , ,

10
Apr

There are many ways to measure brand awareness. As in most analyses, you shouldn’t rely on any single metric to determine which brands have most mindshare. Having said that, the Social Radar Top 50 Social Brands ranking is interesting. It measures conversations and web chatter. According to the ranking, Twitter comes out on top. Google comes in second, and Facebook makes it into fifth place. One of Twitter’s major competitors, FriendFeed, doesn’t even make it into the top 50 by this particular measure (did Scoble back the wrong horse and Kawasaki the right one?). But this ranking didn’t just include “social networking” brands. Rather, it was a survey of how frequently any brand was mentioned in a collection of blog posts, news feeds, forums, social networks and Twitter posts. Interestingly, such well known brands as Coke and McDonald’s fell outside the top 50. I imagine this is because these brands no longer have novelty value. They are ingrained in our culture. Really the only time we could be bothered blogging about these sorts of brands is when controversy strikes, or when someone makes a provocative movie like Super Size Me.

So what does this mean? It means that right now Twitter is hot. People are talking about it, and that’s the best that Biz Stone and company could hope for. The big question for Twitter is how to convert all the talk into more users, and ultimately revenue. If they do manage to do this, it would be nice to know how they did it!

, , ,

15
Feb

Once a year, NICTA’s external advisory boards, called ISAG/IBAG (International {Scientific, Business} Advisory Group), hold a meeting. There are some well known people on this panel, including Jeffrey D. Ullman, who is one of, if not the, most cited computer scientists. At the most recent ISAG/IBAG, the NICTA executive sought some advice on the potential for conflict between the objectives of national benefit and commercialisation. Ullman’s answer was succinct, cutting and delivered with a dry wit that I have come to appreciate over the years since I’ve been at NICTA:

National benefit versus private benefit… Hey, that’s what capitalism is designed to do, is to guarantee that there is no contradiction.

The line got a delayed laugh, because it took the audience a few moments to realise that was all Professor Ullman had to say on the topic, and that he’d moved on to the next topic. People laughed, but he was serious, and more right than many would be willing to accept.

, , ,

20
Dec

To those who responded to my plea for help by leaving a comment or responding out-of-band, thank you very much. We’ve settled on a name for our application, purchased the corresponding domain names and filed a trade mark application.

Will keep you posted as things evolve further. But just to give you an idea, we’ve already iterated through several “alpha” versions and expect to have a public beta ready by the end of February. Stay tuned for an explanation of what the service actually does.

, , , , ,

07
Nov

Valued readers, would you be so kind as to lend 15 seconds of your time completing the following task for me, your humble host. I ask that, from among the five names below (which, for various reasons, all begin with the word “cite”), you choose the one name that you believe sounds the best. The one that rolls off your tongue most easily. The one that you think is, well, coolest. Please do not bother yourself with trying to guess the meaning of the name, or the purpose of this exercise (though many of you will no doubt have a good idea). I am after your immediate gut feeling response. Please leave your response as a comment on this post.

  • Citemind
  • Citecloud
  • Citefish
  • Citecrowd
  • Citemarket

I would be more than grateful if you could point your friends and colleagues at this blog entry, particularly if they are involved in writing research manuscripts.

Thank you!

, , , ,

01
Nov

True:

Often we seem to use the term Ubiquitous Computing to mean “computers everywhere” as if just having the hardware all over the place was a worthwhile end in itself.

But maybe a better meaning is “computing available when you want it in a way that makes sense for where you are and what you’re doing” which is much harder to do than “computers everywhere”.

, ,