Tag Archives: thoughts

Back to Basics – good comments are targeted comments

I can’t think of a single person who enjoys writing comments in code. I don’t, my friends and colleagues don’t, and I’m pretty sure there isn’t a meetup group for fans of it. Outside of code that I write for blog posts, I can pretty much guarantee there are only place where I write comments is in interfaces.

The simple reason for this is that a) interfaces should be explicit, and b) implementations should be self-documenting.

The reason for this blog post is that I’m seeing a lot of code at the moment that falls into one of two traps – either everything is documented, or nothing is documented.

Everything is documented

Spot what’s wrong with this code:

/**
 * The foo class represents blah blah blah...and so on, describing the 
 * class in such detail it's a pity the code couldn't be generated from it
 */
public class Foo {

    /** The name */
    private String name;

   /**
    * Do something with this instance.
    */
   public void doSomething() {
      // Get the name
      String localName = this.getName();

      // munge the local name
      localName.munge();
   }

   /**
    * Get the name.
    * @return the name
    */
   public String getName() {
      // return the name 
      return this.name;
   } 

   /**
    * Set the name.
    * @param name the name
    */
   public void setName(String name) {
      // set the name 
      this.name = name;
   } 
}

Or, to put it another way, spot what’s right with it. That’s a much shorter answer. The code is full of unnecessary comments – e.g. getName() gets the name – and code that seems to have been written just so it could be commented – e.g; String localName – this.getName(); The names have been changed to protect the guilty, but this is real code I’ve seen in a live codebase.

As as I’m concerned, implementations don’t need code-level comments because that’s what the code does anyway.

Nothing is documented

At the other end of the scale is this little gem:

public interface Parser {
    void parse(InputStream is) throws IOException, SQLFeatureNotSupportedException 
}

Interfaces, on the other hand, should have clear documentation that defines what goes in, a generic description of what should happen, and a clear description of what comes out and what exceptions can be thrown. Information at this level should state if, for example, null arguments are allowed, if a null value can be returned, the circumstances in which certain exceptions can be thrown, and so on.

Interfaces should be explicit

Interfaces, to my way of thinking, are contracts, and contracts – as any blood-sucking lawyer can tell you – exist to be honoured. They can’t be honoured if the terms are not explicitly set out.

There are no Burger Kings in Belgium, so if I’m in the UK or the Netherlands I am generally tempted to have one. On my most recent visit, I noticed this at the bottom of the receipt:

Free drink with any adult burger with this receipt Excluding Hamburger, Cheeseburger or King deal or any promotional offers”

Or, to put it another way…

/**
 * Get the free drink promised by the receipt.  This is valid for any burger.
 * @param burger the burger
 * @param receipt the receipt
 * @returns the free drink
 * @throws InvalidBurgerException if the burger doesn't qualify for a free drink
 */
public Drink getFreeDrink(Burger burger,
                          Receipt receipt) throws InvalidBurgerException {
    if (MealType.HAMBURGER == meal.type()
        || MealType.CHEESEBURGER == meal.type()
        || MealType.KING_DEAL == meal.type()
        || meal.isPromo()) {
        throw new InvalidBurgerException();
    }
    return new Drink();
}

To my simple brain, this is confusing and contradictory as hell. Your API should be clear and (as my university teachers beat into me) unambiguous – for example, the words “any” and “except” should not appear in the same sentence. Strive for clarity – if you find your API is too hard to clearly document, there’s a good chance it will be annoying to use. In the case above, an improvement would be something along the lines of

/**
 * Get the free drink promised by the receipt.  Not every burger qualifies for a free drink.
 * @param burger the requested burger.  This may or may not qualify for a free drink
 * @param receipt the receipt containing the offer
 * @returns the free drink. May be null, depending on the burger
 */
public Drink getFreeDrink(Burger burger,
                          Receipt receipt) {
    // implementation
}

Note that I’ve also got rid of the exception as a result of being more explicit.

Conclusion

Annoying as it is, documentation is extremely important in the correct place and completely useless everywhere else. Done correctly, they will make your API easier to use and easier to maintain, which is generally a good thing.

Here endeth the lesson.

Thoughts on the Belgian Play! Framework User Group dojo

The 3rd of October saw the Belgian Play! Framework User Group hold its first coding dojo and overall, it was a success. It’s the first time I’ve been involved in the organisation of anything like this, although the vast majority of the preparation was done by Ben Verbeken.

