all that jazz

james' blog about scala and all that jazz

Google Chrome

When I first heard about Google Chrome, I was very skeptical. Why does this world need another browser to contend with in producing cross browser websites? If open source is what you want, what's wrong with Firefox? So I had to read the Google Chrome comic, and I must admit, it has got me excited. But there is one feature in there that has got me concerned.

Google has suffered a large amount of criticism over the years in relation to privacy. From keeping information on your searches indefinitely, to reading your email, and most recently, getting too close for some with Street View.

One feature that intrigued me in Google Chrome is its location bar searching. It's very cool, it goes above and beyond the recent trend of other browsers to offer past url's based on title searches, it supports full text searching of pages you've visited. But, it also offers suggestions of popular pages that you've never visited. This is cool and convenient, but what does it mean? Everytime you type something into your address bar in Google Chrome, those words get sent to Google. This means that even without using Google's search directly, they can still see what you are typing into your address bar, and most users won't realise it. While that scares me a little, I'm more interested in seeing how the critics will respond to that, are Google up for another onslaught of bad publicity over privacy?

RIP #herring

#herring, the long standing meeting place for many of ANU's 2004 software engineering graduates, has passed away. Born in 2002, on the Australian IRC network oz.org, #herring has been a lively channel for keeping in contact, arguing about meaningless topics, and a nice distraction from a busy days work. #herring, the solid backbone of a friendship group, you will be missed.

JPA 2.0 - Early Review

A few days ago, JSR-317, the specification request for JPA 2.0, released an early draft review of the specification. Today I had the chance to skim through it to see what new things it had to offer.

Something I commented on in an earlier blog post was how they might implement deleting orphan members of an association. Would they follow TopLink's private collection mapping, or use Hibernate's additional delete orphan cascade type? It turns out, they chose neither... or rather, they met half way. The EDR specifies the addition of a boolean orphanRemoval attribute on the @OneToMany and @OneToOne annotations. So the terminology follows the Hibernate orphan terminology, however hibernate uses a DELETE_ORPHAN cascade type. The method though is more similar to TopLink, which has private ownership as a property of a collection mapping.

I don't think that I like this way of doing it. I don't think it's consistent, if I want a new entity to be persisted just by adding it to a collection, then I specify cascade=PERSIST. But if I want an existing entity to be deleted just by removing it from a collection, then I specify orphanRemoval=true. Cascading persistence to members added to collections and removing orphaned elements are both similar operations, in that they indirectly change the life cycle state of an entity, that occur at flush time, in a cascade like manner. I think it would be more consistent to say cascade=ORPHAN_REMOVE. The expert group has made a note in the EDR asking for input on which strategy they should use.

Fair Trade Coffee in the Sydney CBD

I've chosen the title of this blog post very deliberately because I want people who are looking for fair trade coffee in the Sydney CBD to be able to find something when they search Google for it.

Fair Trade Logo

I started working in the city a week ago, and one of my first tasks has been to find a coffee shop that sells fair trade coffee. Of course, there are the big chains, including Starbucks, which incidentally is participating in fair trade fortnight in May, and Jamaica Blue, with its fair trade blend. But neither of those is really that close to my office, and I've never really liked the coffee from the big chains as much as I do from the small cafes. So I did a search in Google to see what I could find.

I was quite disappointed. I couldn't find any lists of cafes anywhere, apart from the Oxfam website, and the Fair Trade Association website. And the only cafes in the CBD they had were Starbucks and Jamaica Blue.

After searching a little harder, I found the voodoo coffee company, which supplies a number of cafes in the Sydney CBD, and they have a fair trade blend. I've emailed them asking them which stores they sell fair trade coffee to, but I read that on occasion, Pulse Cafe on Kent Street (right near my work) has sold the fair trade blend.

Does anyone know of any other cafes in the Sydney CBD that sell fair trade coffee?

Update

I tried out Pulse this morning, and found that they only sell fair trade coffee. Not only that, but the coffee was really good, and only $2.50. So my mission is accomplished. However feel free to add comments of other fair trade coffee places you know of so we can make a comprehensive list.

JSR-666 Extension: Significant whitespace

In many software development teams that I've worked on, code reviews are done by printing out the code to be reviewed. This is in turn read and scribbled on with red ink by developers suffering from a delusion that their coding standard is better than mine. An example of some such code:

public boolean equals(Object o)
{
   try
   {
      if (Calendar.getInstance().get(Calendar.MONTH) == 1
            && Calendar.getInstance().get(Calendar.DATE) == 29)
      {
         return true;
      }
      else
      {
         Thread.sleep(10000);
         return new Random().nextBoolean();
      }
   }
   catch (Throwable t)
   {
      // Something must have gone wrong, try again
      return new Random().nextBoolean();
   }
}

When reading the above code, the obvious problem that jumps out is that it contains no less than ten curly braces. When printed for a code review, this is a waste of valuable ink. The squids of the world have been working overtime to provide the ink needed to print out all the code that needs to be reviewed, it is about time we gave them a break. I'd therefore like to propose to the JSR-666 expert group an extension that curly braces be replaced with significant whitespace.

The previous code example would become:

public boolean equals(Object o)
   try
      if (Calendar.getInstance().get(Calendar.MONTH) == 1
            && Calendar.getInstance().get(Calendar.DATE) == 29)
         return true;
      else
         Thread.sleep(10000);
         return new Random().nextBoolean();
   catch (Throwable t)
      // Something must have gone wrong, try again
      return new Random().nextBoolean();

A fine piece of code that would pass any code review.

This feature will also solve a number of other problems, for example, it will eliminate the age old argument over whether braces belong on a newline or not. It will also force developers to write neatly structured code.

This feature will not require any JVM changes, but will require compiler changes. Existing code may need to be changed, however, if the existing code was well formatted to begin with, it should suffice to simply run the following command in vim:

:%s/\{|\}//g

About

Hi! My name is James Roper, and I am a software developer with a particular interest in open source development and trying new things. I program in Scala, Java, Go, PHP, Python and Javascript, and I work for Lightbend as the architect of Kalix. I also have a full life outside the world of IT, enjoy playing a variety of musical instruments and sports, and currently I live in Canberra.