Adventures in HttpContext All the stuff after 'Hello, World'

How I Got Started Learning Ruby on Rails

As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the]8 video (I use a Mac).  I’m very happy with them.  I’ve also heard great things about the Rest screencast (now in version 2, I’ve seen version 1 and liked it).  I plan on getting the Git and RSpec videos as well.

If you don’t want to spend money, check out Railscasts.  These are done by the same people from peepcode and offer shorter videos on specific topics.  Well worth it.  (For those .NET people, think of Dimecasts).

The Hardware/Software Setup

I use a MacBook Pro.  It’s pretty easy to get setup with Rails on a Mac.  Google for the how-to.  For an editor, I use Textmate and love it. (Especially after watching the Peepcode screencast).  I played around with [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the]8 video (I use a Mac).  I’m very happy with them.  I’ve also heard great things about the Rest screencast (now in version 2, I’ve seen version 1 and liked it).  I plan on getting the Git and RSpec videos as well.

If you don’t want to spend money, check out Railscasts.  These are done by the same people from peepcode and offer shorter videos on specific topics.  Well worth it.  (For those .NET people, think of Dimecasts).

The Hardware/Software Setup

I use a MacBook Pro.  It’s pretty easy to get setup with Rails on a Mac.  Google for the how-to.  For an editor, I use Textmate and love it. (Especially after watching the Peepcode screencast).  I played around with]13 and NetBeans, but stopped using them both.  It’s not worth it if you’re just starting out- these two programs are good IDE’s, but they wrap a lot of functionality that I’m finding is just easier to do on the command line.  Get comfortable with the simple first and add what you feel you’re missing.  On Windows, I’ve played around with e Text Editor and found it pretty nice.

IDE’s are very important.  As a .NET developer, I love Visual Studio.  It’s awesome- I love the intellisense, resharper, the immediate window, debugging, tfs integration, I’m spoiled.  You can pry code completion from my cold, dead hands.  I wanted that in Rails IDE.  But don’t try finding Visual Studio for Rails- Rails doesn’t need Visual Studio, and it will just get in the way.  Everything you need to do can be done in a simple text editor and the terminal window.  When you feel like you’re lacking something, there’s an easy way to do it.  Different is okay.

Other Stuff

This is random:

  1. Ruby in 15 minutes is a great site for learning Ruby.
  2. Learn and understand Git.
  3. You seriously haven’t checked out [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the]8 video (I use a Mac).  I’m very happy with them.  I’ve also heard great things about the Rest screencast (now in version 2, I’ve seen version 1 and liked it).  I plan on getting the Git and RSpec videos as well.

If you don’t want to spend money, check out Railscasts.  These are done by the same people from peepcode and offer shorter videos on specific topics.  Well worth it.  (For those .NET people, think of Dimecasts).

The Hardware/Software Setup

I use a MacBook Pro.  It’s pretty easy to get setup with Rails on a Mac.  Google for the how-to.  For an editor, I use Textmate and love it. (Especially after watching the Peepcode screencast).  I played around with [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The [As I wrote recently in a previous post, I’ve been playing around with Rails.   I wanted to touch on how I got up and running learning and digging into Rails.

Learning Ruby on Rails

The Web:

Ruby on Rails Guides is the best place to learn Rails.  People looking to get started should definitely start here.  The guides are broken down into various topics, and are extremely well written with good coverage.  You’ll get exactly what you need, even if you’re an experienced programmer.

Books:

I bought Simply Rails 2 and almost immediately returned it.  It’s geared towards someone who has no programming experience whatsover.  It has minimal depth, if any.  Don’t buy this book.

I then bought The Rails Way which I did not return, and now use as a reference.  It’s a pretty big book with a decent amount of whitespace.  However, I like this book because it’s not a how-to book.  It’s also not really for learning Rails, but by explaining what Rails does and why.  It has a good format- with snippets from contributors highlighting certain points (think of the comments in Framework Design Guidelines).  To be honest, you can get what you need from the Rails guides, but if you like books, get The Rails Way.

I also found some PDF’s of Rails Recipes and Advanced Rails Recipes which I found useful.  However, Rails changes pretty frequently, so a lot of books get outdated pretty quickly.  Rails Guides is simply your best bet.

Peepcode and Railscasts:

I’m usually not a fan of screencasts, but I bought a 5 pack from Peepcode and am glad I did.  I wish I bought the unlimited.  Peepcode offers very well done videos about various topics on Rails.  There are also some pdf e-books you can download.  So far I’ve bought The]7 e-book which is worth the $9, and the]8 video (I use a Mac).  I’m very happy with them.  I’ve also heard great things about the Rest screencast (now in version 2, I’ve seen version 1 and liked it).  I plan on getting the Git and RSpec videos as well.

If you don’t want to spend money, check out Railscasts.  These are done by the same people from peepcode and offer shorter videos on specific topics.  Well worth it.  (For those .NET people, think of Dimecasts).

The Hardware/Software Setup

I use a MacBook Pro.  It’s pretty easy to get setup with Rails on a Mac.  Google for the how-to.  For an editor, I use Textmate and love it. (Especially after watching the Peepcode screencast).  I played around with]13 and NetBeans, but stopped using them both.  It’s not worth it if you’re just starting out- these two programs are good IDE’s, but they wrap a lot of functionality that I’m finding is just easier to do on the command line.  Get comfortable with the simple first and add what you feel you’re missing.  On Windows, I’ve played around with e Text Editor and found it pretty nice.

IDE’s are very important.  As a .NET developer, I love Visual Studio.  It’s awesome- I love the intellisense, resharper, the immediate window, debugging, tfs integration, I’m spoiled.  You can pry code completion from my cold, dead hands.  I wanted that in Rails IDE.  But don’t try finding Visual Studio for Rails- Rails doesn’t need Visual Studio, and it will just get in the way.  Everything you need to do can be done in a simple text editor and the terminal window.  When you feel like you’re lacking something, there’s an easy way to do it.  Different is okay.

Other Stuff

This is random:

  1. Ruby in 15 minutes is a great site for learning Ruby.
  2. Learn and understand Git.
  3. You seriously haven’t checked out]2 yet?
  4. I spent too much time searching the Internet learning rails and not enough time programming Rails.  Get to it!

Digging into Ruby on Rails from C# and .MVC (Asp.Net MVC)

One of the things I’ve been doing lately is digging into Ruby on Rails. I’ve always wanted to learn Rails since I was first exposed to Rails at an AjaxWorld conference in ’06 (at least, I think in 06). David Heinemeier Hansson actually presented!

