OO style tutorials?

P

Paul Archer

I'm pretty new to Ruby, and while I've read (and mostly get) several books
on Ruby, I'm having trouble with one thing: Object Oriented programming.
Don't get me wrong, I get the concepts of OO. I can construct objects and
classes. The mechanics of it don't phase me.

I'm good with the how, I'm just a little fuzzy on the how much. To put it
in more concrete terms: I'm writing (or, rather, I want to write) a script
that takes incoming digital images from my camera and renames them and
puts them in a directory structure based on their date. Now, I have a
background in scripting (Bourne shell and Perl), and can see doing this in
a purely procedural way. But I'm not sure about how to do it in an OO way.
Do I represent each image as an object? What attributes should the objects
have?

So the question is: Are there any tutorials or resources that go more into
the appropriate use of OO programming, strategies for structuring classes,
rather than the nuts and bolts of creating objects and such?

Paul Archer
 
I

Ian Trudel

Paul said:
I'm pretty new to Ruby, and while I've read (and mostly get) several
books
on Ruby, I'm having trouble with one thing: Object Oriented programming.
Don't get me wrong, I get the concepts of OO. I can construct objects
and
classes. The mechanics of it don't phase me.
So the question is: Are there any tutorials or resources that go more
into
the appropriate use of OO programming, strategies for structuring
classes,
rather than the nuts and bolts of creating objects and such?

Paul Archer

Hello Paul,

Your problem seems to be obvious. It is hardly possible to grasp such
concepts without proper training. Your project feels like a good way to
get going. Why don't you just dig in by yourself and come back with more
questions? Experiment by yourself. Truthfully, if you have read several
books already, the last thing you need is yet-another-something-to-read.

Ah. The heck. Have you read yet http://www.ruby-doc.org/ ? Click on the
link "An on-line copy of the first edition of the book Programming Ruby,
by Dave Thomas."; it's a good starter.

Regards,
Ian.
 
P

Phlip

Paul said:
I'm pretty new to Ruby, and while I've read (and mostly get) several books
on Ruby, I'm having trouble with one thing: Object Oriented programming.
Don't get me wrong, I get the concepts of OO. I can construct objects and
classes. The mechanics of it don't phase me.

That is "object based" programming. OO is about virtual dispatch of methods at
object boundaries.
I'm good with the how, I'm just a little fuzzy on the how much. To put it
in more concrete terms: I'm writing (or, rather, I want to write) a script
that takes incoming digital images from my camera and renames them and
puts them in a directory structure based on their date. Now, I have a
background in scripting (Bourne shell and Perl), and can see doing this in
a purely procedural way. But I'm not sure about how to do it in an OO way.
Do I represent each image as an object? What attributes should the objects
have?

Read the books /Test-Driven Development/, /Refactoring/, and /Design Patterns/.

Then write whatever works. When you refactor it, try to DRY the code up -
meaning Don't Repeat Yourself.

The fewer lines of code your program has, the more likely your objects have
merged their common behaviors into base classes, and their specific behaviors
into derived classes.

The second link on my website, TDD, shows a long list of my various tutorials on
OO design and implementation. I generally try to show the thought process that
leads to emergent designs.
 
Y

Yun Huang Yong

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

So the question is: Are there any tutorials or resources that go
more into the appropriate use of OO programming, strategies for
structuring classes, rather than the nuts and bolts of creating
objects and such?

My first encounter with OO programming was with Java, and I found the
Sun Java tutorial quite handy for explaining the basic ideas:
http://java.sun.com/docs/books/tutorial/java/concepts/index.html

I should also declare that I'm a pretty lousy programmer, and
throughout Uni I had difficulty understanding the need for UML[1],
CRC[2], Design Patterns and various other OO design jargon. But
after 8 odd years working in the commercial world they began to find
their place in my world. The understanding I came to is that there
isn't a perfect tutorial for everyone because it depends a lot on
your experience. Stuff that made no sense to me 8 years ago (and
indeed seemed overwhelmingly complicated) makes perfect sense today.

That said I quite like CRC as a simple tool to help you think along
the right lines.

I suspect beyond that you probably want a good UML or Design Patterns
book. I don't have any recommendations but hopefully someone else on
this thread will. :)

yun

[1] http://en.wikipedia.org/wiki/Unified_Modeling_Language
[2] http://www.agilemodeling.com/artifacts/crcModel.htm





