PDA

View Full Version : Newby question - how to know when code can be removed


Info
07-18-2003, 12:01 PM
So, I'm learning TDD inch by inch starting with the challenge at
http://xp123.com/xplor/xp0201. Surprisingly, I got a little way into the second
section before I ever had reason to add a Cell class. So first, I started
adding a skeleton of a Cell class, then remembered - oh yeah, I'm supposed to be
learning TDD. So I mercilessly delete the code I just started writing and start
writing the first test for the new class, compile, see that compile fails, add
the class, see that the compile succeeds, and the test passes (the first test
was so simple, there was no reason additional code would be needed to make it
pass).

So after that, I'm thinking that if it took so long for me to need a Cell class
in the first place, what if a future refactoring makes it unnecessary again?
Now, I have tests that exist for the sole purpose of making sure the Cell class
exists and does certain things. If I ever remove the Cell class, my tests will
fail. Technically, at that point, the tests could and should simply be removed,
but there is nothing to tell me at this hypothetical later time that this is OK.

I guess my question is - how to you arrange things so that you know that certain
code sections are only required to support higher level sections and that
certain tests are only required so long as the code section they are testing is
also required?

Thanks,

- Steve Jorgensen

Uncle Bob (Robert C. Martin)
07-20-2003, 11:45 AM
Steve Jorgensen <nospam@nospam.nospam> might (or might not) have
written this on (or about) Fri, 18 Jul 2003 20:01:59 GMT, :
So, I'm learning TDD inch by inch starting with the challenge athttp://xp123.com/xplor/xp0201. Surprisingly, I got a little way into the secondsection before I ever had reason to add a Cell class. So first, I startedadding a skeleton of a Cell class, then remembered - oh yeah, I'm supposed to belearning TDD. So I mercilessly delete the code I just started writing and startwriting the first test for the new class, compile, see that compile fails, addthe class, see that the compile succeeds, and the test passes (the first testwas so simple, there was no reason additional code would be needed to make itpass).So after that, I'm thinking that if it took so long for me to need a Cell classin the first place, what if a future refactoring makes it unnecessary again?Now, I have tests that exist for the sole purpose of making sure the Cell classexists and does certain things. If I ever remove the Cell class, my tests willfail. Technically, at that point, the tests could and should simply be removed,but there is nothing to tell me at this hypothetical later time that this is OK.I guess my question is - how to you arrange things so that you know that certaincode sections are only required to support higher level sections and thatcertain tests are only required so long as the code section they are testing isalso required?

I like to organize unit tests by class and package. Each test has its
own TestCase with lots of test methods in it. Each package has its
own TestSuite within that package.

Whenever a method of a class becomes unnecessary I remove the test
methods that test it. Whenever a whole class becomes unnecessary I
remove corresponding Test case class. Whenever a whole package
becomes unnecessary I remove the corresponding TestSuite.


Robert C. Martin | "Uncle Bob"
Object Mentor Inc.| unclebob @ objectmentor . com
PO Box 5757 | Tel: (800) 338-6716
565 Lakeview Pkwy | Fax: (847) 573-1658 | www.objectmentor.com
Suite 135 | | www.XProgramming.com
Vernon Hills, IL, | Training and Mentoring | www.junit.org
60061 | OO, XP, Java, C++, Python |

Shane Mingins
07-20-2003, 12:52 PM
Hey Steve ...

This is not really related to your question ---

I am not sure if you are working in Java or not ...but if u are and u have
not yet come across http://www.intellij.com/idea/ , have a look.

It is the rolls royce of Java IDE's for Refactoring (and those words came
from our local Borland representative *grin*).

Cheers
Shane

--
shanemingins@yahoo.com.clothes

remove clothes before replying

"What are you famous for?" she asked.
"I am simply famous," he replied.

"Steve Jorgensen" <nospam@nospam.nospam> wrote in message
news:fkkghv0h8vp2h586p9a0ta89gmfne4fnlq@4ax.com... So, I'm learning TDD inch by inch starting with the challenge at http://xp123.com/xplor/xp0201. Surprisingly, I got a little way into the
second section before I ever had reason to add a Cell class. So first, I started adding a skeleton of a Cell class, then remembered - oh yeah, I'm supposed
to be learning TDD. So I mercilessly delete the code I just started writing and
start writing the first test for the new class, compile, see that compile fails,
add the class, see that the compile succeeds, and the test passes (the first
test was so simple, there was no reason additional code would be needed to make
it pass). So after that, I'm thinking that if it took so long for me to need a Cell
class in the first place, what if a future refactoring makes it unnecessary
again? Now, I have tests that exist for the sole purpose of making sure the Cell
class exists and does certain things. If I ever remove the Cell class, my tests
will fail. Technically, at that point, the tests could and should simply be
removed, but there is nothing to tell me at this hypothetical later time that this
is OK. I guess my question is - how to you arrange things so that you know that
certain code sections are only required to support higher level sections and that certain tests are only required so long as the code section they are
testing is also required? Thanks, - Steve Jorgensen

