OOP in Ruby?

Hi,

Anyone know of any good resources regarding OOP in Ruby?

Aidy

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

aidy wrote:
| Hi,
|
| Anyone know of any good resources regarding OOP in Ruby?

Err, about everything, I guess. :stuck_out_tongue_winking_eye:

~From personal experience: The PickAxe (Programming Ruby), and The Ruby
Way by Hal F. cover this nicely. And I suspect the O’Reilly book The
Ruby P.ming Language (co-written by Matz) covers that in-depth,
too.


Phillip G.
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.blogspot.com

~ Is it a right to remain ignorant?
– Calvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkg1n3IACgkQbtAgaoJTgL/XggCfb2X2OGk9CN8rUCQQoLwWZLpP
IzcAoJCGS3oPjIjZ+C3l7+mDJKUQ6Hcn
=x33R
-----END PGP SIGNATURE-----

On May 22, 2008, at 9:29 AM, Phillip G. wrote:

I suspect the O’Reilly book The
Ruby P.ming Language (co-written by Matz) covers [OOP] in-
depth, too.

I’m surprised that RPL (does it even have an abbreviation?) hasn’t
made a bigger splash. Or have I just missed it? About the only thing
I’ve seen is a review by someone who didn’t finish it. It seems like
an O’Reilly book by Matz would be required reading for us all. And
Flanagan is a good writer, though he and I have clashed technically.

I still have some of Pickaxe left, then I’m going to dive into RPL.

///ark

Can you be more specific?

Ruby is so object oriented that’s it’s almost impossible not to learn
about OOP by using it.

Books: Pickaxe is good; I’m halfway through reading it from cover to
cover (while also using it for reference). Another book I have is Ruby
Cookbook, by Carlson and Richardson, pub. by O’Reilly, which is next in
the queue for my bedtime reading.

I didn’t know about the Matz book; that sounds well worth looking into.

Perhaps the OP is after a book on OOP illustrated by Ruby examples,
rather than the other way around?

On Thu, May 22, 2008 at 11:48 AM, Mark W. [email protected] wrote:

I’m surprised that RPL (does it even have an abbreviation?) hasn’t made a
bigger splash. Or have I just missed it?

I can’t cite any specific references, but I’ve heard a lot of good
things about it (and I own a copy as well). I get the impression it’s
selling fairly well. To be fair, it’s still a fairly new book and so
it’s not quite as well-established as the PickAxe.

aidy wrote:

Hi,

Anyone know of any good resources regarding OOP in Ruby?

You might do well to first look for good OOP references, then see how
they ideas are applied in Ruby.

Designing Object-Oriented Software by Rebecca Wirfs-Brock is quite good.

Be mindful that not everyone has the same idea of what it means to be
OO; Ruby is largely message-oriented (unlike, say, Java’s form of OO).
(And not everyone who writes about OO in Ruby sees it that way. Caveat
lector.)


James B.

http://www.rubyaz.org - Hacking in the Desert
http://www.jamesbritt.com - Playing with Better Toys

If I were to take a guess, I’d say the RPL hasn’t made such a splash
because it’s not really a “learn ruby” book, it’s a “ruby reference”
book.

I think it has the potential to be the Camel book or the K&R book, but
it’s in a tough position right now: the established ruby programmers
that need a reference book have the Pickaxe already and the ruby newbies
are looking for something a little more introductory.

Eventually people will start moving over to RPL.

To the best of my knowledge, RPL is your best source for ruby 1.9
information right now, which I’m sure will give it a leg up.

Just my 2¢,
-Dana

Lyle J. wrote:

On Thu, May 22, 2008 at 11:48 AM, Mark W. [email protected] wrote:

I’m surprised that RPL (does it even have an abbreviation?) hasn’t made a
bigger splash. Or have I just missed it?