--
(__) Share what you know.
Yun Huang Yong `\------(oo) Learn what you don't.
(e-mail address removed) || (__) --'
(e-mail address removed) \|/ ||w--|| \|/
--
 
U

usw wickramasinghe

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

Hi Paul,
I too agree with Ian. Obvious reason might be lack of experience in these OO
design concepts . OO is not about creating classes and objects but how you
apply it in real world scenarios efficiently. In my personal opinion i do
not recommend you to use a Ruby Language book as a gateway for grasping OO
,coz it might be more concentrating on Ruby rather than OO. I prefer , you
use a good introductory book such as 'Head First Object-Oriented Analysis
and Design' which would give you a great understanding to polish off your OO
concepts..

Regards
Udayanga
 
S

Saji N. Hameed

* Paul Archer said:
So the question is: Are there any tutorials or resources that go more
into the appropriate use of OO programming, strategies for structuring
classes, rather than the nuts and bolts of creating objects and such?

Design Patterns in Ruby by Russ Olsen is what I would recommend reading

http://www.amazon.com/Design-Patterns-Ruby-Addison-Wesley-Professional/dp/0321490452

saji
--
Saji N. Hameed

APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 (e-mail address removed)
KOREA
 
R

Robert Klemme

I should also declare that I'm a pretty lousy programmer, and
throughout Uni I had difficulty understanding the need for UML[1],
CRC[2], Design Patterns and various other OO design jargon. But
after 8 odd years working in the commercial world they began to find
their place in my world. The understanding I came to is that there
isn't a perfect tutorial for everyone because it depends a lot on
your experience. Stuff that made no sense to me 8 years ago (and
indeed seemed overwhelmingly complicated) makes perfect sense today.

Took me some time, too. My first OO program was horrible and I believe
it took at least a year until I managed to grasp it - at least half way.
That said I quite like CRC as a simple tool to help you think along
the right lines.

I also believe that CRC is a good tool because it is quite simple and
keeps you focused on important points. I'd say though that it still
takes a bit more to craft a good OO application. But CRC is very useful
as it will also help to not lump too much functionality into a single class.
I suspect beyond that you probably want a good UML or Design Patterns
book. I don't have any recommendations but hopefully someone else on
this thread will. :)

I always recommend "Object Oriented Software Construction" by Bertrand
Meyer. It is not exactly a tutorial but rather an encyclopedia where
you can look up whatever OO term you encounter somewhere else. Meyer
really has a profound understanding of all the different aspects of OO
and ways in which it can be used.

http://archive.eiffel.com/doc/oosc/page.html

Kind regards

robert
 
R

Rick DeNatale

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

Design Patterns in Ruby by Russ Olsen is what I would recommend reading


http://www.amazon.com/Design-Patterns-Ruby-Addison-Wesley-Professional/dp/0321490452
I'll give that a hearty second. Russ does a very good job of teaching OO
design from a Ruby perspective.


I strongly believe that although there might be a few universal truths, most
good OO design needs to take the characteristics of the language into
account. If you learn OO from a Java tutorial, you're going to speak Ruby
with a Java accent. Object Oriented Software Construction will leave you
with an Eiffel accent. The Gang of Four Design Patterns book, although it
purports to be "language neutral" at least for the popular OO languages back
in 1995, is strongly influenced by C++.

Russ' book is noteworthy because, although it's inspired by the GOF book, it
points out how the choice of language is a real factor in the choice and
expression of design pattern languages.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
P

Paul Archer

Thanks very much to all that responded. I'm frankly a bit overwhelmed by
both the quantity and quality of responses. I feel a bit like the singer
in The Police's "Message In A Bottle": "Woke up this morning/don't believe
what I saw/Hundred million bottles washed up on my shore."

@Ian: You're probably right, I need to dig in and get started. It's not
that I'm a perfectionist, exactly--but I have this "I've got to do it
right the first time" mentality that I need to get past.

@Phlip: I guess thinking of it as refactoring, rather than just "redoing
my poor first attempt", that'll help. (See above about wanting to do it
right the first time.) And thanks for pointing me to your website.

@Yun: What's CRC?

@Udayanga: thanks, I'll check out the "Head First" book.

@Saji & Rick: And the "Design Patterns" book, too.

@Robert: The OO Encyclopedia looks like a good reference. (Might even find
out what CRC is. :cool:

@Paul: So get to work.

thanks, all!

Paul
 
L

Leo

The GoF book has strong influences from Smalltalk and Java. =A0C++ OO is =
a
completely different beast.

He probably assumed a strong c++ influence because many/most examples
are in c++. IIRC (but I could be wrong of course) the book (1994)
doesn't mention Java (1996).
 
I

Ian Trudel

Paul said:
@Ian: You're probably right, I need to dig in and get started. It's not
that I'm a perfectionist, exactly--but I have this "I've got to do it
right the first time" mentality that I need to get past.

I do understand your point. And it's not a bad thing at all. You should
however just keep in mind to balance passive and active learning. It's
also a great opportunity to write few lines of code and then go back to
your books, and repeat the process. It's a good way to bind practical
and theoretical knowledge together. It will lit light bulbs in your head
while helping you to better grasp other concepts, that you're currently
reading on. This process will also allow you to focus on weaker areas
(theoretical or practical), which you understand more or less. Isn't it
a wonderful way to learn? :)

@Yun: What's CRC?

http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card



Well, keep us posted.

Ian.
 
R

Robert Klemme

2009/3/8 Rick DeNatale said:
Object Oriented Software Construction will leave you
with an Eiffel accent.

I would not necessarily say so. It just happens that Eiffel is the
language which has the richest zoo of inheritance options (including
private inheritance, i.e. without maintaining "is a" relationship)
that I know. And Bertrand Meyer not only presents concepts but
verbosely explains them. So I'd say you can understand them
independent of language. It may be though that you benefit most from
this book if you have some OO background already.

Kind regards

robert
 
R

Rick DeNatale

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

He probably assumed a strong c++ influence because many/most examples
are in c++. IIRC (but I could be wrong of course) the book (1994)
doesn't mention Java (1996).

No, I didn't assume, I knew because I know all four authors (or knew, since
John V. is no longer with us). And there's not nearly as much Smalltalk
influence as there should be, Ralph Johnson admitted as much when he
autographed my copy.

As for not using things like templates etc. in C++, I don't know whether or
not those features were commonly available if at all when the book was
written.


--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
S

Simon Krahnke

* Paul Archer said:
I'm good with the how, I'm just a little fuzzy on the how much. To put it
in more concrete terms: I'm writing (or, rather, I want to write) a script
that takes incoming digital images from my camera

That's a file, right?
and renames them an puts them in a directory structure based on their
date. Now, I have a background in scripting (Bourne shell and Perl),
and can see doing this in a purely procedural way.

I don't see a reason to do it any other way. One might create some OOP
concepts for doing that, but that would be more code than the simple
loop of the "procedural" way.

It's a too simple task for learning OOP. Just use objects when you see
the need for it.

mfg, simon .... l
 

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,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top