I am Paul Wilson; Mere Complexities Limited, sells my consulting, coaching, and coding services. I am passionate about Agile, particularly Test Driven Development.


Note to self

It's not "doing agile", Scrum, XP, whatever. It's not about being right. It's not about avoiding the waterfall, avoiding documentation, avoiding MS Project. It's about doing a good job, and increasing revenue. Be pragmatic, but keep the ideals. Be enthusiastic. Ask for help. Accept help. Play to win. Oh yeah, and you need to do your VAT.

Cynefin

I'm about to spend a lot of money on a Cynefin training course. (Well it's a lot of money to me). Cynefin is about organisations, and networks; it is about knowledge; it is about people. This may be a strange road for a geek to start upon, but I increasingly believe that improving engineering practices are not enough. TDD and refactoring are important, but not enough. Iterative and incremental development is probably not enough. As Mary Poppendieck says, they are "micro-optimisations". Software changes the way people do things. It is about time that we learnt about the way people do things.

Why Blog?

Well there's this reason. I'm (currently) a contractor. I put my CV out. I interview for contracts. There's a link to my website and blog on my CV. I want potential clients to know that
  • I think about what I do
  • I care about what I do
Well that's one rationalisation, anyway.

Placeholder for future posts

There are some things that I mean to write about, but haven't got round to yet. Lest I forget (and in no particular order):
  • How exceptional should exceptions be?
  • "Not Invented Here" not so bad after all - sometimes it is better just to write the thing yourself
  • The Simplification Layer - isolating code from complicated framework \ library APIs.
  • Cynefin - enough said
  • NLP, Dale Carnegie, and soft fluffy bunny stuff.
  • The "so what" factor and epiphanies: I expected a pardigm shift, and all I got was a constructor.
  • What is the point of this blog?
Hey, to me that looks quite interesting: pity it's going to be so dull when I actually write the stuff.

Quotes from the waterfall

A couple of memorable things people said on my last big waterfall project.
I prefer to use the term lifecycle model; waterfall has such negative connotations. (A manager with whom I was discussing alternative ways to develop software). The User Acceptance Test Phase is vitally important, because it is the first time that the users see the system: the feedback is invaluable. (A business analyst in a project planning meeting. If I recall correctly, UAT was scheduled for one week at the very end of a six month project).

Bad SAX - Good SAX

Nice to see that David Megginson regrets the complexity namespace support added to SAX2. I don't remember ever needing to use namespaces with SAX; I do remember much confusion of local names, qualified names, and the way the behaviour changed between some versions of Xerces. I would use SAX1, if deprecated interfaces didn't make me feel dirty. As for his other regrets:- I can't say that I'm too fussed about SAXException not extending IOException. The "push" interface does make things tricky, but I have found SAX chaining and the ability to fire events to a SAX interface incredibly useful. In fact the chaining turns up as one of his biggest SAX satisfactions.

How the Date got its indexing

Date: Some time in 1994

Place: California I suppose, Sunnydale?

Event: Routine meeting of Java Pioneers

Attendees: James Gosling, Arthur van Hoff, Some anonymous JDBC hotshots

Item1: Should months in java.util.Date be one or zero based? Conclusion: obviously they should be one based. Zero based would be confusing. Everybody counts January as month 1, and December as month 12. Days of the month are not going to be zero based, so why would months be zero based?

Item 2: Should prepared statement paremeter and result set field indexes be one or zero based? Conclusion: obviously they should be zero based. Zero base is the norm in computer science and Java arrays and lists use zero based indexes: it would cause confusion to use one based indexes for JDBC classes.

Meeting adjourns. On the way out the minutes are dropped; papers get shuffled. And that is the way the Date got its indexing.


The Java UnrecoverableFailureException pattern

