Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 26th, 2007, 08:13 PM
stevephp stevephp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 13 stevephp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 25 sec
Reputation Power: 0
Straight into OO ?

Hi all,
I"d like to start learning just Ruby without the Rails for now, by converting some of my DOS batch scripts into Ruby scripts. I"ve got batch files that do everything from, commit some files to my SVN repos, to copying some files to a particular destination, to switching directories via a menu with choices.

I'm wondering if it would be worth it to immediately start using the OO features in Ruby and actually write objects that I could reuse in some way or another. Like maybe a base class that takes care of basic copying, and then unzipping at the destination.

And then I can inherit from that, but specify with the subclasses, what directories to copy to?

Or is that not a good idea.. and maybe I should just focus on learning syntax and other stuff and just write ruby procedural scripts for now.

Reply With Quote
  #2  
Old August 26th, 2007, 09:11 PM
Oler1s Oler1s is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2006
Posts: 1,461 Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 4 Weeks 7 h 10 m 20 sec
Reputation Power: 425
I never thought of OO as primarily a coding issue. It's really about design. So learning OO syntax means absolutely nothing about whether you can use OO properly. This is akin to seeing the technical description of a hammer (the handle is x inches long, the hammer head is made of x composite material with y added in, shaped like so and so), and seeing the fact that a hammer is used to pound something, preferably on a nail and not your thumb.

If you have experience with OO design, sure go ahead and learn OO syntax. That really isn't all that hard to do. Whether it's OO in Java, Ruby, PHP, Python, C++, C#, you're looking to apply the same concepts and just need to figure out the syntax variations.

But based on your question, I figure that you are relatively a new programmer. And you might be jumping on to the OO thing because it's a commonly cited buzzword. You'll use OO syntax and all, but that doesn't mean your design may be any good. OO syntax does not make your code any better.

If you have a bunch of scripts, writing equivalently procedural code may the best translation. Is there a point to writing those objects? Maybe there is. Maybe there isn't. But it has nothing to do with whether you are new to Ruby. It's a code design question. If you are unable to see intuitively that your code could use an OO paradigm, then don't stretch and make up ways to use an OO syntax feature. Are you creating a number of base classes and so on for the sake of accomodating a design, or are you creating a design that tries to make use of all those features? The second is a sure sign of bad code.
Comments on this post
Yawmark agrees!
Joseph Taylor agrees: Excellent response. Made me laugh, too.
__________________
C/C++: Books, C FAQ, C++ FAQ, C/C++ Reference.
Python: Website, Beautiful Soup.

Reply With Quote
  #3  
Old August 26th, 2007, 09:43 PM
stevephp stevephp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 13 stevephp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 25 sec
Reputation Power: 0
Wow, you're very intense

I really don't take my batch scripts that seriously, .. this was just a casual question asked in a casual mood on a sunday eve. but thanks. Have a beer though, would ya.

Reply With Quote
  #4  
Old August 27th, 2007, 07:39 AM
L7Sqr L7Sqr is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: Constant Limbo
Posts: 577 L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 49 m 8 sec
Reputation Power: 67
Send a message via AIM to L7Sqr
Careful. You got good advise for free. Remember that in the future you may need to get another, less trivial, question answered. If you tell people that you dont like the way they inform you, you are likely to get nothing when you need it.
Comments on this post
Yawmark agrees!
__________________
-- I'll provide you with reference points; if they dont work, refer to something else.

If you process text, this might make your life a little easier.

Reply With Quote
  #5  
Old March 17th, 2008, 04:23 PM
JeffCT JeffCT is offline
PHP & Ruby Developer
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2001
Posts: 1,437 JeffCT User rank is Lance Corporal (50 - 100 Reputation Level)JeffCT User rank is Lance Corporal (50 - 100 Reputation Level)JeffCT User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 5 h 36 m 40 sec
Reputation Power: 9
You're already using the OO features of Ruby. Everything in Ruby is an object. If you mean the advanced features, like blocks, or actually writing your own classes - why not? No reason to continue using it like a functional language when it has that kind of power.

Reply With Quote
  #6  
Old March 17th, 2008, 07:29 PM
stevephp stevephp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 13 stevephp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 25 sec
Reputation Power: 0
Thanks Jeff. Appreciate the reply. Makes sense.

Quote:
Originally Posted by JeffCT
You're already using the OO features of Ruby. Everything in Ruby is an object. If you mean the advanced features, like blocks, or actually writing your own classes - why not? No reason to continue using it like a functional language when it has that kind of power.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Straight into OO ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway