Goodybye Ant, Hello Gant

Java developers spend countless hours writing build scripts using Apache Ant. Ant is a venerable tool in the Java world, having originated as part of the Tomcat project and venturing out into the big bad world as a stand-alone project in the dim days of early 2003.

Ant is supported by all major IDEs (indeed, it is fair to say that the Netbeans IDE has probably taken the ant build script to new heights of complexity and flexibility) and provdes a platform that has made possible the creation of countless plugins.

Still, Ant has its limitations. Writing XML-based build scripts is a task that gets old…fast! In addition, the XML-based build language makes it hard to express simple things like iteration or conditional execution.

Enter gant. Gant is the groovy build tool that augments plain old Ant by supplying a clean and powerful groovy-based DSL.

A simple example (incrementing numbered 'log' files) is:

dirLogs = 'logs'
target ( increment : 'Renumber (increment) the files in the logs directory' ) {
  def files = []
  new File(dirLogs).eachFile() { files << it.name }
  files.sort().reverse().each { 
    index = Integer.valueOf(it - 'log.')
    source = "${dirLogs}/${it}".toString()
    dest = "${dirLogs}/log.${index + 1}".toString()
    new File(source).renameTo(new File(dest))
  }
}

def printLogDir = {
  new File(dirLogs).eachFile() { ant.echo "  ${it.name}" }
}

target ( finish : 'finishing stuff' ) {
  ant.echo '...done.'
  printLogDir()
}

target ( start : 'startup stuff' ) {
  ant.echo 'starting...'
  printLogDir()
}

target ( bumpLogs : 'Log Rotation' ) {
  start()
  increment()
  finish()
}

setDefaultTarget ( bumpLogs )

Note the total absence of the dreaded XML. Note also the degree of sophistication here: this script is actually using a fair bit of Groovy 'goodness': collections, closures, etc. this task would not be so easy in plain Ant.

Gant is becoming increasingly well supported in the various IDEs and also in tools such as hudson. In addition (and very much in keeping with the Groovy world-view) you don't have to throw anything you already have away: all those nice external/third-party Ant tasks still work happily, all those 'legacy' Ant build scripts you have can keep on being used alongside the shiny new gant scripts you will be creating from now on…

If you are a Java developer, do yourself a favour: find out more about gant.

Personally, I don't want to write another build.xml file ever again; I'll be sticking with build.gant from now on!

Tags: Grails, Groovy, Programming, Tools

Gotta Love This Site!

This Wiki ("This was the very first Wiki, the one that started it all.") is a place that starts you off with the Extreme Programming Roadmap and lets you end up at the story of Stone Soup.

Along the way, you can be led to the problem of Essential difficulty in programming or the thorny issue of Surviving Guru Status. You may follow through to the XP tenet of Do The Simplest Thing That Could Possibly Work or any one of the thousands of pages hosted in the Wiki. All are interesting, some are strange, some irreverent and all provide a great example of how user-contributed documentation works.

Reminds me of a place I once worked at (had a really good time, actually): the team there had tried all sorts of things to get their documentation needs working for them; pretty much nothing did. I suggested a Wiki "…so that you can contribute the pages, keep them up to date and capture all the stuff that was 'getting lost' before." I was amazed at the pushback against user contributed/edited content. Seemed to me that the problem mutated into: "But we can't possibly show our managers an unstructured mess of pages!" Eventually a Wiki of sorts was adopted; a Wiki that was carefully structured and locked down in precisely the same way as the shelf upon shelf of existing documentation-and having the same worth to the organisation. The fundamental 'liveness' was lost, alongside all potential for change and any realisation of value.

I guess you can take a horse to water….

Anyway, that isn't the problem here…the "unstructured mess of pages" really works. Take a look-see, but don't blame me if you get trapped!

Tags: Agile, Tools

Green is Good, but easyb may be Even Better…

Long-surpressed, in the back of my mind, a niggling doubt has lurked: perhaps JUnit isn't The Best Thing Since Sliced Bread?

Don't get me wrong, it is a great tool: powerful, easy to pick up and actually quite elegant in its simplicity. It is fair to say that JUnit has advanced software development practices and raised the profile of testing and continuous integration. "Green is Good."

Two things have worried me however. Firstly: the amount of work I have to put in to actually building all these tests could very well be more than that required to build the 'real' code, and thus represents a cost that not too many organisations are actually willing or able to pay.

The second issue goes like this: how do I know that my tests are actually relevant? I don't mean have they achieved the required coverage but rather, are they testing things that the product owner would get value out of; You Ain't Gonna Need It may well apply to tests as well as code.

Enter easyb, a so-called Behavior Driven Development tool.