As an exercise, I have written up the UnrecoverableFailureException - mentioned here - as a pattern. Intent Enable client code to ignore exceptions from which it is unable to recover. Hides implementation information implicit in implementation specific checked exceptions. Motivation In many applications, certainly web applications, the only sensible response to most exceptions is to display a "there was some internal message" to a user: it is not sensible to attempt recovery from most exceptions; there is nothing the application can do, except log and inform, if the database has died. This solution is to wrap those exceptions that the client cannot be reasonably expected to handle with a single application wide UnrecoverableFailureException, distinguishing these general failures with those that the client may handle in a specific way. An UnrecoverableFailureException is used to indicate that a method is unable to fulfill its postcondition due to some external problem from which the client is unable to recover. Applicability The UnrecoverableFailureException is particularly applicable to layered applications in which the lowest layer may always potentially fail; each request to a typical web application involves interaction with the database, resulting in a potential SQLException. It is innapropriate for general purpose library APIs, where the capabilities of the client to recover from an exception are unknown. As far as I am aware, this pattern is only applicable to Java with its peculiar concept of checked exceptions. Collaborations Root cause Exception UnrecoverableFailureExceptions typically wrap a root cause exception that originates from outside the application. Thrower An UnrecoverableFailureException is thrown by code that encounters such an exception. Thrower's logger A common way of using logger APIs, such as log4j or java.util.logging, is to provide a single static logger per class. Passing the logger to the exception on construction enables the error to be logged at the same time as throwing the exception. Client The client of the Thrower propogates the UnrecoverableFailureException without catching. Last minute catch block The UnrecoverableFailureException is usually caught and handled in a common message loop, or by some other common mechanism. This might include a standard error page, in web.xml or struts.config. A typical strategy is to display a common "There has been an internal failure; please try again" to the user. Consequences Cleaner code Adopting this simple pattern takes a great deal of bother from Java exceptions. The decision to make an exception unrecoverable takes place in one place and then no longer bothers any client. I have found that this pattern greatly reduces the number of try catch blocks, as wrapped exceptions are no longer caught and wrapped again. Encapsulation An UnrecoverableFailureException does not give away implementation details; as SQLException tells the client that the supplier is using JDBC to access a database. Some information leakage from client to supplier The supplier needs to know which exceptions are of interest to the client. In practice this is seldom much of a problem: suppliers are written to service the needs of a client; if mistaken the code can be corrected. Implementation Consider
  • Make the UnrecoverableFailureException a runtime (unchecked) exception. If the client cannot handle the exception there is no point declaring it. In a typical web application nearly every method could potentially throw the UnrecoverableFailureException. If you are uncomfortable with this, no matter: you can always make the exception unchecked later.
  • Log in the exception constructor. This ensures that the error is logged once and once only.
  • UnrecoverableFailureException is too long a name for some tastes. Use a shorter title (eg FatalException) if you like.
Sample Code
public class UnrecoverableFailureException extends RuntimeException
{
public UnrecoverableFailureException(String message, Logger clientLogger)
{
   super(message);
   clientLogger.severe(message);
}

public UnrecoverableFailureException(Logger clientLogger, String message, Exception cause)
{
   super(message, cause);
   clientLogger.log(Level.SEVERE, message, cause);
}

public UnrecoverableFailureException(Logger clientLogger, Throwable cause)
{
   super(cause);
   clientLogger.log(Level.SEVERE, "unrecoverable exception", cause);
}

public UnrecoverableFailureException(Logger logger, String message)
{
   super(message);
   logger.severe(message);
}
}
Related patterns throws java.lang.Exception Rather than wrap the cause, an alternative is to simply declare a method to throw java.lang.Exception. This requires even less code and trouble. I dislike this aproach:-
  • in a typical web application all, or nearly all, requests will result in database interaction. As a result most applicaiton methods will need to declare that they throw java.lang.Exception. Being universal, the declaration conveys no useful information. Other application domains, however, may apply this pattern with more point.
  • other checked exceptions are hidden. I believe that there is still a place for checked exceptions, indicating uncheckable precondition failures. If the method also throws java.lang.Exception then this masks the checked exception, making it essentially a runtime exception.
  • it is not obvious that the decision to throw java.lang.Exception was taken with purpose: it gives the impression of sloppiness, and sloppy code attracts sloppy code.
throws application specific exception Another approach is to mandate that all exceptions thrown in the application extend a single checked application specific exception. Where I would prefer to declare an UnrecoverableFailureException, this base exception is declared to be thrown. This is effectively the same as declaring that java.lang.Exception is thrown, with the added burden of having to wrap external exceptions.

My chiropractor broke his spine

My chiropractor has a small model spine which broke as he demonstrated some movement to a patient. He has temporarily fixed it with elastic bands, with which he has tried to mimic spinal muscles. He says that this exercise has taught him a lot about his trade.

subscribe here subscribe

About me

picture

Conference

Scotland on Rails Organiser

Previous blog posts

Blog archive

Other links: