Certainly I’m not the first to notice the similarity between Test Driven Development and the Scientific Method? Answering my question: nope! Looks like a bunch of smart people have also made the connection. My favorite observation on the topic: the Scientific Method can be used as motivation for using TDD. Certainly a clever approach for introducing TDD to a scientifically-minded person.
My friend Matt wrote a pretty rad (yep, I used that word) implementation of the “sleeping barber” program in Clojure. Matt’s code had an almost sentence-like simplicity to it – pithy but expressive — that impressed me.
As we walked through how the program worked, I couldn’t help but wonder about a Java implementation. So, I wrote one.
Matt’s is self-contained in one file while mine is split across multiple files. (I opted to not use anonymous/inner classes.) I think we were a bit surprised that the concurrency logic is similar and the ”main” driving section of each implementation follows the same set-up procedure. Perhaps my code was influenced by way of transliteration?
I’m struck by how Matt’s Clojure programs reads somewhat like a story while my Java program reads like instructions for a computer.
Power-users and developers who use Windows are probably familiar with Sysinternals “utilities to help you manage, troubleshoot and diagnose your Windows systems and applications.” For those folks, here’s a quick one-liner to download all of Sysinternals tools using wget. (I use cygwin, hence
wget. Powershell users may have something similar.)
wget -N -r -l 1 -nd http://live.sysinternals.com/
The above also works for updating your local copy at a later date.
-N turns on time-stamping,
-r turns on recursive retrieving,
-l 1 specifies the maximum depth of recursion,
-nd saves all files to the current directory.
Note: This bug is resolved in Jetty 8.1.8 (v20121106).
Earlier this month, I filed Jetty bug report 393363 and offered a patch for a fatal error when the
user.language property is set to
The use of
setTarget()will throw a
NoSuchMethodExceptionwhen the rules of the default
Localeproduce an unexpected result. For example, if
user.language=tr, then the following would produce “
setİnitialSize” rather than the expected “
This applies to current and past versions of Jetty.
This problem surfaced when a customer in Turkey could not get my company’s software to work on a Turkish-language OS. A work-around is to set the Java
user.language property to
en, but Jetty shouldn’t require this in order to work. The patch specifies an appropriate
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/Injection.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/Injection.java index 5cfad9a..5c529a6 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/Injection.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/Injection.java @@ -140,7 +140,7 @@ public class Injection - String setter = "set"+target.substring(0,1).toUpperCase()+target.substring(1); + String setter = "set"+target.substring(0,1).toUpperCase(Locale.ENGLISH)+target.substring(1);
JUnit 4.4 added a new assertion mechanism with the method assertThat(). Have a look and consider using it in place of assertEquals().