Ruby on Rails interview questions – part 2

Continuing the “RoR interview questions” sequel(part one here) , these are some general Rails concepts and technologies questions. Enjoy :).

Continue reading

Design Patterns: Ruby and Ruby on Rails

I am creating a new page on my blog, regarding Ruby and Ruby on Rails Design Patterns links.

Regarding Ruby Design patterns, there are (in my opinion) 2 major resources: The “Ruby Design Patterns” book of Russ Olsen and the Ruby Best Practices Blog. The Design page is about the rest of them :).

A first link: a slideshow regarding common design patterns (Observer, Decorator, Factory, Command) implemented both in Java and Ruby. Enjoy.

Ruby on Rails interview questions – Part one – Ruby

Ruby

This is the first article on the RoR interview questions. The purpose is not necessary to be used to ‘cheat’ on an interview, but to present some tricky things in Ruby and RoR.

Some (the majority) of the questions do not yet have answers. I will be filling the blanks.. soon 🙂

What is the duck typing?

The duck typing can be seen as one of the ruby implementation of polymorphism. The principle is: “If it walks like a duck and quacks like a duck, I would call it a duck.”. Below is an example of this principle (from http://www.javaworld.com/javaworld/jw-07-2006/jw-0717-ruby.html).

Continue reading

Java Lists: Group by element property (as Ruby group_by method)

This is a very funny function, similar to group_by from Ruby.
It takes a collection and it transforms to a hash, having keys the property *groupBy*, and values the objects having that property.

A usage example:

collectionToHash(users, "name"); // returns a hash where the keys are the distinct user names, and the values are lists of users having that property.

Continue reading