Skip to main content

The Testing Bug

Posted by daniel on January 23, 2004 at 8:03 AM PST

You may be tired of hearing about test-driven development, but have you tried it yet?

In his java.net featured article , Mike Clark provides A Dozen Ways to Get the Testing Bug in the New Year . His first two steps are for those of you already doing testing in your own way. If you are using main() methods and println calls or if you are tracing the value of variables using the debugger, he suggests automating your process with a framework such as JUnit.

Once you master the mechanics of automating your tests, you can start to take advantage of testing first. "Before you write a method, you generally have some idea what the method should do. [..] The test then keeps you from wandering down rabbit holes and lets you know when you're done coding. So, before writing that next method, stop to consider what expectations you already have in mind. [..] Think of test-driven development as a way of structuring and refining that thought process."

This view of the advantages of writing tests first leads into Mike's next point. In many ways, testing first is less about testing and more about design. Mike explains "Writing tests first is a design activity because it forces you to think through how the code should work from the outside before diving into an implementation. In good time and with practice, you'll notice test-driven development is more of a design technique than a testing technique."

As an aside, when you read Mike's article, you may also notice a couple of recent changes to our article template. Recently we added the graphic to the top of the article page, and with this article we add a table of contents to the top of the first page.


In
Also in Java Today
we link to Erb Cooper's blog entry What's the deal with Delegates? I've recently been using delegates in Objective-C/Cocoa applications while Erb has been looking at C#. He writes that when you use delegation, you "effectively, have one method per callback interface. This would be as if, for MouseListener, we instead had MousePressedListener, MouseReleasedListener, etc. We would then say button.addMousePressedListener(this) or something to that effect. This saves us from the old dilemma: Do I add an inner class that extends MouseAdapter , or do I implement MouseListener with a bunch of empty callback methods? Frankly I see nothing wrong with using an inner class, since I like avoiding exposing the public callback method because it allows it to be called in cases other than event notification. C# people, however, seem to want to do the method hiding without the inner class. "

The JDJ article Deutsch's Fallacies, 10 Years After takes a look back at the origins of each of the eight items on what is known as Peter Deutsch's eight fallacies of networked computing. The first four, "the network is reliable; latency is zero; bandwidth is infinite; and the network is secure" were codified by James Gosling. Deutsch added the next three, "that there's a single administrator and that the topology won't change." Number seven, that transport cost is zero," after watching the issues that arose in a move of Sun's offices. Finally, Gosling added the eighth fallacy "the network is homogeneous" in 1997.


In today's Weblogs , Felipe Leme writes that a J2EE plug-in for Eclipse called Lomboz has become open source. Felipe writes that this "is great news for the Eclipse and Open Source communities."

In How to style a simple block menu in HTML using CSS, Satya Komatineni writes that "Recently I wanted to create a block menu in my html pages. I want this block menu to have a header indicating the category of the menu and a set of menu items. There may be more than one way of doing this exercise. There may also be a better way of doing the same. But here is how I have done it and it seem to work well for now."

Richard Monson-Haefel updates his blog entry Open Source Developer: Will Work for Food! to clarify his position in light of the many responses. He writes, "Open source works because it gives developers freedom of choice and expression. Developers get to choose which projects they work on and therefore the direction of their own technical growth. Developers get to choose what to contribute and how much. It's about freedom of choice."


In Projects and Communities The Java Games home page now spotlights JSimBionic , "a powerful AI middleware tool for Java games that helps you define intelligent behavior for characters quickly and easily."

The JXTA community's edutella project is "a P2P network for the exchange of educational resources between German universities [..], Swedish universities [..], Stanford University and others."


In today's java.net News Headlines
:

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 by news director
Steve Mallet before being posted to the site. You can also subscribe to
thejava.net
News RSS feed
.


Current and upcoming
Java Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e"> events submission
form. All submissions go through an editorial review before being
posted to the site.


Archives and Subscriptions: This blog is delivered weekdays as the
Java
Today RSS feed
. All java.net members can subscribe to the email
updates for the site at the href="https://java-net.dev.java.net/servlets/ProjectMailingListList">
java-net Mailing Lists page. You must be logged in to subscribe
to
the javanet_Daily and javanet_Weekly lists. 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 Archive.