Archive for June, 2010

Let’s Log Everything!

Friday, June 18th, 2010

The Australian Government has put forward a scheme which they wish to log the activity of every user of the internet. What. The. Fuck?

Must the government fear its citizens so much that it has to monitor their every movement? Lucky we have a lot of spare land to put the datacenters where to keep this new data they’ll be storing. This means data such as sixteen-year-old girls “liking” a picture on Facebook and writing comments like “omg hayley wat r u doing dere?”. Seriously, Australia? Fuck.

Again, it’s also a load of bullshit. Like the internet filter. People who want to keep their communications secret (VPN / SSL anyone?), will do it. The government must find an alternative solution that doesn’t involve tracking miniscule internet movements of the majority to capture such an infinitesimally small minority. One person’s a terrorist and suddenly we’re all suspected of it until proven innocent.

This is not the “democracy” I’ve grown up knowing. It’s, in the words of Muse, “demonocracy”.

It makes me sad that we have a bunch of old fogeys in their ivory towers scheming against the majority without asking it for their opinion. I thought that’s what democracy was about. I wish they’d climb to the highest level of their tower and defenestrate their pathetic ideas, followed shortly by theirselves.

You cannot protect everyone from everything all the time. Stop trying.

The book is…

Wednesday, June 9th, 2010

Rails 3 in Action!

Yes, I am writing the Rails 3 in Action book that was originally called “Merb in Action” before the Merb+Rails merger. I was approached to join the team to be a co-author with Yehuda Katz at the beginning of April and the process with him & Manning has so far been wonderful! I’ve been writing the book from scratch since the end of April and so far I have five-and-a-half chapters written with the sixth one (Authentication & Authorization) probably finishing up this weekend.

We’re aiming to get the book done published by December 2010 in both paperback, PDF and (probably) eBook-reader formats too.

Watch the video for more information.

Bridging the Gap

Monday, June 7th, 2010

The question is: How do we bridge the gap between “newbie” and “experienced” in such a way that we won’t suffer the talent drought we are currently facing. What are your thoughts as to how we can fix this?

This post was intended as a script for a videocast, but I’m a horrible actor.

Hello!

My name is Ryan Bigg. You may remember me from such hits like #rubyonrails, Railscamp or the Scottish Ruby Conference. I’m here today to talk to you about something that I perceive as a problem. Firstly though, a bit of backstory.

The Ruby (and Rails) communities are some of the most supportive and inviting communities on the planet. When I started with Rails, my first question in the #rubyonrails IRC channel was about an error I was getting, an undefined method “find” on a class called “Thread”. Little did I know back then that Thread is a reserved class in Ruby. As you can see from this example, I too was a noob.

Since then, my Ruby skills have flourished to where I think I’m growing to be a Ruby expert. I still hang out in IRC channels and sometimes I’m asked for advice and if I’m free I’ll help out. So why do I do help? I am not a religious person, but there are some certain aspects of particular religions I believe in, such as karma from Buddhism. To me, karma means that if I do something good to somebody, then eventually something good will happen to me and vice versa, I do something bad, bad things will happen. I also believe in “paying it forward”, that if I help somebody out, then perhaps they’ll see somebody else with the same or a similar problem and help them out, too. So I help out in the hope that 1) I improve somebody else’s life just that little bit, 2) I may improve my knowledge of a particular concept or problem and 3) eventually that good deed will come back to me.

I didn’t get good at Rails overnight. Nobody gets good at anything overnight, unless you’re Neo from the Matrix or Yehuda Katz. It’s taken me 3 and a half years to get to this point and I fully believe it was because I spent time helping people solve their own problems which allowed me to build up a great database of Ruby-knowledge that I could apply to any application I worked on. Working with a team of already-experienced developers greatly assists here too and I am thankful of the time I spent at SeaLink, NetFox and Mocra and freelancing. Before Mocra I didn’t even use Cucumber! Now I’m writing a book centered around using it to develop a Rails application! It’s great! The things you learn on the job are more important, than the things you do on the job. I got lucky. I attended a Ruby meetup back in April 2007 in my hometown of Adelaide where I was invited to work for either SeaLink, NetFox or another company Freerange Future. When I begun working for SeaLink, I had only been in the Ruby and Rails world for 8 months, and during 8 months at SeaLink, I learned a lot about Ruby, about Rails and about RSpec. Working with Rails has definitely been one of the greatest ways to learn about it.

