Thursday, March 8, 2012

Run your enterprise like a startup

I've worked in a variety of companies and I notice an interesting phenomena -- It seems that the capabilities of individual programmers in companies are inversely purportional to the size on the company. Tech startups with 3 folks always seem to have superstars, even though it's a huge drain on their budget, but IT shops with 1000 people seem to always have 10 people who seem to be doing everything.

The irony in this situation is that a startup has the least amount of money to spend on programmers, but requires hiring only the best and needs to spend a disproportionate amount on payroll. On the other hand, a company flush with cash that could easily hire only the best and brightest, inevitably hires "everybody else". This means that particularly large shops end up with a handful of superstars (just by sheer luck of the draw) who do the majority of the work (and then burnout and leave) and a bunch of "also ran" folks who are really just padding their resume and being a drain on your cash flow.

A visionary IT leader at a large company would break software delivery down into a cluster of startup-like groups with very large degrees of autonomy. Forget about the mythical efficiencies of "enterprise architecture initiatives" and simply hold teams' feet to the fire to deliver real solutions with aggressive timelines. Use the incubator model to foster competition within the organization, after all, two insanely great teams working furiously on the same solution seems inefficient on the surface, but at the end of the day/week/month, you're more likely to then have TWO possible solutions to choose from. If you have one mediocre to crappy team of 50 slogging along and delivering nothing, you may be saving payroll money in the short term, but you will bleed to death waiting for solutions that will possibly never appear.

Thursday, March 1, 2012

Aggressive control freaks make great programmers

After reading Give it five minutes I saw an interesting pattern. Of the folks I know, the good/great programmers are all pretty aggressive. In addition they are also pretty controlling. Moreover, when reading the comments to this blog post, I was struck by the number of folks who could identify with the "hothead".

As a person who historically fit in to that personality type, I wonder why this is. It seems to me that the reason has to do with the way people interact with computers when programming. The very idea of being 'in charge' of the computer and making it do anything you want would seem to appeal to this sort of personality. In addition, the current market and the rate of change handsomely rewards people who aggressively pursue this end. Very successful programmers are the ones who can do this most effectively.

The obvious downside is that this creates a situation where negative behaviour (in human interaction) is actually rewarded. Without conscious effort many programming types forget when they are talking to humans and can be overbearing and aggressive without even realizing that it is happening. After all, if you spend 8-12 hours per day bending a computer to do your will, it imaginably takes time to "turn it off" and re-connect with humans.

More importantly, I think this personality type has a self limiting nature to it. While I know many great programmers who fit in this category, many of these top out at fairly low, though highly technical, roles. This is understandable to me because software is largely written for humans. If the person commanding the computer to do things cannot relate to the people the computers are supposed to serve, the odds are low that the computer will be told to do the correct thing.

So the next stupid idea you hear, think about it for five minutes before you start tearing it apart. Better yet, ask questions for five minutes and maybe try to understand why the other person thinks it's a good idea.

Tuesday, February 28, 2012

Using Mongoid, MongoHQ, and Heroku

I recently tried to set up mongoid with a free mongohq account on heroku... This info is accurate as of 28 Feb, 2012.

For the impatient (I just want to make it work)

mongoid.yml

production:
  uri: <%= ENV['MONGOLAB_URI'] %>

Gemfile

gem 'bson', '1.3.1'
gem 'bson_ext', '1.3.1'
gem 'mongoid', '2.0.2'