easyb is a Groovy-driven Domain Specific Language for building executable specifications. It lets your customer write stories that can then be decorated to produce executable tests and the result of these tests can be presented back to the customer for validation. To me, this sounds a lot better: I can't for the life of me forsee a situation where I would plonk a customer down in front of my JUnit code…

Venkat Subramaniam has a good presentation on easyb.

An example is useful, I think.

Consider the following (groovy) Class Under Test:

public class Test {
  def doublePositive = { x ->
    x <= 0 ? x : x * x
  }
}

It is probably not unreasonable (although I have met BAs and PMs that seem to regard themselves as a sort of firewall protecting the customer from the mad-haired, wild-eyed developers) that I could work with a customer to develop the following:

description "Testing the Test Class"

narrative """The Test Class is a cornerstone of our application;
the PHB says it had better be correct!""", {
  as_a "Starving Developer"
  i_want "The Test Class to be bug-free"
  so_that "My boss gives me a raise"
}

scenario "0 is given as input", {
  given "A new instance of Test"
  then "Doubling 0 should produce 0"
}

scenario "-1 is given as input", {
  given "A new instance of Test"
  then "doubling -1 should produce -1"
}

scenario "5 is given as input", {
  given "A new instance of Test"
  then "doubling 5 should produce 25"
}

Now the part that brought it on home to me: once the customer is happy that these stories are relevant and realistic, I can take the specification and execute it as a pending specification…not particularly useful, granted, but a solid start that permits me to incrementally decorate the specification to perform real, useful testing. I end up with the following tests:

description "Testing the Test Class"

narrative """The Test Class is a cornerstone of our application;
the PHB says it had better be correct!""", {
  as_a "Starving Developer"
  i_want "The Test Class to be bug-free"
  so_that "My boss gives me a raise"
}

scenario "0 is given as input", {
  given "A new instance of Test", {
    test = new Test()
  }
  then "Doubling 0 should produce 0", {
    test.doublePositive(0).shouldBe 0
  }
}

scenario "-1 is given as input", {
  given "A new instance of Test", {
    test = new Test()
  }
  then "doubling -1 should produce -1", {
    test.doublePositive(-1).shouldBe(-1)
  }
}

scenario "5 is given as input", {
  given "A new instance of Test", {
    test = new Test()
  }
  then "doubling 5 should produce 25", {
    test.doublePositive(5).shouldBe 25
  }
}

I also get a nice report that I can allow the customer to oversee:

3 scenarios executed successfully

  Story: test story
   Description: Testing the Test Class
   Narrative: The Test Class is a cornerstone of our application; the PHB says it had better be correct!
      As a Starving Developer
      I want The Test Class to be bug-free
      So that My boss gives me a raise

    scenario 0 is given as input
      given A new instance of Test
      then Doubling 0 should produce 0

    scenario -1 is given as input
      given A new instance of Test
      then doubling -1 should produce -1

    scenario 5 is given as input
      given A new instance of Test
      then doubling 5 should produce 25

If something were wrong with the Class Under Test, it is clear in the execution trace (for interest, note the use of gant as my build tool of choice for this little exercise):

C:DEVELOPMENTEB>gant
    [easyb] easyb is preparing to process 1 file(s)
    [easyb] Running test story story (TestStory.story)
    [easyb] FAILURE Scenarios run: 3, Failures: 1, Pending: 0, Time Elapsed: 0.2 81 sec
    [easyb]     "doubling -1 should produce -1" -- expected -1 but was 1
    [easyb] 3 total behaviors run with 1 failure
    [easyb] easyb execution FAILED
Execution halted as behaviors failed

C:DEVELOPMENTEB>

It is also clear in the report:

 scenarios executed, but status is failure! Total failures: 1

  Story: test story
   Description: Testing the Test Class
   Narrative: The Test Class is a cornerstone of our application; the PHB says it had better be correct!
      As a Starving Developer
      I want The Test Class to be bug-free
      So that My boss gives me a raise

    scenario 0 is given as input
      given A new instance of Test
      then Doubling 0 should produce 0

    scenario -1 is given as input
      given A new instance of Test
      then doubling -1 should produce -1 [FAILURE: expected -1 but was 1]

    scenario 5 is given as input
      given A new instance of Test
      then doubling 5 should produce 25

Note that the easyb report is 'live': it isn't stuck away in a Word document somewhere to slowly decay into irrelevance, it clearly shows the result of the test and will continue to do so. This is particularly important when one is using continuous integration.

To recap: I now have a sequence of stories, written for, or perhaps by, my customer that I-as a developer-am using as the basis for my test regime.

This I like!

Tags: Tools

No Clean Feed!

If you find the Australian government's "Clean Feed" Net Filtering 'initiative' as ridiculous and worrying as I do, why not contact the labour politicians responsible for this mess, check http://nocleanfeed.com/ or follow up with http://www.efa.org.au/

