The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
You Get What You Pay For

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Rick DeNatale

Posts: 269
Nickname: rdenatale
Registered: Sep, 2007

Rick DeNatale is a consultant with over three decades of experience in OO technology.
You Get What You Pay For Posted: Apr 8, 2009 3:35 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Rick DeNatale.
Original Post: You Get What You Pay For
Feed Title: Talk Like A Duck
Feed URL: http://talklikeaduck.denhaven2.com/articles.atom
Feed Description: Musings on Ruby, Rails, and other topics by an experienced object technologist.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Rick DeNatale
Latest Posts From Talk Like A Duck

Advertisement

Well, that’s the saying. One thing is for sure. You can’t expect to get what you don’t pay for.

I got an IM from a buddy this afternoon looking for a second opinion on a Rails application. Someone had paid for 100 hours of work (I don’t know at what rate), for a Rails project which wasn’t progressing to his liking. He’d asked my buddy to give an opinion of what had been done, and I was asked to have a look as well.

I only spent about a half hour or so looking at the code, since I was doing this as a courtesy. I spend quite a bit of pro-bono time helping others by writing here and contributing on public fora, but I’ve got my limits.

The executive summary: I wasn’t impressed.

This was a completely blind sampling. I have no idea who the consultant was who wrote this app, nor even the identity of the client who had funded it.

I noticed that there was both a spec and a stories directory in the project a good sign. Looking closer though the specs all seemed to have been generated automatically by the restful_authentication plugin, same thing for the stories.

And the tests were the standard useless stub tests generated by the Rails model/controller generators.

There was some very suspect code in some of the controllers I looked at, one was creating a model in the new action. Normally the new action instantiates an unsaved model instance for use by an edit/creation form, leaving the actual creation of the model in the database to the create action after the form is posted.

The Application controller had some strange looking code, which looked like it might be boilerplate from somewhere. When I googled for a snippet from the code, it looks like it came from somebody’s rails 2.3 template for generating a new rails app using shoulda.

So we have an app which can’t seem to decide which testing framework to use and then not really use any of them to any effect.

Now I know that shoulda, rspec and test::unit can be used in combination by a sophisticated developer, but I don’t think that’s what was going on here.

I poked around in a few models. I found one which really flummoxed me. The model purported to be representing a currency exchange rate for a particular currency on a particular date. The model had a class method average which took a currency and a date range as arguments. Now from the name, I’d expect that this would maybe calculate the average rate for instances for that currency between the first and last dates of the range. Lacking any tests/specs I’ll assume that’s what it would do.

What did it do?

def self.average(currency, date_range)
     first = find(:first, :conditions => ["currency = ? AND issued_on = ?", currency, date_range[0].to_date])
     first ||= find(:first, :conditions => ["currency = ?", currency] , :order => "issued_on"
     last = find(:first, :conditions => ["currency = ? AND issued_on = ?", currency, date_range[1].to_date])
     first ||= find(:first, :conditions => ["currency = ?", currency] , :order => "issued_on ASC"

     median(first.rate, last.rate)
end

protected
def median(a, b)
    (a + b) / 2
end

See anything strange here? Actually I see several.

  1. To find the first it looks for an instance for the currency which happened exactly on the starting date. If it doesn’t find one then it finds the first instance for that currency in the database. I would have expected to find the first instance on or after the starting date, which could have been done with a single find call with the right condition.
  1. Then to find the last it does what looks like a simple variant of the code to find the first, but is it a variant, instead of finding the last instance for the currency in the database rather than the first it’s going to again find the first. He wanted :order => “issued_on DESC”.
  1. What kind of average is being computed here anyway? Average is a generic term, normally we take it to denote the mean, which is the summation of a series of values divided by the number of elements in the series. We’re not doing that here, since we look at only two elements. Now the method being called is median, which is another type of average. You get the medium by sorting the series and picking either the middle element if the series has an odd number of elements, or the mean of the two middle elements. But that’s certainly not what this median method is doing.

Having specs or tests would have helped this guy both think through what he was trying to do, and to realize that it wasn’t working.

So to me it looks like the client had paid for some guy generating a rails app from some templates and plugins and then floundering around with no real idea of how to understand, let alone achieve, the goals of the application.

Like I said in the beginning, it’s not really that you get what you pay for, more like you sometimes get what you pay for. Since I don’t know the rate the client was charged, I don’t know whether he got what he paid for by hiring someone deservedly cheap, or just didn’t get what he paid for.

It’s always a shame when customers don’t get what they pay for, but in the current economy, it’s a real shame when a client burns money hiring someone on the cheap or without real credentials instead of paying someone who might at first look more expensive but would be a bargain in comparison in terms of value for money.

Read: You Get What You Pay For

Topic: Early impressions of Skype for SIP (SfS) Previous Topic   Next Topic Topic: Clojure on Google AppEngine

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use