Excellent review! Gives me an idea for a good blog post, too -
patterns and idioms in the Rails source.
Nice review, but coverage of the GoF patterns? But I’ve read so many
otherwise intelligent folks say that the GoF patterns were created to
address the limitations of less flexible languages, and that there’s
no need for them in a language as powerful as Ruby…
Excellent review! Gives me an idea for a good blog post, too -
patterns and idioms in the Rails source.
Nice review, but coverage of the GoF patterns? But I’ve read so many
otherwise intelligent folks say that the GoF patterns were created to
address the limitations of less flexible languages, and that there’s
no need for them in a language as powerful as Ruby…
Nice review, but coverage of the GoF patterns? But I’ve read so many
otherwise intelligent folks say that the GoF patterns were created to
address the limitations of less flexible languages, and that there’s
no need for them in a language as powerful as Ruby…
What gives?
I was wondering about that myself. I think the Singleton pattern gets
used a lot in Ruby, though. Definitely a question worth asking.
Nice review, but coverage of the GoF patterns? But I’ve read so many
otherwise intelligent folks say that the GoF patterns were created to
address the limitations of less flexible languages, and that there’s
no need for them in a language as powerful as Ruby…
What gives?
I was wondering about that myself.
Ruby isn’t immune to design patterns.
Some patterns are very trivial in Ruby (Visitor is basically just a
method that takes a block), and some others don’t make as much sense
in Ruby (Factory isn’t nearly as important with classes being objects
themselves). Ruby also inspires some new patterns, I believe. The
ideas that led to the design patterns and many of the patterns still
apply to Ruby in some fashion though.
Nice review, but coverage of the GoF patterns? But I’ve read so many
otherwise intelligent folks say that the GoF patterns were created to
address the limitations of less flexible languages, and that there’s
no need for them in a language as powerful as Ruby…
Gracias! It was useful actually – I forgot about Singleton being in
the std lib.
Pat’s review says the book covers only 14 of the GoF’s original 23
patterns, I think that’s the explanation for the disparity between
“Ruby makes design patterns useless!” vs. “design patterns can be
useful in Ruby.” Presumably the missing 9 are considered either not
necessary, or just less interesting, in Ruby.
Nice review, but coverage of the GoF patterns? But I’ve read so many
otherwise intelligent folks say that the GoF patterns were created to
address the limitations of less flexible languages, and that there’s
no need for them in a language as powerful as Ruby…
What gives?
I was wondering about that myself. I think the Singleton pattern gets
used a lot in Ruby, though. Definitely a question worth asking.
Well … I have the book. I’m totally unfamiliar with the GoF book. I
know it’s a classic, but I’ve just never gotten around to learning
design patterns. So I got the book and I like it. If you’re already an
expert on design patterns from another language, for example, from “Head
First Design Patterns” (Java) I rather doubt you’ll learn anything from
this book that you don’t already know. But for me, it’s exactly what I
need.
Has anybody read it? Does it come recommendafied? I still haven’t
found a great tech bookstore in Los A. so I haven’t browsed it.
I thought it was well written. Personally, I didn’t really learn
anything new from it, but I’ve strongly suggested that the less
experienced developers on my team give it a read. Perhaps it’s got
something to do with the fact that it uses Ruby to discuss the
patterns, but the book also seems to be more approachable than its GoF
counterpart. (Could also just be that I’ve had a lot more experience
with such things since I read the GoF book the first time.)
IMO, patterns give you a common vocabulary to speak with other
developers and a way to refactor existing code.
Raganwald wrote a good blog entry about it Another problem with problems with design patterns
I didn’t want to say anything when this was first asked, because I was in
the middle of an interview with Russ Olsen (the author) at that point. I just
posted the interview this morning, so if people are still wondering why
design patterns are important even in a language like Ruby, you might
want to take a look:
On Jan 8, 2008 1:26 PM, Giles B. [email protected] wrote:
Nice review, but coverage of the GoF patterns? But I’ve read so many
otherwise intelligent folks say that the GoF patterns were created to
address the limitations of less flexible languages, and that there’s
no need for them in a language as powerful as Ruby…
What gives?
I didn’t want to say anything when this was first asked, because I was
in
the middle of an interview with Russ Olsen (the author) at that point.
I just
posted the interview this morning, so if people are still wondering why
design patterns are important even in a language like Ruby, you might
want to take a look:
Well … I have the book. I’m totally unfamiliar with the GoF book. I
know it’s a classic, but I’ve just never gotten around to learning
design patterns. So I got the book and I like it. If you’re already an
expert on design patterns from another language, for example, from “Head
First Design Patterns” (Java) I rather doubt you’ll learn anything from
this book that you don’t already know. But for me, it’s exactly what I
need.
Far be it for me to disagree with someone who seems about ready to buy
my book, but… oh well.
You see, I think that if you picked up a book on design patterns in Java
on your way to writing a program in Ruby, you will be making a serious
mistake. As others have pointed out, Ruby is different from Java and the
other traditional programming languages in some serious ways: open
classes,
and dynamic typing to name just a couple.
What I did in the book was to stand back and look at each pattern and
ask
a couple of questions: “What problem is this pattern trying to solve?”
and, critically, “How do people typically solve this problem in Ruby?”
Turns out that sometimes the Ruby solution is pretty much the same as
the Java solution. A Composite in Ruby is pretty much the same as a
Composite in Java. But for many of the patterns - here Commands and
Iterators come to mind - the Ruby solution is radically different
than the Java solution. Why? Those are the kind of questions that I
tried to answer in the book.
One of the nice things about Ruby is that many problems are much easier
to solve. The last thing we need is folks writing Java or C# code in
Ruby. We need people writing Ruby in Ruby.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.