Tag Archives: wtf

Some more Android development peculiarities

There is a baked in logging class called, intuitively, Log. For some strange reason the authors chose to name its methods, most of them, with one letter. That is :

Log.d(..); // debug level
Log.e(..); // error level
...

Until you hit

...
Log.wtf(..);
...

This one’s funny and I appreciate their sense of humor as it goes up to renaming WTF to “What a Terrible Failure”. Like we’re so dumb that we can’t figure what they really had in mind 😛

Another peculiarity is that in an activity (this akin to a Page / Form / whatever) you have some methods that you can/should override such as onCreate(). Everywhere is stated that the first thing you should write in the overriding method is a call to the super (that is base) class’s method. If it is really all that important and vital why didn’t the class designers go with a template method in first place?

That is a design pattern, that in this case, would go like so :

public class Activity {

    // ...

    private void onCreateInternal(Bundle savedInstanceState) {
        //vital stuff
        onCreate(savedInstanceState);
    }

    protected void onCreate(Bundle savedInstanceState) {
    }

    // ...

}

Take note of another difference between C# and Java : the methods and classes are virtual/unsealed by default. So the onCreate method in my example above is overrideable in any subclass. Also in Java terminology the base class is called the superclass.

Other differences of terminology include :

  • A namespace is called a package
  • By default an import (which is akin to a using directive) imports by default just the specified type and not the whole package (namespace). You need to use a wildcard to import the whole package
  • The closest thing to an assembly is called a JAR (Java ARchive).
  • Eclipse by default is set to autocompile. That is whenever you hit CTRL-S (Save) to a Java file the project is (re)compiled. This sounds terrible but it isn’t! You can’t even notice. Either there is an incremental compilation either the performance of the compiler is incredible.
  • Unlike Visual Studio, Eclipse presents the import block collapsed by default. I wish I had this in VS… Just like a mobile app fan would say “there’s an app for that”, I bet for VS “there’s a plugin for that” 😛
  • In Java if you want to call the super (base) class’s constructor from the current class’s constructor you will write “super(…);” in the constructor’s body. When I first saw this I said to myself Fu-Kin-Su-Pa (er… “great”, that is). “Now I have the liberty to call the base/super constructor from wherever inside the constructor I want”. Well, no. It’s either the first line or it isn’t.

Well, I’ll rant more as I go learning Android development.

My goal is to get to know enough so I can do it in Xamarin via C# but first I must understand the underlying things in order to go a level of abstraction above.

In the next episode(s) : I am indebted with a follow-up from my presentation held at RONUA last year.

How not to build an online flight booking site

I had a rough experience a few days ago while trying to book a flight for my upcoming holiday. I … no, we, chose TAROM (site link here).

What happened, in short, I started to book the flight, filled-in all the flight details, got to the point where I need to provide the billing details (card number etc.), pressed next and then… “session expired, please start over again”. For a moment I checked my bank account. Sure enough they took the money and offered me just an error. No email, no nothing.

After 1 hour and something, I finally got to customer service representative who manually issued the tickets which couldn’t have been issued by the site. (Meanwhile I found out how hard is to cancel a payment from your bank to a rogue vendor).

In the end things got fixed but a bitter taste persists towards this TAROM operator. Anyway I tried to understand what went wrong in the process, IT-wise and this is what happened, I think :

  1. The site gathered all the flight details from the sucker customer (me)
  2. The site then asked for the billing info
  3. Tried to bill me and succeeded
  4. Tried to book the flight and failed (the session expired in the meanwhile)

From this short analysis a few WTFs have emerged :

  • Why did they chose to have an absolute-date expiration policy for the session? (i.e. the session expires precisely 10 minutes after you start the booking process, no matter how many or how frequent you do further requests
  • Why didn’t they leave the billing step as the final step?

Having had to put up with Romanian services for the last three decades I’ve learnt that the most probable reason for these WTFs is this :

Why? Because FUCK YOU! that's why..

Leaving the funny thing aside I suppose the ‘architects’ that built TAROM’s site (hope the plane doesn’t crash like the site) thought that it’s better to have the money in the bag and then see if all else went ok… or maybe they thought of a situation where many people would try to book few tickets? Or who knows…

What do you think dear reader?