The true cost of exceptions

Posted by Michael Studman Fri, 03 Mar 2006 19:59:00 GMT

Exception-throwing causing your application to run slower than molasses? Exception-wrapping causing you to loose the original problem like the proverbial needle in the haystack? Who cares? The true cost of exceptions is that you can never type "exchange" or "exchequer" or any other word starting with "exc" without your finger memory first overruling you.

Appledrama: I want my Mac (don't care what I have to do)* 3

Posted by Michael Studman Sat, 07 May 2005 03:00:00 GMT

So I decided to make the big leap into the Apple world. Actually, it turned out to be more like a sideways wobble.

Suffering from the Apple halo effect, I was quite happy to throw down £1100 for a nice new 12” Powerbook at the online Apple store. On their site, they state it’s ready to ship in 24hrs. With the 3-7 days of delivery time that should have meant I received my new baby at most a week after purchasing.

So I key in my credit card details and click submit faster than I’d accept a blow job from my gym instructor (Sammy, are you reading?) The first confirmation email I recieved gave a shipping date 48 business hours later (but I could have forgiven them that for just that).

And then came the 4 days of Applean silence.

After a rather shirty call to the Apple control centre and some fluffy appeasment by a call center operator with exactly the same information to hand as I had on my account screen at apple.com I was assured it would be ready to ship the next day.

Well, if “it” meant “disappointing news” and “ship” mean “send via SMTP” then exactly that happened – I received an email announcing that there had been “unprecedented demand” for my product, that the were “shipping as fast as possible” and were now likely to ship on or before the 11th April (9 days after I ordered it not including delivery time).

All of this I can forgive (I’m quite a forgiving kind of guy) except for one slight detail – Apple are still advising their potential customers by way of http://www.apple.com/uk/thestore that the 12” PowerBook Superdrive ships in 24hrs. This is patently not true so Apple are, by way of incompetence or intent, misrepresenting their shipping times. Since Apple haven’t yet taken my money I imagine none of this is illegal but as a Mac newbie this is clearly a very bad opening to what I expected would be a thrilling and empowering (if costly) relationship.

Anyway, once I get my Mac-fix I’m sure my mouthy opinions will quickly retreat back into Cupertino crack haze.

* Regarding the title, any self-respecting UK or Antipodean child of the eighties should remember Bananarama and their brilliantly plastic pop hit “I wan’t you back (don’t care what I have to do)”

Lexing headache: Hex Floats and Doubles in Java 5 1

Posted by Michael Studman Fri, 06 May 2005 03:00:00 GMT

My brain’s well and truely fried after a night of wrestling with Checkstyle’s java.g to make it happily recognise hex floats and decimals. See what I have to deal with:

      NUM_INT
          {boolean isDecimal=false; Token t=null;}
          :   '.' {_ttype = DOT;}
                  (
                      (('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})?
                      {
                      if (t != null && t.getText().toUpperCase().indexOf('F')>=0) {
                          _ttype = NUM_FLOAT;
                      }
                      else {
                          _ttype = NUM_DOUBLE; // assume double
                      }
                      })
                      |
                      // JDK 1.5 token for variable length arguments
                      (".." {_ttype = ELLIPSIS;})
                  )?

          |    (    '0' {isDecimal = true;} // special case for just '0'
                  (    ('x'|'X')
                      (    // hex
                          // the 'e'|'E' and float suffix stuff look
                          // like hex digits, hence the (...)+ doesn't
                          // know when to stop: ambig.  ANTLR resolves
                          // it correctly by matching immediately.  It
                          // is therefor ok to hush warning.
                          options {
                              warnWhenFollowAmbig=false;
                          }
                      :    HEX_DIGIT
                      )+

                  |    //float or double with leading zero
                      (('0'..'9')+ ('.'|EXPONENT|FLOAT_SUFFIX)) => ('0'..'9')+

                  |    ('0'..'7')+    // octal
                  )?
              |    ('1'..'9') ('0'..'9')*  {isDecimal=true;}        // non-zero decimal
              )
              (    ('l'|'L') { _ttype = NUM_LONG; }

              // only check to see if it's a float if looks like decimal so far
              |    {isDecimal}?
                  (   '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX {t=f2;})?
                  |   EXPONENT (f3:FLOAT_SUFFIX {t=f3;})?
                  |   f4:FLOAT_SUFFIX {t=f4;}
                  )
                  {
                  if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0) {
                      _ttype = NUM_FLOAT;
                  }
                  else {
                         _ttype = NUM_DOUBLE; // assume double
                  }
                  }
              )?
          ;

Gack! This is at once a lexer rule that may return a NUM_FLOAT, NUM_DOUBLE, NUM_INT, NUM_LONG, DOT or ELIPSIS token. The most trouble I’m having modifying this is making sure 0x.1P+127f is accepted as a float while 0x is not (0x is no longer necessarily followed by one or more HEX_DIGIT).

I’ll sleep on this one, I think. Cheers to David Flanagan for indirectly alerting me to this Java 5 language feature.

Marketing Guantanamo - A Thoughtworks Misadventure 2

Posted by Michael Studman Thu, 17 Mar 2005 05:00:00 GMT

Thoughtworks are promoting an opensource tool contributed to by one of their Thoughtworks, a tool sharing the name of one of recent history's flashpoints for the systematic deprivation of basic human rights. Welcome to Guantanamo...

Associating the name Guatanamo with a product is very odd indeed, one might easily draw a parallel between the invalidity, misguided and ultimately self-defeating nature of the human rights abuses at Guatanamo Bay with the efficacy of this extreme eXtreme Programming tool. I suspect this is not the intention of Aslak (the tool's author).

He does try to make a (rather poorly argued) rationale for the product's name and at least this is based on his opinion that the actions by the US in Guantanamo Bay are questionable. He's no Neo-con, just someone with a misplaced sense of taste.

Software and politics can mix, they just didn't this time. That a software consultancy let itself be associated with such a name may indicate just how ambivalent most of us are to the practices at Guantanamo Bay and thus how un-contraversial it is. Or maybe it just slipped under the corporate radar.

Jarwars: StarWars and Generics

Posted by Michael Studman Wed, 26 Jan 2005 05:00:00 GMT

class MadbeanBlogEntry
  implements
    Pastiche<Trailer<StarWars.Revenge<Sith>>>,
    Editorial<Generics>
{
}

Check out MadBean for a high quality pastiche of the latest Star Wars trailer combined with a witty editorial on Java generics.

Matt's a man of many tallents.

Are RSS Feeds the New Tear-a-Page Desk Calendars of Our Time?

Posted by Michael Studman Fri, 07 Jan 2005 05:00:00 GMT

Tear-a-page desk calendars - I'm sure you've owned one - maybe a Dilbert or a Far-Side strip every day for 365 days a year? Except if you're anything like me you loose interest in them or don't integrate the daily ritual of the tear-a-page into your life and end up in May with 5 months of dead tree to toss out. I'm starting to feel like that with RSS feeds - when I miss a day or two or ten of checking a busy feed (typically through Bloglines) the task of scanning 300 or so blog entries becomes too much and I fall behind - way behind.

The Sydney Morning Herald just doesn't get RSS

Posted by Michael Studman Tue, 21 Dec 2004 05:00:00 GMT

It seems like some dumbfuckards at the Sydney Morning Herald don’t like the hoi polloi syndicating their Really Simple Syndication feeds.

So I thought I’d add the SMH RSS feed to my bloglines.com account since it’s far more friendly than the HTML mess fairfax choose to vomit up every day. It seems that in doing so I may cause bloglines to violate SMH’s terms of use:

http://www.smh.com.au/rsschannels/
These channels are for personal use and only in news reader applications. You may not publish headlines from these channels to a web page.

And if you thought little old you could easily licence their headlines you’re out of luck:

http://news.f2.com.au/cgi-bin/SynApp.cgi?sy=smh&ac=initial
Please Note: Sites with less than 2,000 monthly unique users and intranets accessed by less than 100 employees will not be eligible.

A spot check at The Guardian shows a similar policy.

Of course, completely free RSS feeds directly challenge the existing syndication and advertising model of newspapers. And we know how much established players hate having their business models challenged. A unique group of 2000 monthly users (typically clustered around a topic) is a great source of targeted advertising as is a group of 100 employees or more. Not that there’s anything wrong with that, of course, it’s just that this ugly love child of technological bandwagonism and business model protectionism ought not to bear the RSS acronym when it is so blatantly at odds with the spirit of that technology.

And while I’m on my soap box, SMH would you please turn that auto refresh off your front page. I’ll refresh when I feel like it!

SOAP Testing and the Meaning of Life

Posted by Michael Studman Wed, 01 Dec 2004 05:00:00 GMT

I'm currently in search of a decent testing tool for web services and came across PushToTest's TestMaker. I'm still evaluating the product for my needs but its creator, Frank Cohen, gets full marks for giving me a Monday morning chuckle.

On entering my particulars to register the product I noticed a field for any questions I may have. In a fit of Friday afternoon silliness my question became "What is the meaning of life?".

Frank, a man obviously not afraid of a challenge, responded:

Thank you for registering at the PushToTest web site. You asked the question: "What is the meaning of life?" From the perspective of a tool like TestMaker, the meaning of life is the satisfaction a software developer, QA analyst, and IT manager feels when they understand the performance and scalability of an information service. Of course the answer to life, the universe, and everything else is still 42. Hope this helps. -Frank

Why can't all marketing communications be this much fun?

Amnesiac Java: language features I forgot existed 19

Posted by Michael Studman Fri, 27 Aug 2004 03:00:00 GMT

I've been developing in Java for pretty much since Java 1.0. While working on the ANTLR Java 5 grammar I was suprised to rediscover some features of the language I'd just plain forgot.

First up, while working on annotation array initialisers, I was pleasantly reminded that the final element of a regular array can have a trailing comma:

    String[] foo =
        new String[]
        {
            "qwerty1",
            "qwerty2",
            "qwerty3",
        };

This is a nice little convenience for when you need to expand or contract the array elements in the initialiser - it means you don't have to fiddle with the final element to make sure there is no trailing comma.

Later I was reminded that interfaces may be package protected. For some reason i'd deluded myself into thinking interfaces could only be public:

    package foo;
    interface Bar {}
    ...
    package foo2;
    class Bar2
    {
       foo.Bar b;
           //compilation error: foo.Bar can't
           //be accessed from outside its package
    }

Duh! How could I have lived without that one? I often complained to co-workers that I couldn't do this - by their response they obviously didn't know you could either.

Finally, I was recently reminded that you can use the .class 'field' on primitive types:

    Class c = int.class;

I've long been aware of this 'field' on regular classes and interfaces (e.g. String.class) but when faced with the need to get the class of a primitve type I'd use the helper fields (e.g. Integer.TYPE). This forgotten feature is nicely consistent.

I use quotations around the word field here because it's not really a field, just a few grains of syntactic sugar (decompile a class that uses the .class 'field' to see what I mean).

What's your forgotten language feature?

My Java 5 Antlr grammar 6

Posted by Michael Studman Sun, 25 Jul 2004 03:00:00 GMT

After years of toying with Antlr but never actually doing anything useful with it; and after months of merely skimming articles on new Java 5 language features I thought I’d deepen my understanding of both and update the Antlr Java 1.4 grammar to recognize the new language features.

Suprisingly it only took about a week to polish off, and most of that was spent just cleaning up the grammar and deciding between different ways to structure the output AST (rather than strugling with Antlr tool itself).

For anyone interested, my grammar can be found on my site and it’s also hosted at antlr.org

As for how well tested it is: I’ve used it to successfully recognise the entire Java 5 source base, jdigraph’s source base (an early adopter of generics) and some custom tests I developed. I found the accompanying AST recogniser (as opposed to the token stream recogniser) is a good tool for confirming your tree is structured as you expected it to be. I also visually inspected the AST to ensure its structure was what I expected. An alternative to visual inspection would be great to automatically ensure the grammar stays correct over a lifetime of modifications. I’d love to hear from anyone who’s worked on such a tool. A testing framework that used XQuery or XPath querying/assertions on DOM-adapted AST (similar to PMD’s AST interface) would be my first approach. Comments or experience anyone?

More comments on Antlr and Java 5’s new language features later.

Older posts: 1 2