We had 17 people at the dojo, plus a DBA who stopped by for an hour because he’s interested in how developers and DBAs can work more efficiently together. We had an application specification from an idea by Andy Petrella, along with a reference implementation coded by Ben, Andy and me. We had a meeting room and refreshments provided by Cegeka. In short, we had everything we needed to have a dojo.

Ben has already covered the application in his post on the dojo, so in the spirit of DRY and general laziness I’ll kindly allow you to read about it on his site. Here, I want to cover the bits we got right, the bits we got wrong and how we can correct or improve in the future.

The good

  • The first thing we got right was to actually organise the dojo in the first place. Everything else, good or bad, stems from this.
  • In place of having two people at the front of the room, with a constant rotation of the group’s members, a wireless keyboard was used and passed to the left at the end of each 10 minute time block. This saved time, and meant that the group wasn’t split up into the watching and the watched.
  • Purely by accident, one of the most experienced members of the group (Andy) was sitting pretty much in the middle, and was the first to code after the 10 minute break. The people who coded in the first half of the dojo got an application up and running, and then Andy kicked it up a notch by adding the Twitter4J dependency and coded up to the point of actually posting to Twitter. The effect of seeing the app interact with an external system with just a few minutes’ coding sparked quite a bit of interest and discussion.
  • On the subject of Twitter, we set up a QuickQuizzz application in Twitter ready for use in the dojo. Doing this during the dojo would have been pointless, because it didn’t directly relate to Play! in any way.
  • We ended up with a working application that (pretty much) met the spec! You can find the code on github.

The bad

  • No wifi! Due to a miscommunication, we didn’t get the password for the wifi network and instead had to turn a laptop on the wired network into a wireless access point. The resulting connection was very slow!
  • No choice of IDE! We had IntelliJ set up as the IDE, but it seems that a lot of people preferred Eclipse.
  • The keyboard moved in a linear fashion, always passing to the left. This meant you knew exactly when it was your turn, but also you knew exactly when it was *no longer* your turn. This ties in with the next point, which is…
  • Each person coded only once.
  • The idea for the app was mentioned at the beginning of the dojo, but not written down in a visible place. As a result, we had to clarify the idea throughout the evening.

Improvements for the next dojo

  • Full-speed network access is a must. At least one person didn’t have Play installed at the start of the dojo, and found it impossible to download due to the poor wireless bandwidth.
  • A choice of IDEs – IntelliJ, Eclipse and Netbeans – will be offered, along with a few text editors for people that don’t like or use IDEs.
  • The next person to code should be determined by something other than seating order – maybe numbered cards picked at random, or an app that chooses a name.
  • Because the overhead on switching between coders is reduced by using a wireless keyboard instead of having people physically move, each person should be able to code for e.g. 5 minute time blocks at multiple times during the evening. This would allow everyone to code before the break, at which point the random ordering can start again.
  • The spec should be written up as a very simple bullet list. A second list, with optional functionality, could be introduced if the app has been finished and there is still time left.

And next…?

The rest of the year looks to be pretty busy, with Devoxx coming up in November, plus day jobs, everyone seems to be doing the Coursera Scala course, etc, and then it’s the holiday season again. I think we’ll hold another event early in 2013 – not necessarily a dojo this time, because we have some other ideas to keep it interesting. In the meantime, Play BE will be having another meet-up in Brussels one evening – bring your friends, bring your laptop, bring your ideas and join us there! Details will be announced on http://play-be.org soon.

PlayBe Dojo – all seats booked, and ready to go

With less than a week to go until the Belgian Play! Framework User Group holds its first coding dojo, all 20 places have now been taken.  I was half-way through a blog post to promote it when person #20 signed up, so instead I’m going to flip this over and quickly look at how having an active event can really drive up interest in your user group.

The far more organised co-founder of the usre group, Ben Verbeken, has written about the upcoming dojo here - http://ostia.be/blog/2012/09/18/playbe-first-dojo/

Here’s a chart showing sign-up activity for the group since we started it a few months ago.  We’ve had a couple of meet-ups in the meantime, and have all come into contact with like-minded others.  So far, so good – but notice the lull in sign-up activity in the middle of the chart.

In the first few days, about 18 people joined – and I think a couple of those were people who join any meetup in their area.  Since we announced the dojo, the group has pretty much doubled in size.  The lesson I’m taking from this?  Developers want to develop - having a drink and a chat is all well and good, and our past meet-ups have been good evenings, but it’s not quite the same as sitting down together and creating something new in a couple of hours.

