a sql quiz + is a lower hourly rate cheaper?

Suppose you have a task to write some JDBC code and you need to do so in the cheapest way possible.  Having your people grow should not be considered here, just the rate.

Person A

Charges 3X per hour and can write working code on the first shot, test it and complete it within an hour

Person B

Charges X per hour, but needs to multiple cycles to fix once the code is typed.  (This includes the time to identify what the problem is for each, build cycles and fix time.) For the SQL quiz , see how many errors you can find in the following code. I’ll post the answers as a comment. See if you can spot any I didn’t insert on purpose.

PreparedStatement stmt = null;
ResultSet rs = null;
try {
  String sql = "select count(*) from table" + "where column = ?";
  stmt = conn.prepareStatement(sql);
  stmt.setString(1, "test");
  rs = stmt.executeQuery();
  sql = "select count(*) from table2" + "where column = ?";
  stmt = conn.prepareStatement(sql2);
  stmt.setString(1, "test");
  rs = stmt.executeQuery();
} finally {

Which is better

In today’s economy, driving down costs is a hot topic.  One phrase service providers consider is “how can we lower the rate.”  This is the wrong question.  The question should be how to lower costs overall.  Person A is going to be cheaper overall even though the hourly rate is three times as high.  We’ve all heard the comment that a good developer is many times more productive than an average one.

Granted, my example is extreme.  It shows the difference between an experienced person and an someone new to JDBC.  The point is to use the extreme to emphasize that it’s not all about the hourly rate.  In the real world, training the entry level person has value too of course.

Another view

This reminds me of the methodologies that ask you to estimate how many hours/days/weeks a task will take without saying who will do the work.  Well, if I do it, the work will take a week.  If an entry level person is doing it, it may take four.  If someone experienced is doing it who doesn’t know the system, it may take two.  How do we balance the differences in people when estimating?