If you use an ‘if’ you deserve to suffer

How’s this for an extreme opinion: If you use an ‘if’ you deserve to suffer at Mark Needham I actually agree with some of his conclusions, although I am surprised that he does not suggest the simple approach of extracting a method to eliminate the potential confusion of multiple statements depending on an “if”. For …

Continue reading ‘If you use an ‘if’ you deserve to suffer’ »

Comparing Java and Python – is Java 10x more verbose than Python (LOC)? A modest empiric approach

It’s a long-running argument. Are modern, dynamic, languages such as Ruby and Python really much more concise than more mainstream languages such as Java? What constitutes “big” in each case? Stephan tries to flush out some hard facts, and gets a lot of comments. Comparing Java and Python – is Java 10x more verbose than …

Continue reading ‘Comparing Java and Python – is Java 10x more verbose than Python (LOC)? A modest empiric approach’ »

building an executable jar from other jars

I started the day cursing the stupid jar format, but ended the day smiling. I needed to build a stand-alone executable jar which accessed a MySQL database but kept getting all sorts of build-time and run-time errors. Normally to make an executable jar I use the excellent pack ant task which build a minimal jar …

Continue reading ‘building an executable jar from other jars’ »

Never return Null Arrays – really?

Scott Selikoff recently posted that we should “never return null arrays”. I’m not sure I entirely agree. Both the tone of the article and the comments so far seem to be in agreement, but I am still not so sure. I’ll skip the terminology issue for the moment, just note that an array in Java …

Continue reading ‘Never return Null Arrays – really?’ »

Are static or dynamic languages more maintainable?

So the question is: are dynamic-typed languages (ruby, python, smalltalk, etc.) easier or harder to maintain than static-typed languages (Java, C#, etc.)? It seems there are arguments both ways. On the one hand, dynamic languages tend to be a bit more concise, and reducing code size is a great way to simplify maintenance. On the …

Continue reading ‘Are static or dynamic languages more maintainable?’ »

MINA: Building a scalable server in 20 lines

This looks very interesting, even though I have a few questions to answer when I evaluate it properly. @me&java » Building scalable server in 20 lines I’m particularly interested how MINA stacks up against Grizzly, as they both seem to be addressing the same problem – a high-performance Java server using newer IO facilities. Currently …

Continue reading ‘MINA: Building a scalable server in 20 lines’ »

alternatives to ant: gant, gradle and pjmake

We use ant, a lot, but I’m getting progressively fed up with it so I’m looking for alternatives. Ant has several well-known problems, including: The use of XML makes the syntax very wordy and hard to read Things which should be simple such as refactoring common “code” or transforming filenames are more difficult than they …

Continue reading ‘alternatives to ant: gant, gradle and pjmake’ »

Screencast-O-Matic

Ever wanted to make a “screencast” (a recording of some on-screen activity, with or without a commentary, typically used for software tutorials)? I have done a few, but found choosing and configuring screen-recording software to be trickier than it should be. If you also find it a bit cumbersome, then this might be of use …

Continue reading ‘Screencast-O-Matic’ »

Java 6 breaks JDBC

I’m cross. Very cross. Cross with Sun for releasing a new version of Java which shatters both backward- and forward- compatibility. Cross enough that I cannot see any sensible way of moving my software to Java 6 in the near future. It all started with an innocuous question in a comment on my Punchbarrel blog. …

Continue reading ‘Java 6 breaks JDBC’ »

Is it time for Java 5?

A major goal of the Stringtree software project has always been to be as compatible as possible with all the software people are using for their Java development. Naturally that also includes whatever Java version is being used. For a long time I interpreted this goal as implying that all Stringtree code should run on …

Continue reading ‘Is it time for Java 5?’ »

Small and Simple Web Applications – the Friki Way

A few years go I wrote a series of articles for The Java Ranch Journal entitled “Small and Simple Web Applications – the Friki Way”. The series showed an example of developing a very simple wiki (collaborative editable web site) in Java using Test-Driven Development (TDD) and a form of agile project management. From time …

Continue reading ‘Small and Simple Web Applications – the Friki Way’ »

mockito 1.5 and spying on objects

Mockito is a Java Mock objects framework which seems more usable than either of the main contenders (JMock and EasyMock). The project has just released a new version which now allows the attachment of a mock “overlay” to an existing object. This has been on my “evaluate” stack for months, but (as Harry Pynn pointed …

Continue reading ‘mockito 1.5 and spying on objects’ »

A Brief Overview of Java EE 6

A report of a presentation at a user group about Java Enterprise Edition (JEE) version 6, written in slightly unusual language – I can’t quite imagine that the main reason to try Spring is “to get high”. I tend to agree with the author that a JEE “profile” with servlets, messaging (JMS) and transaction management …

Continue reading ‘A Brief Overview of Java EE 6’ »

When to (and when not to) use a context object

Steve Freeman recently wrote about some of the perils of passing around a “context” object, from which different parts of the code may extract the collaborators they need to do their job. This approach is one form of “dependency injection”, a technique which decouples code from specific implementations of its collaborating classes and allows any …

Continue reading ‘When to (and when not to) use a context object’ »

Multiple Returns from a Single Method

A discussion of the benefits and disadvantages of single vs multiple returns from a method cropped up today. Unfortunately we became distracted before getting to the meat of the opinions. To help stir up that discussion again, here’s a link to an article (and follow-up comments) from Mark Levison’s blog. Notes from a Tool User: …

Continue reading ‘Multiple Returns from a Single Method’ »

A cautionary tale about Java Generics

It should come as no surprise that you need to keep your wits about you when you write software. But the wise programmer should also be wary of blithely adopting any kind of “best practice” without considering the implications. Here’s a cautionary tale about a case where doing things as it appeared they “should” be …

Continue reading ‘A cautionary tale about Java Generics’ »

Exploring LISP on the JVM

Despite several brushes with it over the years, I have never really worked with Lisp enough to “get it”. It’s certainly interesting that this language from the relative dawn of software is still around and still compelling enough to prompt new implementations and new support tools. Maybe I should try again and take another look. …

Continue reading ‘Exploring LISP on the JVM’ »