Now in 2010, as a writer of a book aimed at a wide range of Rails people (newbies and up), the experiences of new people is something I’ve been considering for a while. The way I have visualised the community for a long time now, is a pyramid. The bottom is, of course, wider than the top and the lower down the “pyramid” you are, the less skill you have and of course the higher up this “pyramid”, the more skill you have. The width of the pyramid at any level indicates how many people there are at that level and, because the Ruby community is growing, there’s a lot more inexperienced people than there are experienced. If the Ruby community was shrinking, you’d see the opposite effect where there’s a wider level at the top of the pyramid dwindling down to nothing at the bottom. No new people means a dying community. Ruby is not dying. So how are newbies to gain the experience required to work towards the top of this pyramid and get hired by the companies looking for “experienced Ruby / Rails developers”? It’s simple: they’re going to need a job. So it saddens me to see all these companies hiring “experienced” Rails developers.

There’s only so many “experienced” Rails developers. They’re being snatched up by companies quicker than they’re becoming available. I know this because the company I’m working for right now is trying to hire a new “experienced” developer and we’re having an absolute bastard of a time. We’re also down one developer because he has RSI, and another was just pulled off my team to work on the legacy application until the election. So we’re looking to hire an “experienced” Rails developer to fill the gaps. It’s almost as if there’s no more “experienced” developers left to hire in Sydney and I’ve seen this same situation in Brisbane, where I used to live and other people have talked to me about it too. We need an “experienced” developer because we’re looking to get this application done by the Federal Election. But there are seemingly none left. So what can be done about this? How can we and other companies find new members for the team?

Well, we could bring in a new person, but we (as a company), but not I (as a “teacher”), don’t want to spend time teaching new people when that time could be used for developing new features. Why should you pay somebody when you’re teaching them? Shouldn’t it be them paying you? Well, no. You’re paying them in the hope that they’ll stick around and provide another valuable resource to the company. Some do, some don’t. Give them the incentive to stick around and I’m sure they will. Job security is a great incentive. I think we need more companies who aren’t all just about the “gogogogo” and are actually conscious about the future of their business. If the future involves hiring a new developer and having to train them up in a language, why not do it? Sure, you’ll lose one developer’s time for a short while, but what you’ll gain in the long term is two developers’ time. Then that developer can teach more people you bring in. Eventually, you won’t be understaffed.

If you hire nobody, then that’s the worst thing that can happen. You’ll overwork your developers and you’ll think that they underdelivered because they didn’t do a good enough job, but the reality is it was because they were under-resourced. You put a magical deadline on them and expect it to be done but the harsh truth is: sometimes deadlines aren’t met. Budget some money, and some time, to bringing new people way before any major deadlines if that’s what it’s going to take to be successful in the long run. Over-estimate how many people you’re going to need to get the project done. That’s what you want, isn’t it? A completed project? Therefore, we shouldn’t be hiring “experienced” people only but rather people who can contribute back to the team, even if that involves having to teach them something first off.

Personally, If I were to hire a new person, there’s a couple of things I’d be looking out for. Before I list them, here’s a very good point of a conversation I had last night with a Rails developer based in California, kay-von. Kayvon got started with Rails in December. He said that in order to be good at Rails, he didn’t need the knowledge of the ins-and-outs and every single class and method. You just need to know how to do your research (aside: and not to cargo-cult!) and learn to learn. If you’re able to absorb the knowledge and make it into your own from the resources like people and the Internet, then you’ll go pretty far. Now Kay-von is doing Rails work for many clients and is gaining a reputation for his work. What I’m looking for in a person isn’t experience in a language, but rather the same ability Kay-von has. The ability to learn. The ability to understand. The ability to apply yourself to accomplishing something. These are the major concerns that I’d be for. Other things include the standard: good communication skills and good personal hygiene.