I can’t cite any specific references, but I’ve heard a lot of good
things about it (and I own a copy as well). I get the impression it’s
selling fairly well. To be fair, it’s still a fairly new book and so
it’s not quite as well-established as the PickAxe.

I also own a copy. I don’t have it with me right now so I can’t cite any
specific examples, but I’ve found it oddly incomplete. Sometimes I’ll
look up something and not find it, and have to go to the Pickaxe
instead.

So, overall I think it’s a good companion to the Pickaxe.

On May 22, 2008, at 12:41 PM, Dana M. wrote:

To the best of my knowledge, RPL is your best source for ruby 1.9
information right now, which I’m sure will give it a leg up.

Actually, not wanting to toot my own horn too much, but… The new
PickAxe beta is more up-to-date: Ruby 1.9 has changed significantly
since December, and it continues to change. Hundreds of methods have
been added to the built-in set. Complex and Rational are now built in.
Existing methods have tweaks to their behavior. And changes are still
being made. If you want a paper book now with 1.9 stuff in it, then
RPL’s the only game in town. I deliberately haven’t looked at it
because I don’t want to taint what I’m writing for the PickAxe, but I
hear good things.

If you’re OK with a PDF that is getting updated as 1.9 evolves, then
you might want the PickAxe.

Dave

On May 22, 2008, at 10:00 AM, Lyle J. wrote:

it’s not quite as well-established as the PickAxe.
I wonder if most people are like you and me: bought it as soon as it
came out, but haven’t read it yet. :slight_smile:

///ark

On Thu, May 22, 2008 at 1:42 PM, Mark W. [email protected] wrote:

I wonder if most people are like you and me: bought it as soon as it came
out, but haven’t read it yet. :slight_smile:

Well, I’ve read parts of it, but given that it’s more of a reference
book, I wasn’t really planning to read it straight through anyways. I
did of course go through it to look at all of _why’s drawings, first
thing.

I wonder if most people are like you and me: bought it as soon as it
came out, but haven’t read it yet. :slight_smile:

Cant speak for anyone else but normally when i buy something i will read
it. But if it is too boring, I will never finish. That is a general rule
by the way. :wink:

The worst thing were some perl books years ago. I have never finished
reading them, gave most of them away already (only one is kept because I
will work through it, note what is important in my local knowledge base,
and then give this book away as well)

On Thu, May 22, 2008 at 1:03 PM, James B. [email protected]
wrote:

aidy wrote:
Anyone know of any good resources regarding OOP in Ruby?

Designing Object-Oriented Software by Rebecca Wirfs-Brock is quite good.

A classic indeed!

Be mindful that not everyone has the same idea of what it means to be OO;
Ruby is largely message-oriented (unlike, say, Java’s form of OO). (And not
everyone who writes about OO in Ruby sees it that way. Caveat lector.)

Which is why Rebecca’s book (actually Rebecca, Brian (Wilkerson), and
Lauren’s (Wiener) book, is appropriate for Ruby.

This was one of the early books approaching OO design in the context
of Smalltalk, which introduced the computation by messages between
objects. It advocates a role-based approach rather than the
abstract-data type approach, corresponding to the C++ (and to a large
extent Java) view of OO.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

On Thu, May 22, 2008 at 4:04 PM, Lyle J. [email protected]
wrote:

On Thu, May 22, 2008 at 1:42 PM, Mark W. [email protected] wrote:

I wonder if most people are like you and me: bought it as soon as it came
out, but haven’t read it yet. :slight_smile:

Well, I’ve read parts of it, but given that it’s more of a reference
book, I wasn’t really planning to read it straight through anyways. I
did of course go through it to look at all of _why’s drawings, first
thing.

I too am reading it slowly. Most of the time it sits ready for a
quick session in the Master “Library” at home.

I think that RPL and the Pickaxe are complementary, RPL covers the
language step by step in depth and really doesn’t cover the core and
extension class librarys nearly as well, if at all as the pickaxe.
The Pickaxe is more tutorial. Ultimately the serious Rubyist will
want both.

I’m think that in someway they are to Ruby what the K&R, and Harbison
and Steele pair of books are/were to C, although that’s not an exact
analogy.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Robert K. wrote:

about how messages transform internal state (although ADT is mainly
about observable state through sequences of method invocations). In the
end, in both cases an instance holds state which is changed via method
invocation / method sending and the implementation determines how the
state may be manipulated.

Here’s the key difference to me: Taking a message-orient POV, you do
not assume that messages == methods. You think in terms of how an
object does things internally, and then how it will handle messages.

In Java the assumption is that any message you send has to map to a
particular method. It does not encourage the same degree of
encapsulation and emphasis on behavior being distinct from
implementation.

In some ways it is similar to the difference in behavior-driven
development and test-driven development.

Point of view matters.


James B.

http://www.rubyaz.org - Hacking in the Desert
http://www.jamesbritt.com - Playing with Better Toys

On 23.05.2008 00:15, James B. wrote:

Here’s the key difference to me: Taking a message-orient POV, you do
not assume that messages == methods. You think in terms of how an
object does things internally, and then how it will handle messages.

I believe there is usage for both approaches - even within the same
project: usually I create classes from the outside, i.e. I decide about
their responsibilities, their interface and then I decide how they
should be implemented. In other cases, e.g. when implementing a
particular algorithm I probably will first think about the internals and
then decide which input or interface a class needs.

In both cases though clarifying responsibilities of a class (-> CRC
cards) is the first and most important step IMHO.

In Java the assumption is that any message you send has to map to a
particular method. It does not encourage the same degree of
encapsulation and emphasis on behavior being distinct from implementation.

I am not sure I get your point here. Looking at e.g. interfaces in
java.util what else is this than a separation of behavior (e.g. map
lookup) from the implementation (HashMap, TreeMap)?

In some ways it is similar to the difference in behavior-driven
development and test-driven development.

Point of view matters.

At least as a means for reasoning about how one does software
development and which alternative approaches are around.

Thank you for your input!

Kind regards

robert

On 22.05.2008 22:36, Rick DeNatale wrote:

This was one of the early books approaching OO design in the context
of Smalltalk, which introduced the computation by messages between
objects. It advocates a role-based approach rather than the
abstract-data type approach, corresponding to the C++ (and to a large
extent Java) view of OO.

Without wanting to start an indepth discussion about OO, but aren’t
these just two sides of the same medal? The message metaphor seems to
lean a bit more on the client side while the ADT view is a bit more
about how messages transform internal state (although ADT is mainly
about observable state through sequences of method invocations). In the
end, in both cases an instance holds state which is changed via method
invocation / method sending and the implementation determines how the
state may be manipulated.

Kind regards

robert

I wrote a series of articles in which Smalltalk and Ruby OOP are
compared which, perhaps, you may find of some interest. Here are the
links:

http://www.sapphiresteel.com/Ruby-The-Smalltalk-Way
http://www.sapphiresteel.com/Ruby-The-Smalltalk-Way-1
http://www.sapphiresteel.com/Ruby-The-Smalltalk-Way-2-A
http://www.sapphiresteel.com/Ruby-The-Smalltalk-Way-3-The-World

best wishes
Huw C.

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com

Mark W. wrote:

Using the late, lamented Dolphin Smalltalk. RIP. :frowning:

It’s not quite as dead as it seemed. At any rate, in August they
announced the end of development. Then in January, they announcded a new
beta: http://www.object-arts.com/content/news/x61beta1.html

I think Object Arts found it a struggle to make a living from Dolphin
Smalltalk which is why the developers were forced to take on other work.
But many existing Dolphin users were reluctant to let it go. Hence, its
‘second life’ (albeit, I suspect at a more laid-back rate of
development). It would be a great shame if Dolphin Smalltalk just faded
away. It’s a lovely product.

best wishes
Huw

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com