After writing yet another Dispatcher, I've come to think that the Dispatcher interface should have return values as public constants.
The trouble is one of readability, and quite minor, but worse when there is a bunch of return statements, or when reviewing a long dispatcher (when you come to the end of the function, and have to reason... now, is true or false the correct return value?). Basically, I would change this: 028 public interface Dispatcher 029 { 036 boolean dispatch(Request request, Response response) throws IOException; 037 } To this: public interface Dispatcher { boolean dispatch(Request request, Response response) throws IOException; public static final boolean HANDLED =true; public static final boolean CONTINUE=false; } Which would let someone write "return HANDLED;" because the constants come with the interface. It's easy enough to add these constants in every dispatcher, but unlike other (more errant) uses of interface constants that I've seen, this seems to me to be very relevant to the contract of the interface; and it could serve to make dispatchers more readable. I don't think that Java inlines final constants anymore, so there could be a trivial performance penalty. Just a thought... very low-impact on my side. -- Robert Hailey