Ten Things Every Java Programmer Should Know About Ruby

K

Keith P. Boruff

Mark said:
I don't think people are claiming that Ruby programs
never need to be refactored but rather that since
they're less verbose refactoring is easier, so that
you don't need the same heavyweight refactoring tools
that languages like C++ and Java require

Actually, C++ is so verbose that to my knowledge, no one has been able to
successfully create an automated refactoring tool for it. If someone knows
otherwise and can provide a link, I'd appreciate it since I greatly need
one.

Refactoring is simply a process of changing the structure of your code
without changing the way it behaves. When you do any refactoring,
obviously, you have to do a regression test to make sure nothing has
changed. As I'm sure you know, when you change code, you introduce the
possibility of "bugging" your code.

Why does one refactor? Basically to improve the design and make it more
readable to humans. Tell me that you didn't write something in Ruby that
you later changed because you thought the change would produce a better
design. We all do it... we've all done it... in many languages. That's
refactoring.

Refactoring manually in any language can be a pain. It takes more time and
you can introduce bugs. An automated refactoring tool (a good one) helps to
alleviate those problems. For example, if you do an "extract method"
refactor manually, you have to make sure you capture all the outlying
variables that may be used in that new method. With an automated tool, you
just highlight the code, the method is created, the locals are deleted from
the old code, instered in the new, and that old code is replaced with a
call to your new method.

I think some of you here who are debating this issue with me are getting the
idea of refactoring wrong. Don't think of it as a means to deal with a
mechanism to deal with flawed programming languages but rather think of it
as a software engineering mechanism that transcends programming languages.

Would any of you guys seriously think about writing a big project without
using source code revision control? Would Matz have attempted writing the
Ruby interpreter without source code revision control? NO! This is a "best
practice" s/w engineering mechanism that is independent of PLs. That's all
I'm trying to say about refactoring.

Finally, to successfully use refactoring, you have to include your classes
in unit test harnesses to preserve behavior. Well, someone already wrote
this test harness into the Ruby libs so someone must have been thinking
about refactoring... for Ruby.

I don't care what programming language you use, if you're writing a big
program that many people had their hands on and have "hack-ins" from quick
deadline pressures, you're going to have decaying or decayed code.
Refactoring helps to minimize that decay.

KPB
 
A

Austin Ziegler

Well, in the case of C++, I'll agree. I have to deal with this
crap language (sometimes I like it)for a living and understand its
frustrations. Just the dependency issues along.... sigh. I think I
see where you're coming from.

But.... if you think Ruby is impervious to needing any refactoring
because it's less "verbose" than other languages, I would not
agree.

Which isn't what was said. So far, I have refactored thousands of
lines of Ruby code with simple cut-and-paste operations, not with
expensive, extensive tools.

-austin
 
K

Keith P. Boruff

Austin Ziegler wrote:

Which isn't what was said. So far, I have refactored thousands of
lines of Ruby code with simple cut-and-paste operations, not with
expensive, extensive tools.

I don't buy expensive tools either. I'm a linux guy so if I can't download
it, maybe build it, and use it without taking out the credit card, I don't
want it.

I probably spend more money on books about tools than I do the tools
themselves. For example, I bought the latest PDF file of the "Pixaxe".

KPB
 
J

James Britt

Keith said:
Mark Sparshatt wrote:




Actually, C++ is so verbose that to my knowledge, no one has been able to
successfully create an automated refactoring tool for it. If someone knows
otherwise and can provide a link, I'd appreciate it since I greatly need
one.

Refactoring is simply a process of changing the structure of your code
without changing the way it behaves. When you do any refactoring,
obviously, you have to do a regression test to make sure nothing has
changed. As I'm sure you know, when you change code, you introduce the
possibility of "bugging" your code.

Why does one refactor? Basically to improve the design and make it more
readable to humans. Tell me that you didn't write something in Ruby that
you later changed because you thought the change would produce a better
design. We all do it... we've all done it... in many languages. That's
refactoring.


I'm pretty sure most people participating in this thread know what
refactoring is, and have read, or at least are aware of, Fowler's book,
though they may not all have quite the same take on it, nor have the
same view on the topic.

I'd also venture to guess that most people view this thread as a
discussion, not a debate. At least, that's my preference. Debates have
a habit of spinning off into "I'm right, you're wrong" absolutism that
gets in the way of listening.



James
 
K

Keith P. Boruff

James Britt wrote:

I'm pretty sure most people participating in this thread know what
refactoring is, and have read, or at least are aware of, Fowler's book,
though they may not all have quite the same take on it, nor have the
same view on the topic.

Fowler's book was just an example. That's all.

I'd also venture to guess that most people view this thread as a
discussion, not a debate. At least, that's my preference. Debates have
a habit of spinning off into "I'm right, you're wrong" absolutism that
gets in the way of listening.