Info
07-20-2003, 01:15 PM
On Mon, 21 Jul 2003 08:52:36 +1200, "Shane Mingins"
<shanemingins@yahoo.com.clothes> wrote:
Hey Steve ...This is not really related to your question ---I am not sure if you are working in Java or not ...but if u are and u havenot yet come across http://www.intellij.com/idea/ , have a look.It is the rolls royce of Java IDE's for Refactoring (and those words camefrom our local Borland representative *grin*).CheersShane

Ward posted a message recently saying that Eclipse was nice and free, and
Intellij was better, but not free. How much more does Intellij provide than
Eclipse with regard to refactoring? Is it Rolls Royce vs Subaru or Rolls Royce
vs bicycle?

Thanks,

- Steve J.

Info
07-20-2003, 01:33 PM
On Sun, 20 Jul 2003 14:45:29 -0500, "Uncle Bob (Robert C. Martin)"
<u.n.c.l.e.b.o.b@objectmentor.com> wrote:
Steve Jorgensen <nospam@nospam.nospam> might (or might not) havewritten this on (or about) Fri, 18 Jul 2003 20:01:59 GMT, :So, I'm learning TDD inch by inch starting with the challenge athttp://xp123.com/xplor/xp0201. Surprisingly, I got a little way into the secondsection before I ever had reason to add a Cell class. So first, I startedadding a skeleton of a Cell class, then remembered - oh yeah, I'm supposed to belearning TDD. So I mercilessly delete the code I just started writing and startwriting the first test for the new class, compile, see that compile fails, addthe class, see that the compile succeeds, and the test passes (the first testwas so simple, there was no reason additional code would be needed to make itpass).So after that, I'm thinking that if it took so long for me to need a Cell classin the first place, what if a future refactoring makes it unnecessary again?Now, I have tests that exist for the sole purpose of making sure the Cell classexists and does certain things. If I ever remove the Cell class, my tests willfail. Technically, at that point, the tests could and should simply be removed,but there is nothing to tell me at this hypothetical later time that this is OK.I guess my question is - how to you arrange things so that you know that certaincode sections are only required to support higher level sections and thatcertain tests are only required so long as the code section they are testing isalso required?I like to organize unit tests by class and package. Each test has itsown TestCase with lots of test methods in it. Each package has itsown TestSuite within that package.Whenever a method of a class becomes unnecessary I remove the testmethods that test it. Whenever a whole class becomes unnecessary Iremove corresponding Test case class. Whenever a whole packagebecomes unnecessary I remove the corresponding TestSuite.

Thanks, that gets me pointed in the right direction. Obviously, I still have
much to learn about keeping code well organized, though.

Shane Mingins
07-20-2003, 01:51 PM
I guess you'd have to try and compare. I met a colleague who just said "get
this, it's cool" and so I did :-) I have not tried Eclipse ... I have seen
a lot of people posting good things about it. Ward has probably used them
both and his comment seems to be the general agreement that I have seen. My
guess is that it would *not* be Rolls Royce vs Bicycle *grin*.

I was using JBuilder 6 ... (IMO it was Rolls Royce vs Bicycle) and the very
kind people at JetBrains gave me a 6 month evaluation licence in which time
I think I can convince my boss to buy me a copy (just hope that the NZD
gains on that USD!).

Cheers
Shane
--
shanemingins@yahoo.com.clothes
remove clothes before replying

"Steve Jorgensen" <nospam@nospam.nospam> wrote in message
news:p52mhv0oahsiqsbs7m2uti6tdoi01oajd5@4ax.com... On Mon, 21 Jul 2003 08:52:36 +1200, "Shane Mingins" <shanemingins@yahoo.com.clothes> wrote:Hey Steve ...This is not really related to your question ---I am not sure if you are working in Java or not ...but if u are and u
havenot yet come across http://www.intellij.com/idea/ , have a look.It is the rolls royce of Java IDE's for Refactoring (and those words camefrom our local Borland representative *grin*).CheersShane Ward posted a message recently saying that Eclipse was nice and free, and Intellij was better, but not free. How much more does Intellij provide
than Eclipse with regard to refactoring? Is it Rolls Royce vs Subaru or Rolls
Royce vs bicycle? Thanks, - Steve J.

