Guice 1.0 vs 2.0

The Guice 2.0 contains lots of neat improvements. It removes lots of unnecessary boilerplate and allows to write more compact Guice modules. Here is an example of how a confusing binding can be refactored into a simple provider method.

Example using Guice 1.0:
protected void configure() {
bind(new TypeLiteral<List<string>>(){})

The same example using Guice 2.0:
@Provides @TagsToProcess
public List<string> provideTags(@Named("tags") String tags) {
  return ImmutableList.of(StringUtil.splitAndTrim(tags, ","));


JMock vs EasyMock Smackdown

Lets see which of the two popular Java test object mocking tools is more straightforward. Cast your vote! (in comments)

with jMock
with EasyMock
you need to import

import org.jmock.Expectations;import static org.easymock.classextension.
import static org.easymock.classextension.
import static org.easymock.classextension.
import static org.easymock.classextension.
import static org.easymock.classextension.
your test class needs to extend

in setUp() method

mockedThing = mock(SomeInterface.class)mockedThing = createMock(SomeInterface.class)
to set expectations
new Expectations() {{
// this run does not throw

// expect an exception
will(throwException(new RuntimeException());

// expect multiple runs

// since run() returns void

// or if the method returns non-void

// expect an exception;expectLastCall().times(1).

andThrow(new RuntimeException());

// expect multiple runs;expectLastCall().times(1);

to put into replay mode

// only after this call the mock is usable
to use the mock in tests

RealThing realThing = new RealThing(mockedThing);

// this will call the mocked thing at some point

RealThing realThing = new RealThing(mockedThing);

// this will call the mocked thing at some point

to verify mock

// if you forget this, you will not know if the
// expectations were fulfilled
thread safe

mockedThing is not thread-safe.... use this
to make it so:
makeThreadSafe(mockedThing, true);


Who supported prop 8 is a nice mashup of Google maps and prop 8 supporters. Zoom in to Castro and there he is -- a retired man who donated $300 to support prop 8. Seeing no prop 8 supporters in my neighborhood makes me feel warm and fuzzy about choosing the Mission to be my hood.


Tourist Trap

Per wikipedia:
tourist trap is an establishment, or group of establishments, that has been created with the aim of attracting tourists and their money. Tourist traps will typically provide services, entertainment, souvenirs and other products for tourists to purchase, and these will often be at inflated prices (compared to the local economy).

The first thing we did in Italy was buying 2 train tickets from Fiumicino airport to Termini station. The ticket booth employee charged me 22 euros, took 50 euro bill and returned 18 euros. I asked for the other 10 euro, he looked at me disappointed and gave me my money. It seems like he is making good money this way, as there are many travelers that do not look twice at the change they get.

Another tourist trap we visited was a small restaurant in front of a hotel Alexandra about a block from Barberini square. This small restaurant called Alex cafe had a nice menu, professional looking staff, looking like a good place to eat at. We ordered 5.5 euro tea, 2 salads, some seafood pasta and mushroom risotto. The seafood stunk badly, and risotto was undercooked. We ate the salads, returned the main dishes and asked for a check. We ended up paying 35 Euro (plus tip) for the mediocre salads and a tea and headed out.

We then got an advice from a local who recommended we eat at Trastevere neighbourhood of Rome where locals hang out. We ate there twice, loved the food, ate a lot of it, and always payed 32 euros or less for 2 multi-course meals (salad, mussels, tea, beer, main dishes). The mussels are the best in Rome, they are served in a garlic sauce and they are to die for. The roasted chestnuts sold on the streets are also the best I had. They peel of easily and taste very sweet.


Holiday travel from hell

Warning: lots of bitching in this blog post

After taking off 2 hours later than planned, we arrived to JFK too late to catch our connecting flight to London. No problems, (we thought) there were 2 more flights to London that same evening. First, we had to leave the secure area and come out to a check-in to get our new boarding passes, wait in a long line at the check-in, and then talk to a supervisor (who was overwhelmed by crying customers who apparently do not understand the reality of air travel). To our surprise, it turned out American Airlines booked 150 tickets for 120 passenger plane. 30 people had to stay at the airport all night to hope they can get on the plane the next day, the plane that was also overbooked. The 1 800 number they provided was "helpful"... we called and booked us 2 seats that were (according to the customer service person) definitely available. But the crew at the airport kept insisting that the plane is overbooked by 30 people and there are no seats available. Is this a software bug? Why do they give us conflicting information?

As the airline employee recommended, "come at least 5 hours before the take off tomorrow, so you have better chances getting on the plane". Of course, we had to pay for our hotel, since the flight delays were caused by the weather, not the airlines. The next day, we came to the airport 7 hours early, got our boarding passes and did our best not to go crazy waiting for our flight. Once we got on, we buckled up, and waited. Then we waited little more. And then some more. And then we waited for something to be fixed on the plane, then we waited (according to the pilot) for "some paperwork for the repairs that were just performed", and then we waited "just another 1.5 hours or so for our turn to defrost the wings" and then we waited another 1.5 hours to take off. Total, we were sitting on that plane for 5 hours before we even took off. Wearing 2 days old clothes, praying for the torture to end.

When we arrived to Heathrow, our bags were nowhere to be seen. American Airlines employee had no idea where bags can be, as they are not scanned at every city they fly through. We could fly to a moon in the 60s, and we still are unable to track our luggage in 2008! So there we were, in our 3 day old stinky clothes (slippers, sweatpants and sweatshirts) entering the winter London. We stayed 2 nights in London and did not get our bags. The phone number for baggage claim was not picked up and we left few voicemails. We also called a delivery company that delivers bags for American Airlines and the driver told us that the AA is not picking up calls since too many people are calling and complaining (AA employee told this to the delivery guy). So they are just sitting there, and not picking up calls. What a customer service.

Our bags reached us in Slovakia, at the midnight of Dec 24. We checked in on the 19th, and got our bags after 5 days. This is the 5th time I had my bags delayed. Based on my small sample (I fly few times a year), delayed luggage is more common than the statistics claim.

This picture shows how Brad dried his underwear while staying in London and waiting for his bag to arrive.