For those who want more detail (I have a similar problem, how do I troubleshoot

To determine heroku environment variables, do this:

$ heroku config

and the results should contain a line like what follows:
...
MONGOLAB_URI        => mongodb://heroku_app928349384:lkfjgoierheourhgoeurhgoeuh@ds031087.mongolab.com:31087/heroku_appapp928349384
...

The important thing to note is what the left hand line says. Around the internet (like here on SO they will incorrectly name the ENV as MONGOHQ_URI. So then update mongoid.yml like this:

Additionally, it appears that different versions of mongoid only work with certain versions of mongodb. I started by digging around on google to find versions that seemed to be compatible.

Stack trace with wrong URI:
production:
  uri: <%= ENV['MONGOLAB_URI'] %>

Will yield something like

2012-02-28T12:49:46+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:518:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:656:in `setup'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:101:in `initialize'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in `new'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in `from_uri'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config/database.rb:86:in `master'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config/database.rb:19:in `configure'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config.rb:114:in `from_hash'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config.rb:342:in `configure_databases'
2012-02-28T12:49:46+00:00 app[web.1]:  from (eval):2:in `from_hash'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/railtie.rb:64:in `block in <class:Railtie>'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `instance_exec'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `run'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:50:in `block in run_initializers'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `run_initializers'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `each'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:134:in `initialize!'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:77:in `method_missing'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/config/environment.rb:5:in `<top (required)>'
2012-02-28T12:49:46+00:00 app[web.1]:  from <internal:lib/rubygems/custom_require>:29:in `require'
2012-02-28T12:49:46+00:00 app[web.1]:  from <internal:lib/rubygems/custom_require>:29:in `require'
2012-02-28T12:49:46+00:00 app[web.1]:  from config.ru:3:in `block (3 levels) in <main>'
2012-02-28T12:49:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:23:in `eval'
2012-02-28T12:49:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `new'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `map'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
2012-02-28T12:49:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
2012-02-28T12:49:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:11:in `block in <main>'
2012-02-28T12:49:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:11:in `new'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
2012-02-28T12:49:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
2012-02-28T12:49:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:1:in `new'
2012-02-28T12:49:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:1:in `<main>'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.

2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/bin/thin:19:in `load'
2012-02-28T12:49:46+00:00 app[web.1]:  from /usr/ruby1.9.2/bin/thin:19:in `<main>'
2012-02-28T12:49:47+00:00 heroku[web.1]: Process exited with status 1
2012-02-28T12:49:47+00:00 heroku[web.1]: State changed from starting to crashed

Stack trace with wrong version of mongo/mongoid/bson :

Starting process with command `thin -p 4644 -e production -R /home/heroku_rack/heroku.ru start`
2012-02-27T22:50:46+00:00 app[web.1]: /app/app/models/expression.rb:2:in `<class:Expression>': uninitialized constant Expression::Mongoid (NameError)
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/app/models/expression.rb:1:in `<top (required)>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:137:in `each'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:137:in `block in eager_load!'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:135:in `eager_load!'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:135:in `each'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:108:in `eager_load!'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `instance_exec'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `run'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:50:in `block in run_initializers'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `each'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `run_initializers'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:134:in `initialize!'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:77:in `method_missing'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/config/environment.rb:5:in `<top (required)>'
2012-02-27T22:50:46+00:00 app[web.1]:  from <internal:lib/rubygems/custom_require>:29:in `require'
2012-02-27T22:50:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:23:in `eval'
2012-02-27T22:50:46+00:00 app[web.1]:  from <internal:lib/rubygems/custom_require>:29:in `require'
2012-02-27T22:50:46+00:00 app[web.1]:  from config.ru:3:in `block (3 levels) in <main>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
2012-02-27T22:50:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `new'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `map'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
2012-02-27T22:50:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:11:in `new'
2012-02-27T22:50:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:11:in `block in <main>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
2012-02-27T22:50:46+00:00 app[web.1]:  from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
2012-02-27T22:50:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:1:in `new'
2012-02-27T22:50:46+00:00 app[web.1]:  from /home/heroku_rack/heroku.ru:1:in `<main>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/bin/thin:19:in `load'
2012-02-27T22:50:46+00:00 app[web.1]:  from /usr/ruby1.9.2/bin/thin:19:in `<main>'
2012-02-27T22:50:47+00:00 heroku[web.1]: Process exited with status 1
2012-02-27T22:50:47+00:00 heroku[web.1]: State changed from starting to crashed
2012-02-27T22:50:48+00:00 heroku[router]: Error H10 (App crashed) -> POST newsfilter.heroku.com/_heroku/console dyno= queue= wait= service= status=503 bytes=

I apologize in advance for the poor formatting on this post...