Uncle Bob (Robert C. Martin)
07-20-2003, 05:34 PM
"Shane Mingins" <shanemingins@yahoo.com.clothes> might (or might not)
have written this on (or about) Mon, 21 Jul 2003 09:51:10 +1200, :
I guess you'd have to try and compare. I met a colleague who just said "getthis, it's cool" and so I did :-) I have not tried Eclipse ... I have seena lot of people posting good things about it. Ward has probably used themboth and his comment seems to be the general agreement that I have seen. Myguess is that it would *not* be Rolls Royce vs Bicycle *grin*.I was using JBuilder 6 ... (IMO it was Rolls Royce vs Bicycle) and the verykind people at JetBrains gave me a 6 month evaluation licence in which timeI think I can convince my boss to buy me a copy (just hope that the NZDgains on that USD!).

I haven't used Eclipse, yet. But I know a lot of folks who've used
both and who agree with Ward. Eclipse is pretty good, but IntelliJ is
better.

As for me, I can't imagine programming without something like
IntelliJ. Even EMACS would be like going back to "stone knives and
bear skins". The difference is remarkable and very very addictive.
Robert C. Martin | "Uncle Bob"
Object Mentor Inc.| unclebob @ objectmentor . com
PO Box 5757 | Tel: (800) 338-6716
565 Lakeview Pkwy | Fax: (847) 573-1658 | www.objectmentor.com
Suite 135 | | www.XProgramming.com
Vernon Hills, IL, | Training and Mentoring | www.junit.org
60061 | OO, XP, Java, C++, Python |

Info
07-20-2003, 07:00 PM
On Mon, 21 Jul 2003 09:51:10 +1200, "Shane Mingins"
<shanemingins@yahoo.com.clothes> wrote:
I guess you'd have to try and compare. I met a colleague who just said "getthis, it's cool" and so I did :-) I have not tried Eclipse ... I have seena lot of people posting good things about it. Ward has probably used themboth and his comment seems to be the general agreement that I have seen. Myguess is that it would *not* be Rolls Royce vs Bicycle *grin*.I was using JBuilder 6 ... (IMO it was Rolls Royce vs Bicycle) and the verykind people at JetBrains gave me a 6 month evaluation licence in which timeI think I can convince my boss to buy me a copy (just hope that the NZDgains on that USD!).CheersShane

Well, now I'm not sure I made the quesiton clear. Ward's comments on these IDEs
was just regarding their respective qualities as Java IDEs without any specific
reference to refactoring (though that may have been high in his mental list of
criteria). I'm certain Eclipse sould not be a bicycle as an IDE, but here I was
specifically wondering about facilities for refactoring since it was mentioned
here that Intellij was great for refactoring.

Thanks,

- Steve J

Shane Mingins
07-20-2003, 08:07 PM
My comments were in regards to Refactoring. But at the same time from what
I have read in many *best* IDE postings (just do a google search) it does
seem that the comment "Eclipse is pretty good, but IntelliJ is better."
could hold true for general IDE comparison.

But remember .. I have not used Eclipse ... sounds like you do, so why not
download a copy of IDEA and try it out. I think it's just great to program
with but that is just my opinion, you can make your own mind up. Let us
know which you prefer.

Cheers
Shane
--
shanemingins@yahoo.com.clothes

remove clothes before replying

"Steve Jorgensen" <nospam@nospam.nospam> wrote in message
news:lbmmhvc4l8oik4ovvo7foj547b98caeaft@4ax.com... On Mon, 21 Jul 2003 09:51:10 +1200, "Shane Mingins" <shanemingins@yahoo.com.clothes> wrote:I guess you'd have to try and compare. I met a colleague who just said
"getthis, it's cool" and so I did :-) I have not tried Eclipse ... I have
seena lot of people posting good things about it. Ward has probably used
themboth and his comment seems to be the general agreement that I have seen.
Myguess is that it would *not* be Rolls Royce vs Bicycle *grin*.I was using JBuilder 6 ... (IMO it was Rolls Royce vs Bicycle) and the
verykind people at JetBrains gave me a 6 month evaluation licence in which
timeI think I can convince my boss to buy me a copy (just hope that the NZDgains on that USD!).CheersShane Well, now I'm not sure I made the quesiton clear. Ward's comments on
these IDEs was just regarding their respective qualities as Java IDEs without any
specific reference to refactoring (though that may have been high in his mental
list of criteria). I'm certain Eclipse sould not be a bicycle as an IDE, but here
I was specifically wondering about facilities for refactoring since it was
mentioned here that Intellij was great for refactoring. Thanks, - Steve J


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service