To me, debate and discussion mean the same thing. If you think I'm arguing,
I apologize. I'm just giving my views about this particular topic; that's
all.

I also wasn't trying to sound like a diehard advocate of *refactoring*. Like
all techniques, it has its good and bad points.

The only thing I am advocating is that refactoring and programming languages
are, for the most part, two mutually exclusive topics. I felt this
necessary because someone here stated that without bad programming
languages, refactoring is not needed.

KPB
 
G

Gavin Kistner

So go ahead and submit your ideas. What things should a Java
programmer
be aware of when starting out in Ruby?

An instance of a class can be extended to be subtly different, without
needing to subclass.
 
G

Gavin Kistner

So go ahead and submit your ideas. What things should a Java
programmer
be aware of when starting out in Ruby?

Since all access to the inside of an instance is through methods, you
can change your mind about whether .foo is a simple property or a
complex method call, without affecting the interface to your class.
Syntax sugar makes getter/setter methods indistinguishable from direct
property access.
 
G

Gavin Kistner

So go ahead and submit your ideas. What things should a Java
programmer
be aware of when starting out in Ruby?

HEREDOC strings with variable interpolation make large chunks of output
really easy to construct.
 
J

James Britt

Keith said:
James Britt wrote:
I also wasn't trying to sound like a diehard advocate of *refactoring*. Like
all techniques, it has its good and bad points.

To be sure, and I suspect people do refactoring without ever knowing it
has a name. I apologize if I painted you as a zealot or anything.
The only thing I am advocating is that refactoring and programming languages
are, for the most part, two mutually exclusive topics. I felt this
necessary because someone here stated that without bad programming
languages, refactoring is not needed.

I don't think that was anyone's intended statement. More that some
languages push you into circumstances where refactoring is both more
frequently required and harder to do.

James
 
D

Dick Davies

* Keith P. Boruff said:
Mark Sparshatt wrote:

Actually, C++ is so verbose that to my knowledge, no one has been able to
successfully create an automated refactoring tool for it. If someone knows
otherwise and can provide a link, I'd appreciate it since I greatly need
one.

Refactoring is simply a process of changing the structure of your code
without changing the way it behaves. When you do any refactoring,
obviously, you have to do a regression test to make sure nothing has
changed. As I'm sure you know, when you change code, you introduce the
possibility of "bugging" your code.

No ones' arguing against refactoring, i think you've got your wires crossed.

You're mistaking the absence of refactoring browsers as an indication that
rubyists don't like to refactor.

One of the big sellers of a dynamically-typed language is that it makes
refactoring extremely easy.

It's harder in statically typed languages (my main experience was in Java),
hence the buttload of refactoring tools.

'we don (desperately) need no steenkin refactoring *tools*' , the last
word being the important one....

Well, I'm sure they are handy, but I've never needed one in two years of ruby,
whereas I'd have been stuffed without them in Java.
 
T

Tom Ayerst

What I find odd about this discussion is that I remember the discussions
in the Smalltalk and Java newsgroups soon after Java hit the scene where
the Smalltalkers argued that the Smalltalk refactoring browser was an
invaluable development tool that would be hard/impossible to develop in
java due to the overcomplexity of its syntax.

What would you say is so much simpler/terser about Ruby than Smalltalk?

Personally I think every language would benefit from powerful and
reliable refactoring tools and have found them extremely beneficial in
managing large code bases. (fortunately various people in the Ruby
community agree and are developing them, so thats ok ;-) ).

Tom
 
K

Keith P. Boruff

Dick said:
No ones' arguing against refactoring, i think you've got your wires
crossed.

In all fairness, you should trace this thread to who I originally responded
to before making such a judgement.
 
K

Keith P. Boruff

Lothar said:
Hello Keith,


KPB> In all fairness, you should trace this thread to who I originally
responded KPB> to before making such a judgement.

I did. You responded to PA postings from 2005-01-28 18:21:47 PST.
You misunderstood it from the first posting on. It is quite clear that
this was a discussion about the "Tool" and nothing else

This is the statement I responded to:

*Interesting. Yet I get the feeling that such tools solve problems
largely brought on by the programming language in the first place, so
it's hard to see just what real gain such ease of use brings.*

"to solve problems largely brought on by the programming language" is what I
responded to. This statement an incorrect assumption as to why refactoring
(or its tools) exist.
 
A

Alexander Kellett

You're mistaking the absence of refactoring browsers as an indication
that
rubyists don't like to refactor.

there is actually a refactoring tool for ruby :)
not sure how well maintained it is. but it does exist,
ruvi supports it ;)

Alex
 
D

David A. Black

Hi --

Ugly for that case. Gorgeous for the #{myvar.upcase} case, I think.

Indeed. And the realization that Ruby's interpolation goes beyond
variables, and that the "extra" symbols aren't extra, is one of the
traditional rites of passage :)


David
 

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,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top