OOP in Ruby?

P

Phillip Gawlowski

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

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

Err, about everything, I guess. ;P

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

- --
Phillip Gawlowski
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-----
 
S

Sam Rudd

[Note: parts of this message were removed to make it a legal post.]

Can you be more specific?
 
M

Mark Wilden

I suspect the O'Reilly book The
Ruby Programming 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
 
L

Lyle Johnson

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.
 
J

James Britt

aidy said:
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.)
 
D

Dave Bass

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?
 
T

Tim Hunter

Lyle said:
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.
 
D

Dave Thomas

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
 
M

Mark Wilden

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 wonder if most people are like you and me: bought it as soon as it
came out, but haven't read it yet. :)

///ark
 
M

Marc Heiler

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

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. ;)

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)
 
L

Lyle Johnson

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

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.
 
R

Rick DeNatale

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.
 
R

Rick DeNatale

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.
 
R

Robert Klemme

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
 
J

James Britt

Robert said:
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.

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.
 
R

Robert Klemme

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
 
H

Huw Collingbourne

H

Huw Collingbourne

Mark said:
Using the late, lamented Dolphin Smalltalk. RIP. :(

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
 

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

Similar Threads

OOP Through Animations and Dogs 0
General Ruby OOP question 4
How do I solidify my Python skills 1
ruby graphs and hudson 1
Any project ideas for landing a job ? 3
TDD with Ruby 2
OOP only in modules 3
oop 0

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top