Alas, I never could devote enough time to get past the tipping point. I’m comfortable with C# and ASP.NET and evolving those skills has always been the priority. But the perfect storm has happened recently- in order to save space in my apartment, I got rid of my PC desktop and now only use my MacBook. I got tired of using Parallels and Visual Studio, and a new project came up in which I could either use ASP.NET MVC (which I’m calling .MVC from now on) or RoR. I thought it was time to finally try RoR.

The verdict is Rails is great. I still can’t “express” myself as well as I want to with Rails, but in comparison to .MVC Rails is pretty slick, and the evolution of Rails (specifically, combining Merb with Rails) is pretty exciting.  Most importantly, learning Rails has actually made me a better C#/ASP.NET MVC developer- if you’re working with .MVC you have to spend at least an afternoon playing around with Rails- you’ll get an invaluable perspective on MVC and web programming.

Now, a discussion on any programming language/framework always causes a heated debated.  I’m not an expert (or even a beginner) on Ruby or Rails, but these are my initial impressions.

**Ruby, as a Language

**

One major leap between .MVC and Rails is Ruby as a language. Yes, Ruby and C# are both OO languages, but Ruby is a dynamic language– and if you’re up on C# 4.0, you’ll know that C# is on it’s way to becoming a dynamic language too. So if you want keep your C# skills on the cutting edge, get a head start on a full fledged dynamic language!

I originally made the mistake of jumping in and assuming Ruby was more vb- or js- esque than it actually was.  It’s pretty smart in the way it behaves, almost a tailored version of C#.  Ruby’s use of symbols is pretty big difference over other languages that’s extensively used in Rails and pretty handy.

Lambda expressions are also core part of Ruby, and are becoming a more integral part of C#.  This allows Ruby to be extremely concise in getting things done- which is awesome when you know what you’re doing.  When you don’t it can be confusing.  But lambdas make sense and are awesome when you know how to use them- and knowing Ruby can help you grasp lambda expressions in C#.

Rails leverages Ruby’s dynamic language to make a lot happen under the hood.  I personally found letting the Rails framework do its thing as one of the biggest hurdles in learning Rails.  I wanted to either program or explicitly orchestrate everything!  One prime example is the persistence model in Rails-  I struggled to figure out how properties where set in models from migration classes- but it’s entirely automatic!  Also, a lot of methods are created dynamically.  This allows an extremely fluid expression in writing code, making Ruby a pretty natural programming language.  (Example: the find_by ActiveRecord methods; declaring links like edit_xxx_path).

C# is making its way into being a more fluid programming language similar to Ruby.  Meaning, writing code and describing code are converging to be the same thing.  This is seen in lambda expressions and fluent interfaces, where you can daisy chain methods together.  Moq is a good example of the fluent interface approach.  I wouldn’t be surprised if there’s even a larger convergence with C# and Ruby in the years to come.

Rails, as a Framework

Those in the .NET world who follow Jeremy Miller have probably heard the term of opinionated software. He talks about opinionated software in the context of FubuMVC, an alternative to .MVC written in an opinionated style.  It’s worth checking out- it’s very interesting to use but Rails still cracks the MVC shell wide open because it leverages Ruby’s language features.

Opinionated software originally came from the Adam and Eve of Rails, 37Signals.  Rails is highly opinionated- which is a blessing and curse.  The great thing about Rails is that it does what it does extremely well.  The MVC triangle are completely separate but seamlessly integrated, and extension points are explicit.  It’s how MVC should be- and .MVC doesn’t come close to Rails as an MVC framework.  Hate NHibernate configuration?  You’ve never seen an ORM framework until you’ve used ActiveRecord.  Really want to abandon code-behind files and excessive code in views? Really want to do TDD (and even BDD)?  Rails right now is the iPhone in a tin cup and string world.

Here are some highlights:

  1. Respond_to method for rendering html, xml, json or whatever from a single controller.  .MVC ActionResult could learn a thing or two.
  2. Rails’ partial layouts, partial actions and partial views are pretty slick compared .MVC’s master pages, partial views, and partial layouts.  A prime example is using Rails partial views to render a collection of objects.
  3. Passing data between controllers and actions is a lot slicker than .MVC ViewData
  4. Rails helpers are a lot more helpful.
  5. Rails is pretty slick when it comes to mapping between posted data and Models- a lot better than binders.
  6. And of course, Rails’ database integration will make you wonder why you ever spent more than 5 minutes learning about databases- it’s such a model centric approach with migrations you’ll hate doing any data tier work in .MVC.  (Although learning databases are extremely important no matter what language/framework you use).
  7. Plugins.  Rails Plugins are simply awesome- extremely fluid integration into your Rails application.  And combining plugins and other support with gem makes maintenance and upgrades a breeze (forget the GAC!)

Where .MVC Shines

I’ve been hyping up Rails a lot, but there is a major disadvantage with Rails: good luck straying from the Rails track.  If you get off the train, you’re walking alone.  This is something .MVC does well- allows you to change the game with whatever architecture pattern you wish.  It’s one reason I love .NET- you can do literally do whatever want (yes, you can whatever you want with any language, but the .NET framework is pretty awesome).  .MVC is extremely extensible- from replaceable view engines, routing engines, controller factories, coupled with whatever architecture pattern you want.  And all very testable.  C#’s usage of extension methods also add pretty nice extensibility to classes, too.

In fact, Rails’ plans to integrate with Merb as way to be more modular is a prime example of something .MVC already does well- allows you to mix and match what you want instead of forcing conformance.  Allowing total and explicit control over the application stack- including your architecture- is a great advantage in maintaining the health of ongoing software. Yes, you can evolve Rails to do what you want, but the transparency .NET offers is something I don’t see in Rails just yet.  It’s definitely a pro and a con- on the one hand, Rails offers fluid interaction between components.  On the other, .NET doesn’t force you into any specific pattern.

In Conclusion

The bottom line is, check out Rails.  The best way to get started is with the Rails guides.  From a .MVC perspective, you’ll learn a lot about MVC and what an MVC framework can do- and it will help you out in your .NET development.  Knowing Ruby will also keep your C# skills sharp and help you in becoming a well rounded developer.  I’ll even bet you carry over some Rails tricks to your next .MVC app!

kick it on DotNetKicks.com

canonical url:


All those jQuery fans: new event delegation

jQuery 1.3 now has a ‘live’ function which acts similar to liveQuery. It lets you wire up events automatically for newly injected DOM elements. Not bad!

