Wednesday
Feb182009

The Day Before

Today is the day before I get my first SLR camera -- Nikon D60. I am anxiously awaiting the little gem of technology to arrive tomorrow. If it won't come, Petiatko will be very very sad.
I will put it to use this Friday, at the next Photo Friday which we plan to do at the museum (after hours). Stay tuned for more about my little D60. Any suggestions on how should I name this new baby?

Tuesday
Feb172009

Economics in One Lesson

Henry Hazlitt wrote this book more than 30 years ago and it still keeps selling. I loved hearing (this was an audio book) his rants about bureaucracy, and wished I heard this book before my previous post.

Basically, Henry points out that every government intervention into the natural flow of the economy causes more harm than good and hurts the economy beyond what we usually imagine. He explained this on a number of examples:

  • you never get anything for nothing => if you give money to some group, it means you took it from some other group, thus discriminating that other group
  • cost of armed forces during the war and during the peace => army employees are living on money we (taxpayers) earned by being productive and yet they are not producing anything => as a result the whole country is less productive
  • impact of the controlled rent and its impact on the housing industry => builders not incentivised to build in areas with controlled rent, landlords unable to maintain and often abandon their buildings => people not utilizing the space economically (to keep the apartment, they are less likely to move into a more appropriately sized apartment as their families grow or shrink) => other people unable to live in the location with controlled rent since all apartments are taken (lack of price bidding for the space)
  • worker unions and minimum wage rules => demanding wages higher than is the market price of their work => results in shrinkage of businesses and higher prices of products => results in less money in people's pockets => results in less money spent => results in less businesses coming to existence
  • import tariffs => forcing higher than free market price => making Americans pay more for the same item (eg: sweater) compared to the imported one => results in helping one American industry (such as sweater makers) at the expense of many other industries (where people would have spent their extra money which would be the sweater cost minus tariff)
  • over-taxing people == forcefully taking money people earned and giving them to the groups with the best lobbyists. This is not to be confused with the taxing that is necessary to keep the society protected (firefighters, police), organized (judges, DMV), etc.
  • import equals export => increased import means increased export and vice versa. There is no way we can only increase export, since we would end up with too much foreign currency which we can not use in the US.
  • impact of fixed under-market pricing => more demand for cheap items => but less companies interested in producing goods that sell at a loss
  • other harmful effects of bureaucracy
Why isn't this book a required high school reading?

Sunday
Feb082009

Peace on you!


I am planning to travel with Fluffy later this year, and was excited to fly through one of my favorite and very efficient airports -- Munich Airport. I could not find any information about animal relief areas at this airport, so I sent an email to their customer service folks who replied that there are no animal relief areas at any of their terminals. Apparently, I have to leave the security area to get outside of the airport if my pet (who would be already eager to pee after waiting for 2 hours before flight + 12 hours of the actual flight) needs to go. I am very disappointed. I will probably end up finding a large planter in one of the airport halls and encourage Fluffy to water the indoor plants. Peace on you Munich Airport!

Sunday
Feb082009

Getting Rid of Flakiness in GWT RPC Tests

To avoid flaky RPC testing in GWT tests, use fake service implementation which you inject directly into the constructor of your custom widget. There will be no delays, and you will be in complete control.

with real servicewith injected fake service
public void testSomethingHappened() {
CustomWidget w = new CustomWidget();
w.doSomethingThatTriggersRpcCall();

Timer timer = new Timer() {
public void run() {
assertTrue(widget.somethingHappened());
finishTest();
}
};
timer.schedule(200);
delayTestFinish(500);
}

public void testSomethingHappened() {
Service fake = new FakeService();
CustomWidget w =
new CustomWidget(fake);
w.doSomethingThatTriggersRpcCall();
assertTrue(widget.somethingHappened());
}

Tuesday
Jan272009

Populating Test Data for GWT Tests

Sometimes you need to test GWT code that expects to find data in the data store. This approach might work:

In gwtSetUp() create the data (someData) you want to persist and call persist(someData) which would look like the following:

/** Helper method to put data into data store prior to test run. */
private void persist(SomeThing someData) {
SomeServiceAsync someSvc = GWT.create(SomeService.class);
AsyncCallback callback = new AsyncCallback() {
public void onFailure(Throwable caught) {
fail("unable to store test data");
}
public void onSuccess(Boolean success) {
if (success.equals(false)) {
fail("unable to store test data");
}
}
};

// Make the call to the test service impl, passing in the callback object.
// This is the same method you defined in the SomethingService interface
// that extends RemoteService and this method needs to be implemented in
// SomethingServiceImpl
someSvc.saveSomething(someData, callback);

// Wait for it to persist.
// Using Thread.sleep(200) would give compile errors.
// Use gwt.user.client.Timer instead.
Timer timer = new Timer() {
public void run() {
}
};
timer.schedule(200);
}