I want to see that drive in people, that willingness to learn. Another example. Will A friend of mine, Bo, introduced me to a .NET developer friend of his, Lucas. One day last year, we showed him what Rails can do. Lucas attended the ActionHack events that are held monthly in Brisbane as well as the last two Railscamp events. Not because he had to. Because he wanted to. He attended these events because he wanted to learn, and that’s precisely what he’s done. He’s learned Rails, learned BDD concepts and now knows enough to be hired by a Rails shop. Lucas is in the same group of people as Keyvan.

I know there’s a vast group of these people out there, just looking for some company to give them a chance at developing Rails, but all the companies out there are hiring “experienced” developers. I haven’t seen a single job posting in the past couple of months on the rails-oceanic list looking to hire people that they’re willing to teach. Because everyone wants things done now. Nobody is willing to invest in the future of the community. What we need is some… group to invest time teaching these new people. That’s what I’d love to do. I love seeing people’s faces light up when they discover something or hearing that “oohhhhhhh” when something clicks. For now, I’m doing the best I can. I am personally considering after I’ve finished writing this book to approach some universities or TAFE colleges and asking them about how I can go about teaching them, hopefully they can give some pointers.

So in summary: this has been a question that’s been floating around in my head for ages: How do we bridge the gap between “newbie” and “experienced” in such a way that we won’t suffer the talent drought we are currently facing. What are your thoughts as to how we can fix this?

Using Cucumber tables to specify associations

Friday, June 4th, 2010

How many times do you use Cucumber to seed data by using a step such as this:

And there is a list:
  | name          |
  | GetUp people! |

Probably a lot, right? Good. Then this post is probably for you.

How many times have you done it and needed to specify an association in there too? Like this:

And there is a list:
  | name          | parameters[email_contains] |
  | GetUp people! | getup                      |

Probably a couple of times.

So what can be done?

As you may know, by using this syntax in Cucumber you get a variable which I always call “table” in my steps. You may call it something else. What matters is that it’s a Cucumber::Ast::Table object that has a method called hashes on it. This will return a Hash object for every single row minus one in your table. The minus one is the first row — the header row — which provides the keys for the hash. The remaining rows are the values for each of the hashes. In the first example, our hash is:

{ :name => "GetUp people!" }

In our second example, our hash is:

{ "name" => "GetUp people!", "parameters[email_contains]" => "getup" }

Bah! This won’t do!

Enter to_query

There’s a lovely method on Hash that will allow you to convert any Hash object to query parameters. It’s called to_query. The second Hash to_query output is this:

"name=GetUp+people%21&parameters%5Bemail_contains%5D=getup"

Eeew!

Query strings are not pretty

So to deal with query strings, Rack parses them into a Hash object (and Rails, a HashWithIndifferentAccess object) using the lovely Rack::Utils.parse_nested_query method. This forms the query string into the params hash which we have come to know and love. The very same params hash you use to create objects with.

See where I’m going with this? Great!

So we define our step like this:

Given /^there (is|are)\s?a?\s?lists?:$/ do |is_or_are, table|
  table.hashes.each do |hash|
    List.create!(Rack::Utils.parse_nested_query(hash.to_query))
  end
end

The regular expression is to match “there is a list:” or “there are lists:”, in case we want to create more than one. By passing in the parsed hash (and because we’re using accepts_nested_attributes_for, the model is actually ListParameters), we’re able to create not only the new List record, but also assign the ListParameter record too.

Not only for belongs_to

You can also assign has_manys through this too, although the syntax is a little bit more uglier. Again, providing you’re using accepts_nested_attributes_for for the has_many association, this should work just as well as if you posted it from a real form.

  And there is a link:
    | url               | clicks_attributes[0][user_id] |
    | http://google.com | 1                             |

How about that?!