Has anyone read this book?

L

Laurent Julliard

Yesterday I cam across a Web page mentioning this book on "Data
Structures and Algorithms with Object-Oriented Design Patterns in Ruby"
by Bruno R. Preiss.

http://www.brpreiss.com/books/opus8/

I'd like to know if anyone has read this book with care and has an
opinion about it? I spend an hour or so on it and was under the
impression that the content was good but that the source code of the
examples look a bit too Java-ish.

Note: The same book for JAVA and C++ was published on paper by Wiley.

Thanks for you comments.

Laurent
 
L

Laurent Julliard

Antonio,

Thanks for your feedback. I reviewed a couple of Ruby source files and
the code was not as bad as the one you spotted. Obviously the entire
code needs to be rewritten if one want to make a good Ruby book out of it.

I was however under the impression that this could be a good reference
book for data structures and algorithm in Ruby now that more and more
people (finally !) realize that behind Rails there is a really good
programming called Ruby.

Apart from the escellent "Desing Patterns in Ruby" by Russ Olsen there
is not much litterature on the subject.

Laurent

Antonio said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Laurent said:
[...] I'd like to know if anyone has read this book with care and has an
opinion about it? I spend an hour or so on it and was under the
impression that the content was good but that the source code of the
examples look a bit too Java-ish.

Hi Laurent,

versions of the book exist for C++, Java, C#, Python, Lua, Perl, PHP and
Ruby. The focus is clearly on the algorithms and the code is just
adapted for the given language. It's not idiomatic Ruby.

While idiomatic C++, Java and C# are roughly similar, this is not the
case when you also consider Ruby, Perl or Python.

For example, Program 2.6 is:

def geometricSeriesSum(x, n)
sum = 0
i = 0
while i <= n
prod = 1
j = 0
while j < i
prod *= x
j += 1
end
sum += prod
i += 1
end
return sum
end

Which is, from a Ruby standpoint, a mess.

In Ruby, you'd most likely write something along the lines of:

def geometric_sum(x, n)
(0..n).inject(0) { |sum, i| sum + x**i }
end

or use Enumberable#sum directly.

Cheers,
Antonio
- --
http://antoniocangiano.com - Zen and the Art of Programming
http://stacktrace.it - Aperiodico di resistenza informatica
http://math-blog.com - Math Blog: Mathematics is wonderful!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgS/ooACgkQqCqsu0qUj9RW0wCdEMU/N19SlCzXu6NGtiajyXND
DFUAoKHpNMC6C03oDClpYw9vq1pIYU/6
=w3TF
-----END PGP SIGNATURE-----
 
M

M. Edward (Ed) Borasky

Laurent said:
Yesterday I cam across a Web page mentioning this book on "Data
Structures and Algorithms with Object-Oriented Design Patterns in Ruby"
by Bruno R. Preiss.

http://www.brpreiss.com/books/opus8/

I'd like to know if anyone has read this book with care and has an
opinion about it? I spend an hour or so on it and was under the
impression that the content was good but that the source code of the
examples look a bit too Java-ish.

Note: The same book for JAVA and C++ was published on paper by Wiley.

Thanks for you comments.

Laurent

This comes up fairly often on the list. I can't say I've read *any*
version of it in depth, but there are better books available on similar
subjects in just about any (programming) language you can name.

For object-oriented design patterns in Ruby, your best bet is Russ
Olsen's _Design Patterns in Ruby_. I don't know if there's a good book
on data structures and algorithms in Ruby, though. Data structures and
algorithms are often explored in a language-independent manner, and
often using the "natural" recursive formulations. Translation to
specific programming languages is left as "an exercise for the student." :)
 
J

John Joyce

If you've done C, you've come across the the most important data
structures for it: structs, unions, enums, arrays, pointers, linked
lists
Well, really just knowing what of the standard types to use for what.

With Object Oriented programming (which can be done in C... just not
gracefully) you get other things that are very useful and sometimes
language dependent.
In particular collection or container classes that include arrays and
structs but take things to a new level of convenience.
Hashes are commonly used with key-value pairs (some languages call
them dictionaries or other names)

The most unique to ruby is the old Symbol class. Get the rest of Ruby
and Symbol will make more sense, especially when and how it is useful.
Ruby's other unique feature is its ability to enumerate over its
collection classes with great ease and power.

Beyond that, any data structures book will give you ideas.
Take a look at other people's code too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top