I think that, in future, coding will be a fixture of the meet-ups.  There’s no better way to discuss development than to actually bang some code out there and then.  Using Play, you already have a head start on creating an app in a few minutes which can then be evolved by the others around you.  So, the dojo will (hopefully) be a great night with a structured plan but there’s no reason why every meet-up shouldn’t be the equivalent of several concurrent dojos.

If you would like to join the Belgian Play! Framework User Group, head over to http://play-be.org – it’s free, and there’s a lot of fun ahead of us.

The value of independence

Three or four months ago, I received an email from an on-line advertising agency inquiring whether I would be interested in allowing in-article ads on my blog. I thought about it for about a second, and immediately answered with a polite rejection. The advertisers replied pretty quickly, pointing out the money I could earn from such ads.

This time, it didn’t even take a second to think about it – my answer was a flat “NO!”.

A couple of days ago, I received another email – this time from a tool vendor that’s preparing to offer free individual licenses for its tools. Would I be interested in writing an article on the tool? Certainly. What’s the difference? This – “I would love to hear your thoughts – both the good and the bad”.

I will happily review your product, your book, etc, but it will be as objective as I can make it. I refuse to hand control of this blog over to anyone, and there will never ever be a paid advert on here. I’ll review things with full disclosure, but I won’t shill for you. I will advance my own interests, but I’ll try to minimize my bias in the process. This is what the independence of my blog means to me.

But, as usual, someone else said it better…

Facebook…hmmm

I just read how Facebook changed all e-mail addresses to use their @facebook.com domain. Now, unless I misread something, I seem to recall my information section is about me, and so it’s not really up to them to change it. I wonder if they’re thinking of changing all birthdays to the same date, and having presents trans-shipped through them so they can shake the boxes first.

Happily, I own the domain that I use for my facebook email address, so I’ve created a new account called fuck-facebook@<my domain>.net, because that seems to sum it up nicely.

Which is to say, fuck facebook.

I’m not concerned about them changing the layout of their site, or introducing timelines – it’s their app, and they can do what they want with it in the free market of social networking. It may be their app but, unfortunately, it’s my data – and right now, I wish I’d never signed up to that damn place.

I would like to say I’m stunned by the unbelievably bad judgement they’ve shown with this move, but let’s face it – it’s not exactly the first time they’ve screwed with or exposed data

I’ve stripped my profile down to bare bones – no movie or music likes, minimum personal information. The next step is to check how much data of mine I can force them to purge (but I’m not holding my breath). Maybe you should think about doing something similar too.

A thought – people change each other’s facebook details often as pranks or as a prelude to fraud. In other words, they change personal details and act abusively. Facebook just happens to have a “Report abuse” section (you can find it here) – maybe you should report this as abuse too.

Update: I never realised how hard facebook made it to report something outside of something they consider to be abuse! Click on the link above, and you’ll find out for yourself. I’m trying to mail them about the following in their community standards:

On Facebook people connect and share using their real identities. This culture creates accountability and builds trust and safety for everyone.

Quick summary – real identities and creates accountability and builds trust. Talk about do what I say, and not what I do!

How to confuse a Belgian call-center operator

I love my job as a software engineer. I love it so much, in fact, that whenever I have time, I do it for free by working on open-source software and writing about software development on this excuse for a blog.

I am, therefore, highly aware that some people don’t enjoy their jobs. Call centers, for example, which will be the focus for this example.

When I lived in the UK, call centers were a fact of life. Anytime you needed to call your bank, your car insurance, your ISP, whatever, it’s a call center. Anytime you need to call one of those places because there was an issue or they’d screwed up in some way, there would be a call center operative doing their job by taking your call. Ninety-nine times out of a hundred, they would be extremely helpful because that’s the best way to enjoy your job – do it well, and try to get some satisfaction out of it. One time out of a hundred, they would be…um…anywhere on a range of not-so-helpful through to downright rude and obstructive.

Call centers, as far as I can make out, are set up to do three things – field calls, field calls that are complaints, and field complaints against the call center personnel. There is one category that it seems they’re not set up to deal with.