Understand Unit Testing and TDD: Getting Better Code Coverage

One of the biggest challenges in unleashing the power of unit testing is getting good code coverage.  Most of the time, especially when teams are just starting out with Test Driven Development, unit testing usually gets in the way.  A lot of people (I succumb to this syndrome sometimes) add tests after they develop code.  The audacity! Some people just don’t unit test at all- especially when struggling with mocking a dependency, like a database or the HttpContext object.  And forget about finding more than one unit test for functions- you already have one for a function which passes- so you’re done, right?

The secret in unit testing is understanding what you need to test.  You are not just testing something works- you’re testing specific functionality behaves as expected.  Once you understand this difference, not only will TDD be easier to achieve, but developing large projects, ensuring business rules, enforcing API guidelines, and concurrent development on the same feature will be easier and faster for you and your team.

This post will help you think about testing: what you need to do to add unit tests to your existing project or add to what you already have.  We’re not doing test first- hopefully, this will be a precursor to TDD in getting you thinking about what to get out of your unit tests so you can get into the TDD groove.

**Expectations And Reactions

**

Each class- and each function- has a specific purpose.  Systems are built on the interaction of these classes and functions.  Classes call functions.  Functions call other functions.  Data is processed.  Objects are returned.  Exceptions are thrown.  All of this interaction is like a clock- the pendulum swings, the gears turn, the hands move.  When everything does what it should, you have a healthy, usable, working system.  When something doesn’t, chaos ensues and thing don’t work- the hands of the clock don’t move.

This boils down to a simple concept of expectations and reactions.  Class A expects Class B to do something when Class A calls a function on Class B.  Class A is dependent on Class B’s behavior.  What you’re looking to do is create a suite of tests to ensure Class B is actually doing the behavior Class A expects- from valid return values to handling exceptions- so the hands on the clock always turn.

The Code

Download the sample code here.

I’ve created some simple code which represents an ordering system we’ll say is part of typical three tier MVC application, similar to Rob Conery’s MVC Storefront, I’ve backed everything with interfaces.  To keep things simple, I’ve done this as a single class library- you can imagine all the other mumbo jumbo thrown in there.

We’re simply going to be shipping an order- which involves getting an order from our data tier and then using a shipping service to ship the order.  For this series, I’m only going to focus on a single method in our business tier: the OrderShipmentManager.ShipOrder() function.  This will help us look at one of the two main components for a successful test suite: knowing what to tests and setting up mock objects.  In a real world application, you’ll want to apply the expectation/reaction approach to each layer.

Currently, I’m only going to focus on what tests we need to have.  I’ll dig into how to set up mocking in another post.  Let’s start by looking at how our ShipOrder is being called in the controller:

IOrderShipmentManager opm = new OrderShipmentManager(new DataTier.OrderStorage(), new DataTier.ShipmentService());

Shipment shipment = null;

try

{

shipment = opm.ShipOrder(orderId);

}

catch (OrderShipmentException ope)

{

System.Diagnostics.Debug.Write(“Whoops: {0}”, ope.Message);

}

View(shipment);

Most controllers should look like this: very light, with the bulk of your application in your business logic layer.  This is a fairly simple call: in my controller, I take in an orderId I want to ship, and pass it to ShipOrder(). The controller expects two things to happen: a shipment to be returned, which it can pass to the view; or an exception to be thrown.

So let’s make sure we have two unit tests to cover these two expectations (Note: I always prefix unit tests with CLASS_FUNCTION.  This makes viewing test results easier. I didn’t add that here because of redundancy- but the test project will have each test prefixed with OrderShipmentManager_ShipOrder):

[TestMethod()]

public void Returns_Shipment_Object()

{

}

[TestMethod()]

public void Throws_OrderShipmentException_When_What()

{

}

So I have my two unit tests- but the problem is, when should ShipOrder return a shipment? What should it actually do? And when does ShipOrder throw an exception?  What the hell do I write in these tests? We could look at the view to figure out what it does with the Shipment object.  We could read the requirements to figure out what ShipOrder should do (or, in an agile world, figure this out from our user story).  But we don’t have these things.  So let’s look at the function to see if we can make heads or tells of this:

public Shipment ShipOrder(int orderId)

{

Order order;

Shipment shipment;

if (orderId < 0) throw new OrderShipmentException(“OrderId cannot be less than zero”); order = _orderStorage.GetOrder(orderId); if (order == null) return null; if (order.ShipmentStatus == ShipmentStatus.Shipped) { throw new OrderShipmentException(“Can’t ship an order that’s shipped!”); } shipment = _shipmentService.CreateShipment(order.Customer.CustomerId); shipment.ShipmentProducts = new List();

order.OrderItems.ForEach(oi => shipment.ShipmentProducts.Add(oi.Product));

_shipmentService.CalculateShipment(shipment);

_shipmentService.Ship(shipment);

order.ShipmentStatus = ShipmentStatus.Shipped;

order.ShipmentId = shipment.ShipmentId;

_orderStorage.SaveOrder(order);

return shipment;

}

Ahh, I get it now! We get the order from our order storage.  If it’s null, we can’t ship, so we return null- n0 need for an exception.  If the order’s been shipped, throw an exception.  Next, create a shipment with our shipment service, calculate the shipment cost, and save the order.  Return the shipment and we’re done.  Now we can add a suite a tests.

Let’s focus on exceptions.  Here, we plan on throwing exceptions when either the orderId is bad or the order has already been shipped.  Other code will expect an exception to be thrown under these circumstances.  If we change this logic, things could get screwed up- code can’t react accordingly, and chaos ensues.  People may have already written code based on these expectations.  So let’s write some unit tests to ensure we’re always throwing an exception under these circumstances.

[TestMethod()]

public void Throws_OrderShipmentException_When_OrderId_Is_Less_Than_Zero()

{

}

[TestMethod()]

public void Throws_OrderShipmentException_When_Order_Status_Is_Shipped()

{

}

We’ve essentially enforced two business rules with these unit tests: when to throw our two exceptions.  (You can argue when or when not to throw an exception.  Personally, I follow the rule: If a function can’t do what it should, throw an exception).

Coincidentally, we’re also guaranteeing something else: that our ShipOrder function will always react the same way under certain circumstances.  Here, ShipOrder will always throw an exception with an invalid orderId.  It won’t return null- and it won’t continue.  That’s important for processing logic- we wouldn’t want to create a shipment when we don’t have an order.

