articles in 2007

Up in the morning, 'bout a quarter to 4

no comments yet, post one now

USMC

Pain starts this November in New York, and I am way behind in upping the mileage

End of an era

no comments yet, post one now

Fellow TPM on leaving card

What is the past, but a mirror to the future, a negative reality inversion of what could be? Invest in Parmesan my son, that is the future …

A Lesson In Computational Complexity

1 comment

What is ‘Computational Complexity’ ?

Basically a theory describing the scalability of algorithms. “As the size of the input to an algorithm increases, how do the running time and memory requirements of the algorithm change?” Wikipedia has a more complete description. Complexity can be considered in terms of;

  • Time Complexity – the number of steps that it takes to solve an instance of the problem as a function of the size of the input, using the most efficient algorithm.
  • Space Complexity – the amount of space, or memory required by the algorithm.

If you consider an array with n elements, and in solving a problem on this array, it takes n times n (or n2) steps. You could say the algorithm used had a complexity of n2. Now with different programming languages there may be additional steps in the algorithm necessary to solve the problem. To describe a general level of complexity across any language, the Big Oh Notation is used. So the time-complexity for this algorithm would be ?(n2)

‘?’ basically indicates that we are ignoring any language dependent factors, allowing complexity to be expressed purely in terms of the size of the input.

An Example

if you take a simple problem like, finding the ‘mode’ average on an array. I.e. the most frequently occurring element in a sequence (lets say of numbers) – You could do this an number of ways. Here is a brute force attempt (in Ruby).

def calculate_mode(nums)
  hi_count = 0
  mode = nums[0]
  nums.each do | search_for |
    count = 0
    nums.each do |num|
      if search_for == num
        count += 1
      end
    end
    if count > hi_count
      hi_count = count
      mode = search_for
    end
  end
end

It should be obvious that this algorithm has a complexity of ?(n2) – since every element of the array must be searched by each element to find the highest count value (and hence the mode).

Could it be done any faster? If the array of elements was sorted (ordered numerically) – the mode could be found by finding the longest continuing sequence in the array, that should only take n iterations. Employing a quick sort algorithm first; which can sort (on average) with ?(n log n)

def quicksort(a)
  return a if a.size <= 1
  pivot = a[0]
  quicksort(a.select {|i| i < pivot }) +
      a.select {|i| i == pivot } + 
      quicksort(a.select {|i| i > pivot })  
end

def calculate_mode_fast(nums, time_start)
  # sort array first
  sorted_nums = quicksort(nums)

  hi_count = 0
  mode = nums[0]  
  count = 1
  idx = 1

  sorted_nums.each do | search_for |
   if search_for == sorted_nums[idx]
     count += 1
     if count > hi_count
       hi_count = count
       mode = search_for
     end
   else
     count = 1
   end
   idx += 1 if idx < sorted_nums.length
  end
end

So we could say that this approach has (on average) a complexity of ?(n+(n log n)) which is significantly less that ?(n2)

I’ve posted this code listing which implements both algorithms running to compute the modal average on identical arrays of random integers. You can vary n (the number of elements) to see how each method performs. From the results (below) its clear that the 2nd algorithm is more time-efficient in this case.

calculate_mode
====================
mode => 3 (it occurs 44 times)
array length was 1000
num loops was 1000000
completed in 0.71737

calculate_mode_fast
=========================
mode => 3 (it occurs 44 times)
array length was 1000
num loops was 1040
completed in 0.011247

The Wiesmann GT

1 comment

In recent on-line chatter over buying cars, the argument was put forward for more fun. Yes, Fun! with a capital ‘F’.

RWD, open-top and general ‘side-ways around corners’ was favoured over smooth driving, electric everything and ‘I feel like I’m doing 5mph when I’m really doing 80’.

weismann_gt_black.jpg

Enter the (german made) Wiesmann GT, checking all the boxes. German made yes, but performs and looks every bit like a British sports car classic. With a BMW V8, BMW brakes and gearbox, Wiesmann work hard to make 500 cars every year. The lead time on ordering one is about 6 months. Another photo here, and a review at PistonHeads.com explains more.

weismanngt480.jpg

Starting at £72,000, its a little pricey though. A killer-internet app and a quick sale to Google/Yahoo should sort that out; to the Bat mobile robin!

Lightboxing, Control.Modal style

no comments yet, post one now

You might have noticed a minor style change in the most recent blog entries. I’ve decided (from now on) to use a light-box for showing off any embedded videos and (biggish) images on the page. It keeps the layout tidy and allows you to focus on the video you’re watching or image your viewing, without distraction.

All of this is made possible using Control.Modal, a light weight, unobtrusive JavaScript library for creating modal windows and lightboxes using content that is already on the page. So with javascript turned off, everything still works, with the links navigating to anchor tags in the page.

At the moment I am applying display:none; on the modal content to avoid a visible onLoad jump effect as the content gets hidden by Control.Modal javascript. I’ll be changing this (since doing this hides the content when javascript is off, and CSS is on) – There’s also a small bug with the tv-icon link style on IE6.

