RSS 2.0
# Thursday, January 21, 2010

Probably you are aware of Edgecase Ruby Koans. In case you aren’t, let me introduce you to them.

From Wikipedia, Koan:

A kōan is fundamental part of the history and lore of Zen Buddhism. It consists of a story, dialogue, question, or statement whose meaning cannot be accessed by rational thinking, yet it may be accessible by intuition. A widely known kōan is "Two hands clap and there is a sound; what is the sound of one hand?"

The Ruby Koans are a set of failing test that you need to resolve. Of course the idea is not just to resolve the test as fast as you can but to read the code carefully and understand why it’s failing and them provide the solution.

Once you download the code you just run the rake command inside the folder where the Koans have been downloaded and you will be presented with a failing test and a message in the screen that indicates what you need to do to fix the test.

You should take as much time as needed to contemplate the solution and internalize the code, the syntax and the constructs that Ruby use.

I went through them once and I’m planning on do it again in a day of two. The Koans cover some important aspect in the following areas: asserts, arrays, arrays assignments, blocks. Classes, open classes and class methods.  Inheritance, hashes, exceptions and so much more, this is the complete list of files in the Koans folder:

17/01/2010  11:25 PM             2,024 about_arrays.rb
17/01/2010  11:29 PM             1,015 about_array_assignment.rb
17/01/2010  12:27 PM               942 about_asserts.rb
18/01/2010  11:51 PM             2,392 about_blocks.rb
21/01/2010  12:02 AM             3,873 about_classes.rb
21/01/2010  06:20 AM             3,820 about_class_methods.rb
18/01/2010  12:11 AM             2,320 about_control_statements.rb
22/12/2009  10:24 PM             1,436 about_dice_project.rb
18/01/2010  12:24 AM             1,374 about_exceptions.rb
22/12/2009  10:24 PM               317 about_extra_credit.rb
17/01/2010  11:35 PM             1,765 about_hashes.rb
21/01/2010  12:07 AM             1,652 about_inheritance.rb
18/01/2010  10:10 PM             2,441 about_iteration.rb
21/01/2010  06:39 AM             4,277 about_message_passing.rb
18/01/2010  12:02 AM             3,613 about_methods.rb
21/01/2010  12:10 AM             1,132 about_modules.rb
17/01/2010  08:08 PM             1,020 about_nil.rb
21/01/2010  12:03 AM               920 about_open_classes.rb
21/12/2009  04:38 PM             3,295 about_proxy_object_project.rb
19/01/2010  12:10 AM             2,657 about_sandwich_code.rb
21/01/2010  12:15 AM             1,870 about_scope.rb
20/01/2010  11:46 PM             1,843 about_scoring_project.rb
17/01/2010  11:51 PM             4,725 about_strings.rb
22/12/2009  10:24 PM               771 about_triangle_project.rb
22/12/2009  10:24 PM               486 about_triangle_project_2.rb
18/01/2010  12:12 AM               788 about_true_and_false.rb
22/12/2009  10:24 PM             1,111 array_test.rb
21/12/2009  04:38 PM                19 code_mash.rb
21/12/2009  04:38 PM             4,498 edgecase.rb
22/12/2009  10:24 PM                15 example_file.txt
22/12/2009  10:24 PM               156 first_test.rb
22/12/2009  10:24 PM             2,323 GREED_RULES.txt
21/01/2010  06:32 AM               895 path_to_enlightenment.rb
21/12/2009  04:38 PM               159 Rakefile
02/01/2010  10:19 PM             5,482 README.rdoc
22/12/2009  10:24 PM                70 test_helper.rb
18/01/2010  12:29 AM               821 triangle.rb

 

Open your favorite editor, launch the console and start running the Koans, just type rake and you will be presented with messages like this,after fixing it your awareness will “expand”.

Thinking AboutOpenClasses
  test_as_defined_dogs_do_bark has expanded your awareness.
  test_after_reopening_dogs_can_both_wag_and_bark has damaged your karma.

You have not yet reached enlightenment ...
<"HPPY"> expected but was
<"HAPPY">.

Please meditate on the following code:
./about_open_classes.rb:26:in `test_after_reopening_dogs_can_both_wag_and_bark'
path_to_enlightenment.rb:28

 

It’s very addictive, the only complain/suggestion I have is to provide some answer to some of the question in the code. May be in a separate show?

 

    # THINK ABOUT IT:
    #
    # Is it better to use
    #    obj.nil?
    # or
    #    obj == nil
    # Why?
kick it on DotNetKicks.com Thursday, January 21, 2010 11:09:54 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
General | Methodology | Patterns | Programming | Testing
Add The Dynamic Programmer Mippin widget
Navigation
Archive
<January 2010>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
What I'm reading
Shelfari: Book reviews on your book blog
About the author/Disclaimer
Hernan Garcia I have been a software developer for the last 16 years or so.
I was a journalist before and I still consider myself one.
Besides baseball, programming is my other big passion.

Me on twitter. @TheProgrammer
Certified Scrum Master
© Copyright 2010
Hernan Garcia
Sign In
Statistics
Total Posts: 197
This Year: 15
This Month: 1
This Week: 0
Comments: 70
Themes
Pick a theme:
All Content © 2010, Hernan Garcia