Next, let’s go into functional logic.  I want to make sure a couple of things are happening, mainly that the workflow is consistent.  Let’s add some unit tests around the order object:

[TestMethod()]

public void Gets_Order_From_Storage()

{

}

[TestMethod()]

public void Saves_Order_With_ShipmentId_And_Status()

{

}

[TestMethod()]

public void Returns_Null_When_No_Order()

{

}

Next, our shipment object does a couple of more things:

[TestMethod()]

public void OrderShipmentManager_ShipOrder_Creates_Shipment_For_Customer()

{

}

[TestMethod()]

public void OrderShipmentManager_ShipOrder_Copies_OrderItems_To_Shipment()

{

}

[TestMethod()]

public void OrderShipmentManager_ShipOrder_Calculates_Shipment()

{

}

[TestMethod()]

public void OrderShipmentManager_ShipOrder_Ships_Product()

{

}

Finally, we now know what this function should return:

[TestMethod()]

public void OrderShipmentManager_ShipOrder_Returns_New_Shipment_With_Order_Items()

{

}

We have a pretty robust suite of tests around our ship order function.  We’re not only testing how the controller deals with this function, but the internal workings of the function as well- the expectations other objects have of our ShipOrder method.

What This Means

The core principal of testing is to make sure something works as expected.  In principal that’s totally obvious and makes perfect sense- why the hell am I even writing about it?  In reality, implementing something which meets that definition is extremely vague and easily debatable.  The pitfall most people get into in attempting TDD- or even writing unit tests- is their definition of “I’m proving it works as expected” is wrong.

Evolving systems- especially those built with agile development- change a great deal over time. What we want to do is make sure the behavior of everything we write is always the same as these changes occur.  Ideally, nothing can be taken for granted- return values, exceptions, processing.  All must be tested.  Changes create little ripples in the interaction between all the dependencies in a system. Unchecked, ripples grow bigger and bigger into tsunamis of horrible, horrible bugs.  It’s important to understand what these interactions are, and make sure new changes don’t alter current behavior.

Where TDD Fits In

TDD simply makes you think about these interactions before you code, so you know what each class and function does for the greater good.  For most people, especially getting started with TDD, that’s a lot to wrap your head around.  Especially when you’re the type of coder that likes to code first and have the system morph into what you need it to be.  With TDD, you can easily end up over analyzing the situation, testing too much or too little.  That’s why TDD is very iterative- figure out what you need, write your single test to enforce it, then write code to pass your test.  But it’s important to note the level you need from your tests.  If you need a ShipOrder function that returns a shipment, don’t just check it returns a shipment.  Enforce it’s doing every step it should- your unit tests are guaranteeing every assumption every other piece of code makes is valid.

Up Next

I didn’t talk about mocking at all.  Mocking is the second most important factor of testing: after knowing what to test!  In another post, I’ll talk about how to write the unit tests I outlined above.  Unit tests also provide numerous benefits I mentioned earlier in this post: enforcing standards, allowing concurrent development and faster coding (no need for those console apps for class library development!).

kick it on DotNetKicks.com

Saving dynamically added list items using jQuery and ASP.NET MVC

There are going to be times when you want to allow a user to enter multiple copies of a single form on a web page.  This frequently happens when adding items to a list- like products in a shopping cart or tasks in a task list.  You want the user to add as many “items” as they want to the list, then save the entire list at once.

Dynamically adding elements to a page is easy with jQuery, but parsing out list items on the server can be difficult- especially when you don’t know how many items are on the page!   Things get even trickier when the number of input controls for each item increases- you have to keep all these input controls in sync so each item gets saved correctly.  Luckily, ASP.NET MVC has a built in feature to pull out a list of complex types posted to a page and automatically put them in a model.  We’re going to combine this feature with jQuery to dynamically add form elements on a page which end up in a list of complex types that can be accessed in a controller action.

In our example,  a user will be creating a shopping list and will  have the ability to add items to the shopping list dynamically.  When the user hits “Save” the entire list with all items will be posted to the server and serialized into a ShoppingList model.

We’re going to use:

  • jQuery to dynamically drive the client side and dynamically add list items
  • ASP.NET MVC as our web infrastructure
  • The DefaultModelBinder to build a list of complex types which can be passed to an action method.

Our model is simple- we have a ShoppingList with properties of Name and ShoppingItems:

public class ShoppingList
{
public string ListName { get; set; }
public IList<ShoppingItem> Items { get; set; }
}

public class ShoppingItem
{
public string Name { get; set; }
public int Quantity { get; set; }
}

Posting Multiple Items At Once

The key to this feature is posting multiple related elements which end up in a list.  In order for the DefaultModelBinder to build a list, we have to post elements in a certain way.  Essentially, each set of related input elements are grouped together using a uniquer key.  The key can be any string- it doesn’t have to be an integer index.

Keys are specified with a hidden input element.  In our sample, we want our list to end up in the myList.Items property.  So for every object in the Items list, we need a hidden input field with a name of “myList.Items.Index”.  The key we specify for the element will be the key we use in the name attribute the input element.  If our key is “foo”, and our property is “Quantity”, we’ll have:





[/pre]

Even though we couldn't do that in c#, we can do it in our markup.  Think of keys for a hashtable- the key can be anything you want.  The hashtable is a list of the complex type your building, so typing hashtable["myKey'] returns the complex type, and you have access to all properties of that type.

I've created a unit test which shows off this magic for multiple items:




shoppingController.Request.Form.Add("myList.ListName", "My Shopping List");
shoppingController.Request.Form.Add("myList.Items.Index", "1");
shoppingController.Request.Form.Add("myList.Items[1].Name", "Chocolate");
shoppingController.Request.Form.Add("myList.Items[1].Quantity", "5");
shoppingController.Request.Form.Add("myList.Items.Index", "Alpha");
shoppingController.Request.Form.Add("myList.Items[Alpha].Name", "Graham Crackers");
shoppingController.Request.Form.Add("myList.Items[Alpha].Quantity", "10");

Notice how we're passing multiple "myList.Items.Index" values.  Don't worry- they won't overwrite eachother.  Servers turn multiple name values into a comma delimited list (you'll end up with: "1,Alpha" has your values for "myList.Items.Index".  All the DefaultModelBinder is doing is parsing the list of  keys for whatever array you want, then matching those values to the form package. My naming convention of myList.Items is simply allowing the myList parameter in the controller action to be populated correctly by the DefaultModelBinder.

