Ruby/Rails interview questions
July 25th, 2008
I’ve recently been helping interview some ruby/rails developers. I searched the web for some inspiration but I could not find any example questions that had real depth to them. I like my questions to be a point of discussion rather than one word answers. Most importantly I want a wide enough scope to let those talented individuals shine through. So here are some of the questions I’ve been trying out recently.
1. You are getting the chance to fly in the worlds first unmanned Airplane who’s systems are written only in ruby. Would you fly in it? Explain your reasoning
2. Ruby is great and everything but its nothing more than a prototyping language. Its just too hacky and dynamic for any real production system. Why bother with its messy Perl lineage and the lack of internationalisation support when you could just use Python? Discuss.
3. Ruby takes a unique approach to the problem of multiple inheritance. Explain ruby’s approach and the strengths and weaknesses of it.
4. Do you think adding behaviour to the builtin core Ruby classes is a good idea? Can you give some examples to backup your opinion.
5. Explain why in ruby nil.object_id is equal to 4. (Rather nasty question, really asking about C)
>> nil.object_id => 4
6. Twitter(http://www.twitter.com) is a website built on Ruby on rails. It is a
“Social networking and microblogging service utilising instant messaging, SMS or a web interface.”
Why do you think twitter (http://www.twitter.com) used Ruby on Rails?
Do you think it was a good decision?
7. Explain what ‘has_many’ is and what happens when it is run.
class Monkey < ActiveRecord::Base has_many :bananas end
8. Given a simple website focused on a REST model and produced solely by using script/generate scaffold. Explain what happens in the rails application when a user submits a form with a POST request to: ‘/images/1′. State any assumptions you make.
9. If each language was represented as a person what type of person would each be and why?
- Ruby person
- Python person
- Php person
- Java person
July 26th, 2008 at 1:08 am
“Why would you prefer working on Rails rather than an architecture that supported, say, intra-hit debugging and continuations, such as Seaside (http://seaside.st)?”
July 27th, 2008 at 8:16 am
“1. You are getting the chance to fly in the worlds first unmanned Airplane who’s systems are written only in ruby. Would you fly in it? Explain you’re reasoning”
Well, if it’s unmanned then there’s no space for passengers, so you’ll be clinging to the fuselage. Personally, I avoid duct tape class.
And is the apostrophe part of a trick question? Is the actual question “Explain you are reasoning”, wherein an explanation that you are a reasoning being is required.
Damn tricky question if you ask me.
July 30th, 2008 at 10:27 am
Interesting questions. Abstract and imaginative - just the way i like it.
My personal take on the airplane question is this.
If i am getting a chance to fly in this airplane, then that implies that i have already made the choice to fly in it. So provided all goes well, yes.
Tricky question indeed.
July 30th, 2008 at 12:25 pm
You gonna provide any answers to these?
I’m particularly interested in the answer to question 5!
July 31st, 2008 at 1:34 pm
I’m happy to give answers to any questions if anyone requests it. Though the comments from people above have shown some of the best and most entertaining answers are the ones I was not expecting
Regarding question 5:
The object_id method returns the identity of an object. Every object must have a unique id. Hence if two objects have the same object_id, they are the same object.
Ruby’s booleans and nil are objects, so they deserve to be treated like real objects just like the rest. So they too should have an object_id.
When allocating object ids we are restricted with what ids we can use as Fixnum uses the odd object_ids (well all those needed to reach the maximum Fixnum). It takes the odd ids as the least significant bit is always set to 1 to flag this as a Fixnum.
So starting at the sensible point of 0 this leaves us with the following order:
July 31st, 2008 at 7:43 pm
Question 4 is obviously “sometimes yes, sometimes no”. A better question would ask *when* it is a good idea.
I’d be pretty annoyed getting the last question on an interview.
August 4th, 2008 at 7:30 pm
I would counter that, I think there is another valid answer to the question: Never! I think there are valid arguments for this. I do ask for examples after the question to backup the argument but you are right I could phrase the question better.
The last question is a bit silly but its interesting seeing peoples reactions to it. Really what I’m looking at is:
1. Preconceptions of the languages
2. Enough knowledge of each to express some traits.
3. Sense of humour
August 13th, 2008 at 8:23 pm
Hi,
It really good effort to pass this article here its really helpful for me you can also find other info related to ruby at http://www.interviewmadeeasy.info/ruby