When you call a call center and the call ends, occasionally you’ll have a little touch-tone survey. “Did the operative help you? Press 1 for yes, or 2 for no”. Press 1 or 2, and you’ll get a cheery “Thank you for your feedback”. This is not the way to collect satisfaction data – or, at least, it’s not the way to collect anything other than the coarsest-grained data possible. The survey may as well be tone-sensitive and ask you to fart or belch to indicate your level of satisfaction.

Personally, I make a point of explicitly thanking people when they’ve been helpful. If the calls are recorded (which they invariably are, for “training purposes”), then you would hope it would show up. I also think those tapes are only used for the training purposes of lawyers when the company in question is getting sued. That’s why I also like to speak or contact the operative’s manager to pass on my positive thoughts on their performance.

Fast forward through two years of living in Belgium, and I’m back in call center land. I just signed up with Lampiris as my new utility provider, and there was an issue with my on-line sign-up. I got in touch with the service center and the guy I spoke to – in English, of course, despite the fact I’m living in Belgium – resolved the issue, looked at the root cause of the issue and got me to where I want to be in the sign-up process. I am one happy bunny.

So I ask to speak to his manager, at which point he gets a little bit confused. Now, customer service in Belgium is not what you would call satisfactory – in the majority of cases, you feel like you’ve achieved something when asking customer services anything if they haven’t poured sugar into your fuel tank as a response. Consequently, when you do get not just good but excellent customer service, you feel inordinately happy – maybe this is a country-wide long-term strategy, but I wouldn’t bet on it.

But I digress – I asked to speak to the guy’s manager, and he got confused and asked why. I briefly explained my philosophy, and he went off to get his manager (another difference to UK call centers – there, it seems the lines are constantly monitored by people issues can be referred to). The eventual outcome of this – his manager had stepped out for a minute. What a kick in the nuts! I put up with crappy customer service all the time, and when I want to express my satisfaction, there’s no-one there I can do it to!

I think I’ll file this one under “thoughts”.

Women in IT – thoughts triggered by a female colleague

This post is coming quite a way after the fact, but I just read this tweet from Pamela Fox and it reminded me that I’ve been meaning to mention this for ages.

Back in November at Devoxx here in Belgium, one of the major themes was women in IT*. I asked my female colleague (who is, by the way, an exceptional developer but I’m not going to name her because I haven’t asked permission!) if she was attending any of the talks. She said no, and then went on to explain her viewpoint.

I’m paraphrasing from memory here, but the gist of the argument was “software developers are already a minority, and I don’t like the idea of creating an unnecessary sub-minority“.

This surprised me a lot. From one point of view, I can see where she’s coming from – as software developers, we’re already regarded (to a lesser or greater degree) as a bit strange**, and we need to hang together if we’re going to avoid being hung separately. From another viewpoint, however, it ignores the marginalisation of women by men who are in the same industry. I was going to use the word victimisation, but I’ve never witnessed it personally (and you can be damn sure it wouldn’t happen twice in my presence, regardless of the gender of the victim) – maybe a commenter can bring me up to speed on this?

I’ve been lucky enough through my career to work with some exceptional developers who happened to be female. In fact, I’ve never worked with a female developer who was any less than excellent – but there’s probably a very good reason for that. Since the overwhelming majority of developers are men, it follows that the majority of bad developers are also men. I’m pretty crappy with statistics, and they can famously be made to say anything, but it seems to me that the women who punch through the marginalisation barrier do so based on skill, and thus skew the figures even more.

Right now, I’m feeling very concious about what I’m writing, with the usual thoughts of sounding patronising and, frankly, feeling like the kind of dipshit who dumps his brain into his blog only to get it run through a blender. C’est le vie.

* The chivalrous part of me wasn’t sure to use women, ladies, girls or females. Since “Men in IT” is what I would write if this were about men, the feminine noun seems to me to be the correct one.
** Strange, in this case, defining a group of people who will have vitriolic arguments over the formatting of JavaScript, for example.

The Play Framework is now officially an embarrassment

If you’ve read any other entries on this blog, you’ll know that I’m an advocate of the Play! Framework.

As of today, this has changed.

My client is currently in the process of migrating their services to a federated collection of web services. Business metrics are required, and so we needed to look at a logging service. We discussed various options, and my proposal was accepted. We have a few well-defined fields, and service-specific data is logged as a JSON document. The discussion lasted about 25 minutes or so.

I went back to my desk, and wrote the code – a RESTful service, an asynchronous client using Akka, and a front-end in 15 minutes – using Play 2.