To reiterate, the indexer I use for each array object is simply grouping related html elements together- Graham Crackers has a quantity of 10 because I'm using the same indexer for each name: Items[Alpha].Name and Items[Alpha].Quantity, just like a hashtable.

The rest of the unit test shows how the DefaultModelBinder will build the ShoppingList Item's property using these form values:


var defaultBinding = ModelBinders.GetBinder(typeof(ShoppingList));
var bindingContext = new ModelBindingContext(shoppingController.ControllerContext,
shoppingController.ValueProvider,
typeof(ShoppingList),
"myList", null, shoppingController.ModelState, null);
var binderResult = defaultBinding.BindModel(bindingContext);

Assert.IsNotNull(binderResult);
Assert.IsNotNull(binderResult.Value);
Assert.IsInstanceOfType(binderResult.Value, typeof(ShoppingList));

var myList = binderResult.Value as ShoppingList;

Assert.IsTrue(myList.ListName == "My Shopping List");
Assert.IsTrue(myList.Items.Count > 0);
Assert.IsTrue(myList.Items[0].Name == "Chocolate");
Assert.IsTrue(myList.Items[0].Quantity == 5);

Assert.IsTrue(myList.Items[1].Name == "Graham Crackers");
Assert.IsTrue(myList.Items[1].Quantity == 10);

The View

I want a button to "add another item" to the shopping list.  If the user clicks this button, two new textboxes should appear: one for name, and another for quantity.  These need to have the same indexer.  When the page first loads, there should already be an item to enter.

I have a couple of choices to build this logic.  I could specify one set of input elements in the view, and use jQuery to add individual elements to the DOM when the user hits the button.  I don't like this idea because it means I have two places to build the list items: one in the view, the other in jQuery.  When you build the same code in multiple places, you're going to get discrepancies, which lead to bugs-  I guarantee it. I could use jQuery to add the default form when the page loads, but I don't like this- html is easy and simply, it allows me to see what I'm doing.  It's much easier to write html than write javascript to build html.

Instead, I'm going for a partial view approach using actions.  By putting the injected section of markup into its own UserControl with a controller action I can embed the markup in the parent view and use ajax to get the rendered html snippet to the client via a url.  I can also choose how to generate the indexer in the action method's body: I'm going to use Guids.  With Guids, I won't have to track any other indexers- I'm guaranteed a unique value I can use for all the related elements in the partial view.  Here's the markup:

The parent view, which the user sees on load:




The partial view for each item:




<input type="hidden" name="<%= ViewData["Prefix"] + ".Index" %>" value="<%=ViewData["GUID"] %>" /> <input type="text" name="<%= ViewData["Prefix"]  + "[" + ViewData["GUID"] + "].Name" %>" />
<input type="text" name="<%= ViewData["Prefix"] + "[" + ViewData["GUID"] + "].Quantity" %>" />

I chose to make the "prefix" I need a variable so I can potentially use this same view in other forms if needed.  I may want to put this form somewhere else, where the server argument isn't myList, but something else- I could forgo a parameter of ShoppingList and want to post a list of ShoppingItems.  This is useful when adding some sort of "update" feature in another section of page- say, when I already have a ShoppingList and I'm updating with a new list of items.

On the client side I simply wire up my button to request the html snippet from the server and inject that snippet with jQuery:


$(document).ready(function() {
$("#btnAddAnother").click(function() {
$.ajax(
{
type: "GET",
url: "/Shopping/ShoppingItemFormContent/myList.Items",
success: function(result) {
var toInject = $(result);
$("#itemContainer").append(toInject);
}
});

})

});

There's something I don't like about this: I need to call the server every time I need a view.  This isn't that snappy, and could create a lot of chatter with the server.  There's a way around this for brevity I'm only going to explain: render the indexer as a specific value which can be parsed out and replaced with something else later.  My original goal is only wanting one place to specify markup: I do not want to have to duplicate code across a project.  But that shouldn't mean I need to call the server every time I need an html snippet.  I could make the snippet regular html which can be cached, then use a string or regular expression replace function to replace the hard coded indexer with something unique.

You can download the sample project here.
kick it on DotNetKicks.com

Hiring Software Developers: The In House Interview (Open Ended Questions)

_Note: This is part of a series on hiring software developers.  See articles tagged with interview for the series.  I needed to break the in house interview post into two parts.  This part focuses on open ended questions._

The in house interview is by far the most important part of the hiring process.  It’s also the most difficult.  You need to vet a person thoroughly in a very short time.  If you don’t have a strategy for the in house interview you will not effectively gauge a candidate nor be able to make a confident ‘yes’ decision.  Furthermore, if you enter into a bargaining/negotiating process, you want enough information to know how far to go in the negotiations.

Open Ended Questions

Quite simply, you’re testing a developer on how well they solve problems.  No, not those ridiculous how many dentists are in San Fransisco questions.  Development problems- that measure a candidate in how well they analyze information, gather requirements, structure applications, organize data, implement software and scale for the future.  These are development- not programming- problems.  They’re not algorithms or set theory or knowing the best collection class to use.  These are problems regarding how well you go from a customer or product owner telling you something to a living, breathing software system.  If you’re an agile development shop, or want to be one, it’s essential you hire developers- not programmers- who do this well.

Open ended questions offer a suite of scenarios where you explore various skills that define a good developer.  These scenarios are really up to you and can include everything from data modeling to application architecture to user interface design.  Essentially, you simply tee up a situation and see how the developer deals with the situation.  There’s no right or wrong answer, just good or bad discussions.  More importantly, it requires solid communication- the ability to understand and explain ideas- which is the cornerstone of a good developer.

The Questions

The first example focuses on application design and analysis.  Here in New York, we have MTA vending machines.  These are straightforward machines that let you buy either a prepaid or an all-you-can ride pass with credit or cash.  It’s a simple system, everyone in New York has probably used it, and is perfect system to talk system design.  A regular ATM machine or other common system also works well- you want the developer already have an understanding of the system so they can focus on application design.

Design the system architecture for an MTA vending machine.  How would you break up the system into various components? How would the system work? What problems can occur? How can you deal with them?

I get to see how well a candidate can come up with all the different things you’d need to know about a vending machine, and how thorough they are in their application design.  If they say “I’ll create a user input class and a payment processor” they’re not thinking through the issues. If they ramble on for ten minutes, they’re not organized with their thoughts or approach.  I want to know how well they understand tiers and class design- roles and responsibilities and program organization.  Don’t be afraid to ask what classes they would create to implement this system.

This question should focus on a system the user is already comfortable with.  Don’t have them gather requirements- it throws another dimension which can be difficult to maneuver, and takes away from the core point of system design.  It’s important to ease them into this interview approach, so they don’t get flustered or confused (however, it probably says a lot about them if they do).

Here’s a data modelling question inspired by Flickr:

Design a data model for photo album software.  There should be photos, where each photo belongs to one, and only one album.  Albums belong to users.  Users can view other people’s photos if they are marked as public.  If a photo is private, no one can see the photo.  Each photo can be tagged using a simple “tagging” system.  Photos can have comments, which are linked to both the photo and the user who wrote the comment.  Finally, photos can belong to sets.  A set is a group of photos from various users.  A set is owned by a single user, but anyone can add a photo to a set.

This question works well on two fronts.  First, it obviously covers data modelling.  More importantly, it gauges the candidates ability to absorb information.  The question is explaining what we need from a business perspective- it doesn’t list any specific attributes.  The candidate should think and ask what we need to put in these tables.  The question also highlights entity relationships, to see how well the candidate can deal with joins and data organization.  Unlike the MTA question, I’m not approaching this as if they new what system I was talking about.  I could make this like the MTA question by saying, “Datamodel Flickr”.  I didn’t.  I’m looking how well they go from what the customer wants to an implementation- specifically, a data model.

Here’s a web service related question:

Let’s say I have two existing systems- an ordering system and a warehouse system.  The ordering system handles billing customers and fulfilling orders.  The warehouse system tracks inventory and sends shipments.  Currently, each night, orders are printed from the ordering system and faxed to the warehouse, where they are checked to see if they have any inventory.  If they are, they are fulfilled.  If not, they get put on hold and the warehouse calls the sales rep to have them update the ordering system to mark the order “on hold” until the product comes in.  Your job is to make the ordering system and warehouse system talk to each other via web services.  What does the communication between the two system will look like?  What functions need to be exposed at which points?

There’s a part two:

A problem has occurred: Unfortunately, the connection between the two sites may be unreliable, but will never be down for more than a day.  It’s too cost prohibitive to upgrade the connection, and you’re asked if there’s anything you can do with the new service.  How would you design the system so a user can enter an order on a web page that will eventually get fulfilled by the warehouse?

I like this because not only does it talk about vanilla web services, it also hints on extensibility.  Here, the candidate is asked to lay out a web service design and come up with some schemas.  If they can boil this down to a simple client/server service, great.  If they come up with a complex two way communication system bad.  But, after they laid out the initial design, they’re confronted with a major issue.  What do they need to do to deal with this problem given what the original solution?

The big kahuna question- everything rolled into one:

This one is mostly geared towards senior level programmers.  I was asked this question once in an interview and loved it- it was very draining, but in the end, it allowed me to show the company I was worth it.  It essentially wraps up all kinds of role playing questions into one big one.  Be warned- it also takes a while to do thoroughly.