Leaving aside the obvious technical impossibilities, IMHO this issue speaks to education, personal responsibility and responsible parenting (difficult, I know).

Probably a better alternative approach is described at http://forums.overcl … 45&postcount=15:

The best and easiest solution would be to offer a 100% tax rebate (refunded with a tax return) to anyone who purchases their choice of commercially available internet filter from the existing market place.

Tags: Rant

Mea Culpa, Mea Culpa…Doing Ourselves a Disservice

This has been on my mind for a while, so bear with me…

I have just watched a whole series of vendors stand up and talk about their products. The message was always the same: "we realise that our products are hard to use for you to use without (gasp!) training, that we use too many TLAs so you can't understand us easily, that we behave too much like specialists and don't 'connect' with you on your terms, etc., etc. Mea Culpa, Mea Culpa, Mea Maxima Culpa."

Now, I understand that a vendor probably has to take this approach…he/she most likely wouldn't make too many sales otherwise (try to imagine a sales pitch concluding with: "…and you are required to purchase sufficient training and to devote sufficient time and effort to ensure that you are using our product correctly." it ain't gonna happen [and for some perfectly good reasons, too]). I do worry about this, though. Complex products that address complex requirements are hard to use…no amount of wishing/denial is going to change this fundamental (consider please a computer numerically-controlled lathe). All specialists have their domain languages and we do ourselves a disservice by pretending otherwise. Let's face it as well: would you really expect to consult with a top-surgeon only to be told "we need to go snippetty-snippety on the pink dangly bit here."

This issue of Mea Culpa seems to go deep: I have just finshed Certified ScrumMaster training. In Scrum, a fair proportion of the ScrumMaster's role involves working with the Product Owner to ensure that what is happening in the team is visible and appropriate for the needs of the project. There are no real requirements placed on the Product Owner other than to 'represent' the business. To my mind, there is an obvious imbalance here: while the dev. team has to work hard to be seen as working clearly, quantifiably making progress, ec. etc. there is no such requirement placed upon the Product Owner, who (as far as Scrum is concerned) may as well be handing down Product Backlog Items on tablets delivered from above.

Spot the issue? Clearly, development has such a highly problematic history (Mea Culpa) that it must be able to be overseen by all and sundry to make sure that things don't go badly off the rails (Mea Culpa). Where, pray, is the requirement on "the Business" to work in an equally transparent way so that the dev. team can oversee and have visibility into the way that requirements are gathered, analysed, presented, etc.? Organisations are regularly seen asking for developers with n+ years experience in products only n-1 years old ("just to be safe", it appears) while at the same time feel free to ask for BAs with little or no training (note that my cat has "Demonstrated ability to be able to communicate to a wide variety of people from all levels of an organisation"). Harsh words, perhaps. I am sure that Agile Analysis exists, I just don't see too many job adverts. Meanwhile PRINCE2 project management is gaining popularity in leaps and bounds since it is obvious that if a big hammer isn't doing the job then a bigger one is clearly needed).

Who knows, if both sides worked equally hard, if both sides admitted Mea Culpa, we would get real improvement…it certainly won't come about if this fake and ineffectual tendency to take on blame continues.

Tags: Rant

I am now Certified…

…as a Certified ScrumMaster.

I have just completed a two-day SCM training course, let by Mr. Rowan B. Bunning.

I found the course enjoyable and well-presented.

For posterity, here is a piccy, courtesy of Rowan.

I find the primary idea underlying Scrum appealing: Scrum comes from the realisation that up-front, in-toto planning simply doesn't work and that structuring a project as a series of time-boxed iterations may well be a more successful approach. There is more than this of course (the ideas behind the Agile Manifesto, self-organising teams, highly visible/quantified progress indicators, shared responsibility for success and/or failure, etc.) but that is the fundamental driver.

I still can't shake the feeling, however, that it's going to be a rare organisation that is brave enough to allow some of Scrum's features to be applied without change: how many enterprises (the natural home of the PHB) are there out there really capable of daring "safe-fail rather than fail-safe"?

Still, it's another string to my bow and may prove useful. Every good developer should aim to be a useful "cross functional team member", after all!

Tags: Agile

What Features Characterise "Enterprise Applications"?

This topic came up at lunch today…it is a contentious issue, but I'll wade in fearlessly!

It seems to me that although there are many applications used in an enterprise, very few of them are actually deserving of the title "Enterprise."

I am sure that this is one of those "how long is a piece of string"-type arguments that can't ever be 'won' but one of the best "feature-lists" that seems to cover all the requisite bases is given in the Gartner report Magic Quadrant for Enterprise Application Servers, 2Q08, which I excerpt here:

"…a system software product of the following minimal characteristics:

  • Offers a "container" implementation for the execution of application software modules (SM):
    • The container provides a "programming model" (a set of APIs for use by the SMs).
    • The container deploys as a long-running server operating system (OS) task (OS "daemon").
    • SMs are programmatically addressable on request remotely through services that are associated with the container.
    • The container allocates and uses OS resources (memory, threads, tasks) on behalf of the individual SMs, freeing SM code from the necessity of direct interaction with the OS.
    • The container provides resource pooling (database connections and network connections), and the pools are shared by the SMs.
  • Supports distributed computing (load balancing and failover clustering between container instances).
  • Provides an API or other means for authentication and authorization by the container.
  • Provides an API or other means for monitoring the status and minimal management (such as start and stop) of the container instance(s).
  • Provides an API or other means to access a file system by an SM.
  • Provides an API or other means of access to a relational DBMS (RDBMS) by an SM.
  • Provides an API or other means of invoking SMs by an SM:
    • Within the same container instance
    • Across like container instances
    • In other unlike container types
  • Provides an API or other means to demarcate an atomicity, consistency, isolation, durability (ACID)-style transaction by an SM.

…"

In addition to all this, Martin Fowler, in the introduction to his book Patterns of Enterprise Architecture gives other properties:

  • A lot of persistent data
  • Concurrent data access
  • A lot of user interface screens
  • Integrate with other enterprise applications, often transactionally or in a time-sensitive fashion
  • Lots of translation between data formats (usually for integration or reporting)
  • Complex business 'illogic'
  • A requirement for 'scalability' (meaning the application has to deal with those intangible and ill-defined issues of response time, responsiveness, latency, throughput, load sensitivity and degradation, to name but a few)

But wait, there's more!

An Enterprise Application also lives in a context: what is the application's Service Level Agreement and how is that monitored; how is that application deployed and how is it maintained; how does server/network infrastructure maintenance impact on the application; what logging facilities should be made available and how are those logs to be used (reporting); how is 'uptime' defined and managed; etc., etc., etc.

Don't forget the people! A typical Enterprise Application is not simply "install and forget", indeed, it may resemble an overgrown baby with very particular care and feeding needs; 'nanny' must have a very different skillset to that needed by a person skilled at managing a desktop SOE.

Just because an application is used in an "enterprise", just because it is client-server, just because it is written in Java, C#, C, Python, or Whitespace, just because it is running on JBoss Application Server, Oracle WebLogic Server, IBM WebSphere, or whatever, just because you have a load balancer in front of a load of disparate server instances, etc. doesn't necessarily make the software worthy of the term "Enterprise."

Not many applications will touch all the bases outlined here, but it should be quite clear that real Enterprise applications are hard to build and that in reality the tag 'Enterprise' is a hard one for an application to earn.

It should also be quite clear that the tag 'Enterprise' is a hard one for a developer to earn!

Truthfully, it is hard for a development team to earn. The days when an Enterprise application can be developed by a guy and his (C/Java/C#/…) compiler are (or should be…) long gone. Of course, that one guy can produce good, useful software having significant value to its owning enterprise but it is doubtful whether that code will qualify as true "Enterprise" grade stuff.

Tags: SOA

Another Outstanding Tool: SoapUI

I have used this tool 'in anger' more than once, to develop and test webservices.

I often talk to people who have heard the term 'WebService' but don't really understand what they are about and SoapUI is really excellent at showing "what's what." It's also great for helping people understand that "Interfaces Matter; Implementation Tool/Language/Organisation Doesn't…"

Version 2.5 looks even better than what has gone before. Get it: http://soapui.org

Tags: SOA, Tools

Documentation: Very Wise Words

Some of the wisest words ever written about documentation are to be found here: BBQ Sauce. Sweet or Hot?.

The words are so darned good that I feel simply obligated to show them to you:

If this 'clicked' with you, then let me just say that the whole Implementing Scrum site is very well worth a good, long read; the explanatory cartoon sequence is outstandingly good, IMHO.

If this didn't 'click' with you, let me just strongly advise you to go to the above site and read even more carefully, and ponder…

Tags: Agile

Documentation: the Bane of Every Consultant's Life!

Too often I have seen projects get swamped and sidetracked by the desire to produce the perfect documentation set. I recall one project where the attempt to produce the 'perfect' paper trail so completely consumed all available cycles that no working code was ever produced!

I wholeheartedly endorse the Agile Manifesto that says, in part: "…we have come to value…Working software over comprehensive documentation…."

Still there is often a need to produce quality documentation for one's client.

Just as with software, I am happy to reuse good open-source material.

I have recently come across ReadySet http://readyset.tigris.org/:

ReadySET is an open source project to produce and maintain a library of reusable software engineering document templates.

I am sure that there are other similar document collections "out there", but this set seems to be a good starting point.

Tags: Agile