Let me spell that out, in case you missed the figures. Implementing the entire solution took 3/5s the length of time of the meeting.

Can you imagine doing that with another web framework, especially in the Java space? Play is, by definition at this point, an embarrassment – it can, should and will make other frameworks embarrassed of what they can offer.

I’m no longer an advocate of the Play! Framework. I’m an unequivocal advocate of it.

Edit: I’ve changed ashamed to embarrassed – ashamed was the wrong word to use, and gave negative connotations.

Sometimes, it’s like the internet never happened – listen and learn, Disney

Ever read Freakonomics? There’s a great chapter on how internet-accessible information drove down insurance premiums massively. The same story can be found in many places – but some companies are apparently completely oblivious to this.

Which is the specific company that triggered this blog post? Disney – Disneyland Paris, to be exact.

On visiting their site, I immediately got redirected to the Belgian version of their website. While my level of Dutch is good enough to deal with this, I do prefer English just for speed of reading so I switched to the UK website. I looked up 5 nights in a specific hotel, 2 adults, 1 five-year-old child, starting August 1st. The resulting price – £1338. Expensive, but about what you would expect from Disney. For comparison, the currency converter at OANDA converts this at today’s rate to €1620.70.

Now, having lived in Belgium for some time, and being acutely aware of how expensive it is, I decided to check out the same deal from the Belgian website. Same people, same date, same duration. The result this time? A jaw-dropping €2306. Since this doesn’t include transport, it would be cheaper for me to drive to the UK, turn around, drive to Paris and have the holiday than just drive 3 hours south and have the same exact holiday. What would Al Gore say about this carbon impact?

This goes completely against the concept that people won’t pay 10 for something when information is freely and easily available that indicates they should be paying 5. It does take into account the inherent laziness of some people, and the fact that some people are unaware of this information. For people who are aware of this info, and are willing to do something about it (i.e. me) it’s a complete insult. It’s also a great incentive to not go to Disney.

Remember, the democratization of information the web has brought doesn’t mean anything if you don’t vote! In the meantime, let’s call this a fail for Disney.

Why Doctor Who sucks, and Tinkerbell rocks

To start, a couple of disclaimers:
1. Growing up, I loved Doctor Who – both the TV series and books. Can’t add anything else to this particular disclaimer – I absolutely loved them.
2. On a similar, yet diametrically opposed, note, I absolutely hated Disney films. I’m not going to go into the reasons, because that would take a long time, but even now whenever a child gets mauled by a dog – I wonder if it happened because the child was trying to get the dog to sing.

Let’s move swiftly on. A few years ago, Doctor Who was revived as a TV show and I was very excited. Then I saw the first episode, and I was somewhat less excited. Excitement diminished every week – there were some excellent stories, typically the ones not written by Russell T. Davies – but there was always something that got in the way of enjoyment.

That fucking sonic screwdriver.

In the older episodes, the Doctor would whip out his sonic screwdriver occasionally. In the new episodes, the screwdriver became a magic wand. What’s the problem with magic? It doesn’t require explanation – it’s just magic.

Also fairly recently, as the father of an amazing daughter*, Disney DVDs entered the family collection alongside uncountable zombie films, 80s John Hughes movies and my treasured Buffy DVDs. Most of them were, well, exactly as I remembered. Some where actually very enjoyable (such as The Little Mermaid), but one set of films has really stuck in my mind. These are the Tinkerbell films.

Specifically, I’m talking about Tinkerbell And The Lost Treasure. In a nutshell, Tinkerbell is given a task that is of vital importance to all the fairies, and requires an extremely rare moonstone. It’s a movie, so of course the moonstone is shattered and she has to deal with the consequences. Most of the movie deals with her travelling to a far-away place to find a magic mirror that will make everything OK again. So far, so Disney.

This, from both a general and technical point of view, is where it starts to get interesting.

She finds the mirror, and manages to screw it up again. Suddenly, there’s no more magic solution to her problem and so she starts using her brain. She designs and implements a solution based on the broken moonstone for the fairy ritual that is far more successful than previous rituals have been. She’s taken the broken pieces of something she’s told has to be whole, and instead of taking what she’s told as the only truth, innovates her way out of the problem.

At a time when the importance of teaching children to program is making (inter)national news, I think a role model that encourages critical and pragmatic thinking trumps one who can zap his way out of any problem with setting xyz of his magic wand.

* And I dare you to prove otherwise :)