Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #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: 15 stevephp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 53 m 11 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 Regular (2000 - 2499 posts)
 
Join Date: Jul 2006
Posts: 2,270 Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 15 h 34 m 57 sec
Reputation Power: 1735
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.
__________________
When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
Want better answers? Tell us what you Googled for and what steps you took to answer your own question.

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: 15 stevephp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 53 m 11 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: 989 L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level)L7Sqr User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 22 h 45 m 6 sec
Reputation Power: 362
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!
__________________
True happiness is not getting what you want, it's wanting what you've already got.

My Blog

Reply With Quote
  #5  
Old March 17th, 2008, 04:23 PM
JeffCT JeffCT is offline
Dev
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2001
Posts: 1,436 JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 h 52 m 59 sec
Reputation Power: 40
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: 15 stevephp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 53 m 11 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 ?

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap