Posted by Rick DeNatale
Tue, 29 Jan 2008 21:24:00 GMT
About a year ago when I first encountered RSpec, I thought that the idea sounded good, but I was concerned about how much the implementation at that time pushed new methods into Object and Kernel. It felt to me as though it could interfere with the code being specified/tested. Indeed back then there were some problems when RSpec and Rails bumped heads over the use of certain Ruby metaprogramming techniques. I’d been a TDD user advocate for many years, heck I was there right after Kent Beck, “test-infected” Erich Gamma and sat in on some of their early pairing sessions during an annual OTI company technical conference at Montebello in Quebec, when JUnit was in it’s infancy. The cleaner language of RSpec did have it’s attractions, particularly in trying to get across the idea to newcomers that TDD was really writing mini-specifications rather than tests, which helps put them in the right mindset, but for those of us who had already crossed that paradigm shift, or been born on the right side of it, it didn’t seem so important.
Since then the RSpec implementation has matured, and after talking to David Chelimsky and Dave Astels at RubyConf, I decided to give it another look, and, armed with a new perspective on the use of mocks and stubs to isolate specifications and tests in BDD/TDD, I quickly became a convert. I still use other frameworks as external requirements dictate, but RSpec has become my first choice.
These days, though the choice of testing/specification framework seems to have become one of those religious issues which divide the community, almost as much as emacs vs. vim vs. textmate. I run into people all the time who reject RSpec because it’s “too magical!” Although I’ve never been able to get them to expand on that thought. Perhaps it’s based on the kind of concerns I had about it at first, maybe it’s something else. I’d love to have it explained.
And like advocates do, other arguments get expressed, some of which don’t get the scrutiny they deserve.
Read more...
Posted in ruby, rails | Tags bdd, Rspec, tdd, TestSpec, TestUnit | 3 comments | no trackbacks
Posted by Rick DeNatale
Tue, 01 Jan 2008 19:39:00 GMT

I've written before in this blog about how the meaning of the term "object-oriented programming" got hijacked from it's original meaning. For example I go into this in some length
in my mini-memoirs.
I recently ran into an interesting site with links to "Classical Computer Science Texts", which in turn led me to this e-mail exchange with Alan Kay on the meaning of OOP from July of 2003.
This exchange gives support, with details, for my description of Kay's concept of what Object-Oriented Programming was supposed to mean.
I'm not against types, but I don't know of any type systems that aren't a complete pain, so I still like dynamic typing.
- Alan Kay
As Kay explains, the key concepts came from biological cell communications modeled as networked "whole computers" and a desire to "get rid of with data"
As for the influence of Simula on Smalltalk's notion of classes and inheritance:
I didn't like the way Simula I or Simula 67 did inheritance (though I thought Nygaard and Dahl were just tremendous thinkers and designers). So I decided to leave out inheritance as a built-in feature until I understood it better. - Alan Kay
And summing it up:
OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.
I'd argue that you can do this in Ruby as well. I don't know if Ruby was on Kay's radar in mid-2003.
Posted in ruby, smalltalk | Tags alankay, types | 6 comments | no trackbacks
Posted by Rick DeNatale
Thu, 27 Dec 2007 17:57:00 GMT


Disclaimer: I received a free copy of this book because I contributed a one-page essay about "What Rails Means to Me" which appears starting on page 821.
The Rails Way came out shortly before Rails 2.0 was released. I must say that it serves as a very valuable reference for those with some Rails experience, and in particular for those who are coming up to speed on Rails 2.0.
Read more...
Posted in rails, book_reviews | no comments | no trackbacks
Posted by Rick DeNatale
Sat, 17 Nov 2007 11:18:00 GMT
One of the things about working with software is that you can pretty much do anything you imagine.
Many of these things can be cool.
And many of them, particularly in retrospect, can be less than brilliant.
Here are two of the more visible cool, but stupid things I've done in the past.
Read more...
Posted in smalltalk, war_stories | Tags smalltalkdistributed, stupidity, visualage | 1 comment | no trackbacks
Posted by Rick DeNatale
Sat, 03 Nov 2007 06:51:00 GMT

I finally got to meet Matz in person today, and we had a nice little chat.
I was pleased to learn that he follows this blog. My readership might be small, but it's quality readership. One thing I told him was that as much as I love, and still love, Smalltalk, I really do feel that I love Ruby just a little bit more.
We talked a bit about the upcoming stabilization of 1.9, which will be frozen as far as language and standard libary changes for the Christmas 2007 1.9.1 release, at which time transition from development to stable status. He has been backing out some of the differences between 1.8.x and 1.9.0. He told me that he had recently, or was soon to, revert the changes to the scoping of class variables. It appears that class variables will continue to be shared between classes and subclasses.
He also cleared up a technical ruby mystery that's been puzzling me for some time.
About a year ago I wrote about a change in Ruby 1.9 which cleaned up the semantics when modules included by a class are re-included in a subclass. The mystery is that sometime after I wrote the article, in a subsequent revision of 1.9, this got dropped. I never could find out why this happened, so today I took the opportunity to ask Matz in person.
Read more...
Posted in ruby, smalltalk | Tags matz, railsconf, railsconf2007 | 4 comments | no trackbacks
Posted by Rick DeNatale
Sat, 03 Nov 2007 00:50:00 GMT

Photo by Nathaniel Talbott.
This was not quite the largest audience Matz has faced there were about 500 in attendance at this evening's "Town Hall Meeting", he asid that he had spoken to a group of over 1000 in Japan, but that was not to an exclusively Ruby audience.
I captured most of the questions and answers as best as I could. Any errors of paraphrasing are mine:
- Q1
- What about backwards compatibility. My program broke when Ruby 1.9 changed File.exists? to File.exist?
- A1
- We try to keep the language as backwards compatible as possible, but File.exists? was an old method inconsistent with the naming of predicates.
- Q2
- (From an Engineer from TI looking at putting Ruby into new calculators) I don't like the licence on the regexp library function in 1.8. The regexp engine in 1.9 isn't "encumbered" by the GPL?! When will 1.9 be out.
- A2
- Ruby 1.9.1 will be out by Christmas 2007, but might not be as stable as we want.
Read more...
Posted in ruby | Tags matz, railsconf, railsconf2007 | 3 comments | no trackbacks
Posted by Rick DeNatale
Fri, 02 Nov 2007 13:32:00 GMT
Jim's talk was entitled "Advanced Ruby Class Design"
He started out talking about his own background with various programming languages and how influences from experience with other languages can both help and hamper learning Ruby. He said that while some things from Java/C++ like modularity carry over usefully to Ruby, but, that some very useful Ruby techniques are inconceivable to Java/C++ programmers.
Unlike Wallace Shawn's Vizzini, I'm pretty sure that Jim really does know what that word means.
He gave some examples of this from his "Classics", unfortunately, my note-taking skills are such that I can't capture enough to go into them in detail.
- From Rake, an example of why the FileList class, which acts like an Array broke because it was initially implemented as a subclass of Array. The fix was to NOT make it a subclass of Array, something which can blow the mind of someone coming from a statically typed OO language.
- From Builder, which uses "method_missing" to turn Ruby method calls into XML, a problem caused by interference between domain names, like 'class', and core Ruby object methods. The solution was to create a BlankSlate class which undefines most of it's inherited methods (it spares methods like __id__, and __send__). Then he found that he also needed to deal with methods added to Kernel and Object after BlankSlate was loaded. To do this he used method_added_hooks in Kernel and Object so that BlankSlate could remove newly added methods as they were defined. This later changed to use the append_features hook instead to catch methods added to Object or Kernel by module inclusion. Again, this is something which really requires coming from a less dynamic language to "Think outside the box."
He made another foray into "Parsing without Parsing" a Ruby technique for tracking the execution of a Ruby block with method_missing and proxy objects to "parse" the "source" of the block and capture an object graph representation. His motivating example was doing something like Err the Blog's Ambition which generates SQL queries from Ruby blocks. He gave lots of useful Ruby metaprogramming tips, up to and including where Ruby limitations led him to abandon this approach for SQL generation. Because of things like the inability to handle "syntactic sugar" operators like && and || since they aren't implemented as methods, he felt that these restrictions on contents of the block left him short of his goal to express the query in "natural" Ruby.
But the technique itself is quite useful, and finds use in tools like FlexMock and RSpec.
All in all a very thought provoking presentation from Jim. I hope he makes the slides available soon.
Posted in ruby | Tags rubyconf, rubyconf2007 | no comments | no trackbacks
Posted by Rick DeNatale
Fri, 02 Nov 2007 10:22:00 GMT

The conference led off with Marcel Molina reprising his Ruby Hoedown talk
"What Makes Code Beautiful".
I notice that he's changed the final solution to the problem he posed to "monkey-patch" String, instead of introducing a CoercibleString subclass. Did he read my earlier blog post?
no comments | no trackbacks
Posted by Rick DeNatale
Thu, 01 Nov 2007 00:12:27 GMT

I'm heading down to Charlotte tomorrow afternoon to attend RubyConf.
Maybe I'm taking a chance, but I decided to show you my face, in case any one going to RubyConf actually reads this stuff and want's to say hi.
Hopefully, I won't need body armor after this!
3 comments | no trackbacks
Posted by Rick DeNatale
Tue, 30 Oct 2007 16:31:00 GMT


I've been meaning to write a review of the recently published Apress book
"Pro Active Record"
by Kevin Marshall, Chad Pytel, and Jon Yurek for a while now. I have to admit that I was prompted to sit down and actually do it after reading
Josh Susser's recent review of the same book.
While I generally agree with Josh's assessment, We do differ a bit on which audience the book best serves.
The goal of the book is to cover Active Record in depth, outside of the context of Rails. The result, as I see it, is a book which is useful to intermediate to advanced users of Active Record, those who want to dig in to understanding the implementation and perhaps extending it.
My own reading of the book gave me the impetus to explore the code of Active Record to the extent where I felt comfortable submitting contributions to Rails. Since reading the book, I've written and submitted two active record patches to the Rails Trac. The first fixed an oversight which made the schema.db file dumped for MySQL tables with non-standard primary keys to lack those primary key declarations, and the second is an enhancement which allows the :joins option of methods like find and count in ActiveRecord::Base to take values like the :include option as an alternative to a sql joins clause string. Both have made it into rails edge!
Read more...
Posted in rails, book_reviews | Tags activerecord | no comments | no trackbacks