Refactoring in real life
Throwing stuff away
I spent some time last week writing a toy application that
exercises the Apple Rendezvous Java APIs. This particular example is a
tictactoe game. At one point I realized that most of the game logic
isn't needed for the final version as it will mainly be used in a book
I'm co-authoring with Rendezvous architect Stuart Cheshire. The code
that makes the example a better tictactoe game gets in the way of the
code that expresses what it is that Rendezvous is doing. So I ripped
The magic was that I could easily rip out six classes and a couple
hundred lines of code without fear that I'd ruined anything. I just
ran my unit tests again and moved on. With the bar still running
green, I had the confidence to delete the code that I had commented
out. Along the way I also moved some files around and found that
IntelliJ's Idea is a very smart tool. I moved a test class from one
package to another and IntelliJ moved the line that calls the test
class in the AllTests.java file of the first file to the correct line
in the corresponding file in the other.
Is it too much to ask for a tool that does that with my real life
items as well. I would love to be able to run a suite of tests and
know that I can safely delete these thirty
emails. Kimmy-the-wonderwife would love it if I had a tool that did
the same for books, magazines, and papers I have stacked all over our
Unit tests/ TDD is the life changing practice for me from all of
those proposed as part of XP. I'm working on how it might work in
cleaning up other areas of my life.
in Java Today Ashwin Jayaprakash knows he's sticking his neck
out to call his article href="http://www.onjava.com/pub/a/onjava/2004/12/22/towardsbugfree.html">Towards
Bug Free Code. But he's got some good practices to back it up -
J2SE 5.0-based tricks for achieving code that is more loosely-coupled,
and thus more readily testible. "If we make good use of some of the
basic idioms and thumb-rules of design and programming, we can take a
step closer towards software with a lot less bugs."
This article suggests that if your mission is to do the simplest
thing possible, then using mock objects in unit testing may not be
meeting these goals. In href="http://www.devx.com/Java/Article/22599"> Unit Test More
Efficiently with Mock Object Alternatives, he explains that his
pseudo object " is definitely not a mock object. There are no methods
defined above and beyond what is available on the interface. The
pseudo doesn't remember any object state or verify anything during or
after test execution; it simply throws an exception on any method
call. Now, this is not necessarily a stub, because it is not providing
any canned values that a test may use."
Steve Harris explains why he
started the Mnemos Project in today's href="http://weblogs.java.net/"> Weblogs. He asks " Have
you ever longed for a simple way to persist Java objects; something
along the lines of what Shelve/Pickle does for Python objects? Mnemos
may be just what you've been looking for."
James Gosling thinks about
href="http://today.java.net/jag/page13.html#106"> Sharpen the Axe: the
Dark Side . He worries that sometimes we can wander off and get
lost sharpening the axe and never return to the problem at hand.
Michael Nascimento Santos continues his discussion of AOP in
about Practical AOP and Transparent Remoting He is answering
questions about whether or not AOP makes applications more complex by
masking the complexity.
Forums, Bino George writes " href="http://forums.java.net/jive/thread.jspa?messageID=9338&tstart=0#9338">
AbsoluteLayout does more than just setting Layout to
null. AbsoluteLayout may even accomodate for changes in font sizes
etc. I know that the Swing team is working with the Netbeans team to
provide enhancements to the Swing layouts so that building Swing UIs
can be made easier and more intuitive.I have seen a demo of it and it
seems very intuitive, almost like a graphics tool. Layouts are one of
the most commonly complained about area because most
the exisiting layout managers complex and unintuitive."
Subnark raises issues of
Iterable not Iterator . "Under the current symantics only classes
which implement java.lang.Iterable may be used in a 'foreach'
statement. Since all this interface requires is to return an Iterator,
it would be nice if there was a special case for Iterator. I find that
I end up with an iterator and not an Iterable often since I use legacy
code that does not implement this interface, or I'm using a class
which can be iterated in multiple ways."
Also featured in Projects
and Communities, Kathy Walrath has pointed out on the href="http://community.java.net/javadesktop/">Java Desktop
community homepage that four JavaDesktop projects are #1 in the five
categories measured. Congrats to lg3d and xhtmlrenderer.
The Global Education and
Learning community features href="https://docclerk.dev.java.net/">docclerc, an application
with Tapestry, Spring, and Hibernate that is a coordinated publish and
edit document system and automatic version control.
In today's java.net
- Eclipse 3.1,
- Lucene in
Action Website Launch
- NailGun 0.7
- JoSQL 0.5
01.03.05 - Java IRC Client
Registered users can submit news items for the
href="http://today.java.net/today/news/">java.net News Page using
our news submission
form. All submissions go through an editorial review before being
posted to the site. You can also subscribe to the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net News
Archives and Subscriptions: This blog is delivered
weekdays as the href="http://today.java.net/pub/q/java_today_rss?x-ver=1.0">Java
Today RSS feed. Also, once this page is no longer featured
as the front page of java.net
it will be archived along with other past issues in the href="http://today.java.net/today/archive/">java.net
Throwing stuff away