Data Structures and Algorithms with OO Design Patterns in Ruby
Data Structures and Algorithms with Object-Oriented Design Patterns in Ruby is an online book (free to read!) by Dr. Bruno R. Preiss, an incredibly well qualified engineer and computer scientist. It covers all of the various data structures and algorithms that beginning Computer Science students have to learn, but from a Ruby perspective and using object oriented design patterns.
The book itself is now a few years old, but I've only just come across it and it still seems relevant although, rather sadly, the on-page code is in graphics only (a ZIP file containing the source is available) and feels like a line-by-line conversion from C++ rather than true Ruby code. Still, if computer science, data structures, and algorithms elude you to any degree, and you want to learn about them while following Ruby code, it's a good place to start. There are also versions for C++, Java, C# and Python available from Bruno's homepage.
April 24, 2007 at 12:11 pm
While its always good to have more references (I suppose), if the awful piece of sample code presented is typical then this will have to wait some time before it gets to the top of my reading list. Why? Array already supports push() and pop() out of the box, and top() if you can stand to translate to first().
Goodness knows what the Stack implementation looks like. Some sort of linked list in a language without explicit pointers? Maybe he used an array? Ugh.
April 24, 2007 at 12:18 pm
Oh. I couldn't resist it - I peeked.
Ghastly ghastly ghastly.
Talk about not getting it.
April 24, 2007 at 3:33 pm
You are right, it is pretty atrocious ;-) I'm certain it's just a line for line conversion from C++.
However, I think the point of the text is to teach about structures and concepts rather than best practices per-se.