Learn Rails Backwards
13 Jun 2011I sometimes run free Rails courses locally here. One of the things that I have learnt is that it seems to be best to teach Rails ‘backwards’. What do I mean by that? Well it depends on how you define ‘forwards’! If you practice TDD then a high level process would be to:
- Write your (failing) test in RSpec
- Write Rails code to pass the test
This means knowing Ruby before you even start step one above, of course. However, when teaching Rails, I like to do things in reverse, namely:
- Learn how to write Rails code
- Learn how to write RSpec code
- Learn how to write Ruby code
Now, of course it’s all Ruby, but the point is that the order when teaching / learning Rails is reversed compared with what is done in practice. Of course, this approach does have its good and bad points.
Good Points
- It’s easier to jump straight into a framework with some simple examples and exercises to wow the students
- A lot of the time, Students can start building something cool right after the first lesson
- It’s especially good for new programmers as their interest in what is going on behind the scenes starts to seep through subconsciously.
Bad Points
- It may be the beginning of a lifetime of bad habits (a.k.a “where are your tests!”).
- Following on from the above point, tests make for beautifully simple code – only do what you need and no more. If the student gets into the habit of writing tests after then the code will not be so simple.
- For some students, maybe the more experienced ones, it might be better off with the ‘forward’ approach: Learn Ruby, TDD / RSpec, Rails.
What are your thoughts on this?