Essentially, you, as the interviewer, sketch out a set of web pages on paper.  Do this before hand.  When I got asked the question it was an insurance site.  A CMS system, blog site, or project tracking system works well too.  For the insurance system, there were four pages: The account owner, with a bunch of the usual fields (name, address, city, SS#).  Then, there was a form for cars- an owner insured a car.  Make, model, year, etc.  Next, there was a form for insured drivers.  This could just be account owner, or members of their family.  Cars were linked to insured drivers, and offered a price for the insurance.  The owner could buy the insurance or not.  You need to have four or five hand drawn web pages, each with a form, all related.

So you walk the candidate through the hand drawn forms and what needs to happen, and you have them do numerous things.  They need a data model.  They need to design the application- data tier, business objects, web pages, whatever classes they need- see what they come up with.  They need to figure out how to get from one page to another and maintain state.  Sometimes I throw in a curve ball- in order to figure out the quote price, you need to call a long web service which could take ten to twenty seconds.  What’s the user experience like? How do you deal with this?  Finally, you tell them they’re running a dev team, and ask how they would break up the work to the different developers.  See how they approach this- it will give you a sense of well they know how to delegate and run a team.

**What You’re looking For

**

Remember, with the phone interview done, you should have a solid understanding of the technical ability of the candidate.  But that’s not the most important quality of a candidate.  Google will tell me how to use ThreadPool.QueueUserWorkItem for multithreaded programming.  The real quality is knowing when I need multithreaded programming and knowing the difference between the ThreadPool API and asynchronous delegates. That’s what you’re looking for in these answers- the meat, not the special sauce.

You can also create your own questions depending on the work you do.  The point is to focus on a specific thing you’re looking for- data modelling,  SOA, application architecture, user interface design, business objects, or everything all in one- and try and stear the conversation in the general direction you want.  But let the candidate do most of the driving.

With each question, have a specific area of focus.  See what their toolbox is like if you want to know about implementation or programming.  If it’s about requirements, see how well the analyze the problem and cover the bases.  You know the problems you need to solve- so set up sandbox environments to see if they have the skills to solve your problems in various areas.  You decide how specific to get- and whether these are one, five or 20 minute questions.

If you’re not getting what they want, you may need to nudge them a little.  But be careful not to ask lead in questions.  If you set up a question like, “Okay, tell me how you would handle error in the MTA machine?” and they reply with, “Exceptions” they simply don’t get it.  If the struggle with the answer they probably don’t know what to do- you’ll easily spot this when you see it.

What’s Next

There’s a lot more to the in house interview- everything isn’t solved with open ended questions.  My next post will cover what else to ask- those personal, character building questions as well as how to structure the interview.

Best Comment Ever

I found this when going through some code:

//I have no idea what the following code does
//but the ui seems to function better without it
//except for when it crashes

Event Pooling with jQuery Using Bind and Trigger: Managing Complex Javascript

Managing Complexity in the UI

As everyone knows, the more dependencies you have in a system, the harder maintaining that system is.  Javascript is no exception- and orchestrating actions across complex user interfaces can be a nightmare if not done properly.

Luckily, there’s a great pattern for orchestrating complex interaction in a disconnected way. No, it’s not the Observer pattern.  It’s a take on the Observer pattern called Event Pooling which is a piece of cake with jQuery’s bind and trigger functions.  For the get to the code folks, here’s an example of using jQuery’s bind and trigger for event pooling.

Problems with the Observer Pattern

The observer pattern is great for some things, but it still requires a dependency between the observer and the subject.  The publish/subscribe scenario creates a direct relationship between two objects- and makes orchestrating a lot of events difficult when you have to manage so many direct references.

observer pattern

observer pattern

Event Pooling

Event pooling is simply a variation on the Observer pattern, where a “middle man” is used to orchestrate the publish/subscribe system.  First, an observer will register with the event pool by saying “I need to call this function when this event is fired”.  Next, the subject will tell the event pool “I’m firing this event”.  Finally, the event pool will call the function the observer registered on behalf of the subject.  The observer and subject only need to know about the event pool, not each other.

Event Pool

Event Pool

This provides some cool functionality- especially because if you need to reference the subject (called the publisher), you can get a direct reference via the event pool.  This is similar to the object sender parameter in .NET’s event system.

Show me Code!

We are going to do two things: First, update a span tag to show an address when a user enters a name, city, or state.  Second, show some complex behavior by daisy changing events and binding a single function to multiple triggers. Check out the example.

We have an UpdateOutput() function that updates the span:

function UpdateOutput() {
    var name = $('#txtName').val();
    var address = $('#txtAddress').val();
    var city = $('#txtCity').val();

    $('#output').html(name + ' ' + address + ' ' + city);
}

This is wired up via the bind function:

$(document).bind('NAME_CHANGE ADDRESS_CHANGE CITY_CHANGE', function() {
    UpdateOutput();
});

Notice how we’re wiring up multiple event names with a single function which calls UpdateOutput.  This allows us to encapsulate common functionality in a single function which could be called from various sources.

We’re also binding and firing to $(document).  Document provides a global bucket all functionality has access to- a static class that can be referenced from anywhere, making pooling easy.

We can also wire up another function with the NAME_CHANGE event without effecting any other logic:

$(document).bind('NAME_CHANGE', function(e) {
    UpdateName();
    UpdateOtherText(e);
});

Here, NAME_CHANGE will also trigger UpdateName and UpdateOther.

Firing an event is done with the trigger function:

$('#txtAddress').keyup(function() {
    $(document).trigger('ADDRESS_CHANGE');
});
$('#txtCity').keyup(function() {
    $(document).trigger('CITY_CHANGE');
});

It can also be called directly from html:

Name: <input type="text" id="txtName" onkeyup="javascript:$(document).trigger('NAME_CHANGE');" />

Advanced Functionality

There are two more things you can do with bind and trigger: Inspect who fired the trigger (this can be important if you’re wiring up a single function from multiple subjects) and pass data to the event.

In our next example, our function definition takes in two parameters: e, which is the event’s sender, and data, a generic data bucket:

$(document).bind('FIRST_UPDATED', function(e, data) {
    UpdateOtherText(e, data);
});

The first parameter will always be the event’s sender.  You can wire up as many other parameters as you want.  You pass data as a comma delimited list between brackets [parm1,parm2] when calling trigger:

$(document).trigger('FIRST_UPDATED', [data]);

and from html:

<input type="text" id="txtData" onkeyup="javascript:$(document).trigger('DATA_CHANGED', [$(this).val()]);" />

The sender object has a couple of properties, but the most important is ‘type’, which let’s you know what triggered the event:

function UpdateOtherText(e, text) {
var text;
if (e.type == 'FIRST_UPDATED')
 text = 'from first: ' + text;
else
 text = e.type;
$('#eventFired').html(text);
}

Check out my follow up article Organizing Events for Event Pooling.

[]5

kick it on DotNetKicks.com

Adventures in Agile: Practical Scrum (Intro)

Disclaimer: I am not a certified scrummaster, nor have I taken any formal scrum classes.  I have, however, worked with scrum a great deal at my job, and wanted to share my experiences.

Let’s face it: Scrum is a Utopian pipe dream.  The user stories, working in sprints, task estimations, no deadlines, uncommitted backlog, visibility, transparency, business buy-in, everyone’s happy, fast development, easily responding to change, everyone gets what they want, everybody gets it and works together- it’s all a hot air and completely unrealistic.

Okay, so maybe that’s a little bit harsh.  How about this argument- real Scrum- true Scrum- ideal Scrum- is a Utopian dream.  It’s a never ending struggle for a more perfect union.  The essential problem is we, as humans, are incapable of living up to the requirements of ideal Scrum; and business mentality will never allow Scrum to work in the practical world.  It’s a round peg in a square hole.  But if you believe- and try- you can get partly there, and that, my friends, will be good enough.

Utopian Scrum

Scrum is dependent on the cohesion of too many disparate factors- mostly three sets of opposing forces.  First, the difference between practical feasibility and the unrealistic demands of requirements; second, the need for “When can I get it?” delivery dates from the business versus the complete impossibility of defining those dates accurately; and third, the need for a group of people to fluidly communicate and work together in a variety of situations.

Scrum works- and delivers- when these three completely impossible scenarios are met.  Scrum simply sets groundrules on how these groups of people interact and manage their work.  But that requires disparate groups of people working and interacting effectively.  Unfortunately, most of the time, it’s doesn’t fully happen.  The business will never be satisfied with vague, long term deliverable goals.  The business wants concrete information so they can make decisions- they want to know when product “A” will be ready for launch so they can do x, y and z and estimate revenues.  An uncommitted backlog? Story points? WTF is that?  Nor will the business ever fully comprehend the cost/benefit analysis that goes into any sort of feature development.  What do you mean let’s wait and see? I want to know what it’s going to be like now! It needs to do x, y and z be be super simple to use- can’t we just have it do this other thing?  Why will that take so long? I want to tell you how to do it- and if you already do it, why would we change it? I know how it should work!

My personal favorite is the working together part.  Do you really think it’s possible to get a group of introverts- all with their own egos and insecurities- to proactively communicate, share ideas, and work effectively as a team?  Heads down, opinionated, or really quiet developers?  This is the “this conversation is too simplistic for me” crowd! The “I talk in code” crowd!  And everyone on the team can operate without high level direction- and figure out requirements- and bring up impediments or issues when they arise- and ask questions- crowd?  Yeah, right! These are programmers!

Practical Scrum

Don’t worry- all is not lost.  The principals of Scrum are pretty solid and good ideas, and even if you only get half way there, you’re better off than with anything else.  Visibility and transparency are extremely important with any development group, and knowing where you stand with the big picture is solid information anyone can appreciate.  Most of the time the business doesn’t really care about when things happen, they just want an accurate estimate for planning.  Who wouldn’t want that?  When you hit your stride with Scrum, it may not be perfect- but both you, the development team, and the business- are all better off because everyone gets enough of what they need with a manageable amount of overhead.

The main problem with Scrum is that in principal everything make sense.  It’s easy to see how it works- the backlog, the sprint, the scrum, the estimations- but when you try to do it, everything false apart. In practical terms, it’s impossible to make all the chips falls as they need to- to make everyone understand what they need to do- and to get everyone in the organization on the same page.  Most people either end up with a bastardization of the process, or worse give up out of frustration.

Practical Scrum is that middle ground between where you are now and Utopian Scrum.  It’s the half way of making what you have work, and like Scrum, iterating to a better place one thing at a time.  Practical Scum is simply understanding how to implement Scrum to make your organization work effectively.  The key is not jumping into the deep end with Scrum hoping you know how to swim.  Hint: You’ll drown.

I’ll delve into various aspects of Practical Scrum in future posts.  For now, it’s important to remember a couple of things:

  1. Don’t give up.  If it doesn’t work, don’t worry, it usually doesn’t.
  2. Scrum is easy in principal; in practicality, it’s extremely difficult.
  3. Like everything, you need to move in baby steps when adopting Scrum.
  4. Remember: If you do it, they will come. This simply means once your team is on Scrum, and you start delivering, people will recognize it works.
  5. The goal isn’t learning Scrum- or what Scrum is.  The goal is learning how to adopt scrum.  Like the principals of Scrum, go with the flow.  Iterate.  Make subtle improvements.  Get to where you need to be at a healthy pace.
  6. Don’t rush it.

I’ll dig into how you get to where you need to be in Scrum in future posts.  I’ve been on the brink of giving up too, but am happy I’ve stuck with it.  Now we’re starting to hit our stride, and it’s great.  Yes, it’s still rough around the edges, but that’s a fact of life with everything.

Getting there isn’t half the battle- it is the battle.

How to Hire a Software Developer: The Phone Interview

Note: This is part of a series on hiring software developers.  See articles tagged with interview for the series.

The Phone Interview

The purpose of the phone interview is twofold.  First, a simple baseline for communication is established.  Communication is the most important quality a candidate can have.  You can always learn new technology, but if you can’t communicate clearly- your ideas, your work, and your ability- you probably won’t work well in a collaborative environment.  Secondly, the phone interview provides a benchmark for technical ability.  This is usually a list of straightforward programming questions in the particular language most important to the job. I use this list of .NET questions to get a sense of surface area and depth.

Communication

How do you know a candidate is a good communicator? A two prong approach works best: first, have them go over their resume. Ask about the projects they’ve worked on, and what they did on those projects. How good are their answers? Do you have an understanding of the work they did? Did they ramble on too much, or not provide enough depth, or repeat themselves? If you asked any questions did they give a direct answer?

Second, find out how well they answer technical questions. This isn’t an issue of right and wrong, it’s about complexity. Did they provide a clear explanation of the answer? Were they concise and confident they knew what they were talking about? Was there a hint of ego in their response? The more you phone interview the more you can tell someone who is good or bad at communication. It’s that “thing” that makes you say, “Tell me more!”

Technical Questions

There are plenty of sites out there for programming type questions- whether C#, PHP, Java, etc.  You know the technology you work with- so ask the candidate if they know it too.  Be flexible on this, we often interview people without any knowledge of the programming language we use.  If you’re an expert in one language, you can probably pick up another pretty well.  Try and figure out how well the candidate has dug into their craft.  This will also give you the opportunity to rank a candidate as junior, mid-level, or senior.  It also lets you know how much they’ve hyped up their ability (if you have the audacity to list php, .NET, java, perl, cobol and fortan as your “expert languages”, I’m calling you out on it).

Break up technical questions into a standard set of categories. This includes SQL/Database work, class design/architecture, web programming, web services, html, javascript, language/framework how-to’s. Go in with more than you can possibly fit into the allotted time: this will allow you to maneuver during the technical interview. It doesn’t make any sense to ask a candidate who has no sql experience a bunch of sql questions. Instead, focus on their stronger skills or go for more surface area.

How many questions to ask? That’s easy: ask until they get something wrong. This is important, because it allows you to see how they handle themselves when they don’t know something. They’ll either flat out admit they don’t know it, make an educated guess (hint: they’ll have a good sense of reasoning skills), or lie. I prefer going for surface area then depth. First, find out how much they know about different things. Second, pick some of the most important areas you’re looking for and go for depth: see how much they know in that area.

Here are some questions I use for the phone interview, or the in house interview if needed. Note, I’m not going for detailed how-to’s. I like to keep things high level, as I believe it’s important to know concepts. Google will tell me how to expire cache after ten minutes.

Divide and Conquer

Usually, the phone interview is handed out to a lot of different people, as it’s somewhat time consuming and very hit or miss. Some prefer to have one person do the phone interview so they can easily compare candidates to make it to the next round. Either way, it’s important to make a checklist. A checklist lets you remember the differences between candidates, and allows other developers to easily summarize their phone interviews. I’ve gotten a lot of blank stares and “How do I do this?” after asking developers to do phone interviews. Give them a set of questions- and a checklist for them to fill out- will make your and their lives easier. If you can’t into trouble (i.e. sued) for not bringing somebody in, a checklist will also give you cover.

Conclusion

The most important thing for you to know is don’t worry about ending the interview early. If clearly you don’t like them, you just say any number of things:

1) “I’m sorry; we’re looking for someone with more experience. Thank you for applying.”

2) “Thank you for your time. Unfortunately, we won’t be able to move forward.”

3) If you want to postpone the face to face, there’s always “We’re in the process of interviewing candidates now and will let you know about the next round in XX days.” Then, e-mail them no in XX days. This works if someone else is doing the phone interview, or you want to mull it over. Giving them an e-mail date prevents them from living in limbo when you’ll get back to them. It’s simple respect.

You can even add in “We’ll keep your resume on file” if you feel guilty. My point is, be respectful: if you know they’re a no, don’t waste their time or yours.

How do you decide you makes it or who doesn’t? Simple: if they impress you and you want to know more, invite them in. Your gut check should be, “This person has potential.” If not, don’t move forward. If you’re on the fence, put them on hold until you seriously would want to hire them. Don’t bring them in for the sake of bringing them in- the in house interview should take some time, and if you’re not serious about them, don’t have them put on a suit, take time away from their current job/life, and make them travel just to use as a benchmark for something else. It’s not right.

Ideally, 15% of your applicant pool you want to do a phone interview with.  Maybe 25% if you are in a tight technical market like NYC.