In Mephisto, I was able to create my own custom ‘Modal Macro’ filter, so I can easily apply the effect to any content in my articles. Here is the code for doing just that. Save this as modal_macro.rb in the lib/ folder for any new or existing vendor/plugin. As usual, any comments, questions or suggestions are appreciated.

The Land of Chocolate

1 comment

I’m off to Bruges, (or the ‘Land of Chocolate’) in Belgium this Friday. Coincidently the Belgium Chocolate Festival also begins this weekend (in Bruges). I’ll get some pictures up on the Flickr

Jeff Han’s own multi-touch interface

no comments yet, post one now


Microsoft’s Podtech Research Lab has also been experimenting with a different type of interface based around shape/motion tracking. It works with two hands as well, but without any tactile feedback for the user to ‘press against’. To be honest it looks like it would be very odd to use, as Jeff Han mentions, 3d manipulation of objects without tactile feedback is actually less intuitive and a step away from 2d multi-touch interfaces.

In a Jam

1 comment

Some of you may know that I work for the BBC, on a little (£150m) e-learning site, BBC Jam. It was with great frustration last week, that I learned of the BBC Trust’s decision to suspend the service, pending the outcome of a public value test – Here lies the official press release describing just that.

Along with some harsh conditions placed on the production of this service (brought about by the same complaints that have caused this suspension), the site has seen its share of challenges. But the quality of e-learning content over the last year has been outstanding, and a great deal of it (more than 80%) has still to see the light of day.

There is a story worth reporting here. Years ago £150m was awarded to the BBC for the production of Jam. The government also granted £530m in e-learning credits (over 4 years) to bolster the e-learning education industry here in the UK. Along with these grants, a set of conditions was imposed on BBC Jam, including terms stating the BBC could only cover 50% of the UK curriculum. Some questions worth asking here;

  • Where did the £530m go? How is the spending of this money by schools regulated?
  • Why is e-learning content in the UK still so droll? (in comparison with the richer interactive (flash-based) offerings from the BBC)
  • How can some companies claim they have lost business/revenue since BBC Jam had (until now) only launched about 15% of it’s content with only a small advertising campaign?
  • Why does most of the UK’s educational software market revolve around the adoption of VLE’s in schools (and locking them into a platform) – rather than content and great learning experiences?
  • Should the suspension of a free e-learning service for kids ever be celebrated? and who does this really benefit?

Reaction across the web has proved BBC Jam has a lot of support. Even on sites claiming this suspension is a good idea. commentaries have quickly shot down the authors post. There is some more good discussion on the matter here and here.

Here comes the disclaimer: the views expressed above do not necessarily correspond with those of the BBC.

March 24, 2007 22:19 by

OpenID

no comments yet, post one now

Maybe I am a bit late to the party, but OpenID seems to have made a surging comeback in the last month or so, not least in the Rails community. Its something I am looking to implement on a few projects of my own, and luckily (with Rails) I won’t have to re-invent the wheel. Here are some useful links on the matter:

Last year during @media2006, Mr. DHH questioned whether login/signup (and managing multiple usernames/passwords across the web) was such a big problem after all. With modern browsers capable of remembering passwords and client side tools to take care of the matter. You can see how 37 Signal’s new HighRise application handles it (with a small unobtrusive link in the login box corner).

For some more discussion on the good/bad aspects of OpenID, we have:

One awkward part of OpenID at the moment, is the use of a URL to login with; to the average user this has to be a bit confusing. With that, and few major sites offering OpenID support, it may be a while before it takes off across the web.

The Un-agile Prince

2 comments

Heard of PRojects IN Controlled Environments aka. Prince ? If you’re in the UK you’ve probably seen it, asked for on job descriptions,
listed in expense reports and generally talked up among those in the project management industry. Outside of Europe Prince2 holds little clout. Most people have never heard of it, (including Mr. Joel on Software)

Prince2 is essentially a project management framework, that claims it can be applied to (or modified to fit) any project. It is great theory – but that’s pretty much all it is. In reality it’s rarely the right methodology to choose for a software project.

The problem is some large (often bureaucratic) companies place a strong emphasis on having a Prince2 qualification, even in the software industry. Year on year, it seems to make a regular appearance on training expense reports.

To make things worse, whatever good intentions Prince2 had to begin with, have faded away. What’s left now is a money making training industry (with loyal repeat customers). Having to re-take the same training and sit the exam every year or so, just to keep the accreditation. Speaking to those who have taken the course, it doesn’t seem to offer anything more than ‘how to pass the exam’ – and is scant on the underlying principles of project management using the framework (including how you might want to tailor it).

Simply put, Prince2 is too rigid to fit with the complexity involved in managing software projects, especially those with small teams. The amount of work you would have to do, moulding Prince2 into a more agile solution, would offset any benefit in using the framework.

If you’re still not convinced, I’d suggest have a good read through ‘Why Software Projects Fail’ , ‘Getting Real’ and ‘The Agile Manifesto’

Heads up, I know which one I prefer in the Agile Manifesto vs. Prince2 debate.

← (k) prev | next (j) →