Jez Higgins

Freelance software generalist
software created
extended or repaired


Older posts are available in the archive or through tags.

Feed

Follow me on Twitter
My code on GitHub

Contact
About

Wednesday 16 October 2013 The Forest Road Reader, No 98

Digging around trying to work out if I had a chunk of dead code I could remove, came upon

    if (1==1) {
      throw new UnsupportedOperationException("GetSellersFromSales has not
been properly tested and should not be used until it has been.");
    }
That's that question answered, I guess.

Is it cycling infrastructure? Is it bollocks. The neolegism for this kind of thing is farcility. I've ridden through this particular example myself. Happily, there was no one else around at the time.

Continuing to delve into old, old Java, pruning away the thought-it-might-be-useful-but-not-actually-used-stuff, and dragging the what's left into a more modern age. The code I'm working with has a great many methods that return arrays of objects. The main reason, as far as I can see, is because much of the code predates generics so it's a mechanism to return a pile of objects with their correct type. I've been converting all those methods to return either List<T> or, preferably, Iterable<T>. In almost every case this is straightforward, especially when the returned array was used in a loop -

  SomeType[] things = r.getThings();
  for(int i = 0; i != things.length; i++) {
     SomeType thing = things[i];
     ...
  }
First move is convert to a for each loop -
  for(SomeType thing : r.getThings()) {
    ...
  }
Then we can swizzle the method return type. In every case I encountered in this code, the array was being created using List.toArray, so refactoring the method was trivial.

Mapping London's Cycling Census Dataset. Fascinating. And not just cycling - looks like you really can't get a cab sarf o'the river.

Another Java "modernisation" guideline, although it's not completely language specific is if you only have one implementation of an interface, it's probably okay to bin the interface and just go with the implementation. An interface with one implementation isn't abstracting anything. It might be a quirk of this codebase and of my way of working, but I've found the code easier to reason about without redundant interfaces cluttering up the place. Because Java requires all methods to be public, it can be easier to identify methods which aren't used or which can be private if you pull back to a class.

A corporate outing! Four meeting invitations (all with the same details), one meeting cancellation, and an email saying ignore the cancellation. So far.

To the barricades!


Tagged cycling, and java


Jez Higgins

Freelance software generalist
software created
extended or repaired

Older posts are available in the archive or through tags.

Feed

Follow me on Twitter
My code on GitHub

Contact
About