Wednesday, April 10, 2013

Android C2DM to GCM

I'm trying... really trying to be nice, to give these guys a chance, but boy, they have done it this time...

Long ago, I've implemented a C2DM Module for Cyborg in less than a day, which was elegant tight, and generic... and a few(3) weeks later, Google has announced that C2DM is dying, and now there is GCM... terrific...

Since I'm short on time, I've implemented a GCM Module for Cyborg, happily using the gcm.jar, and its updates every now and again.

Today, I've actually looked at the code of the gcm.jar, and I was shocked, shocked to find out that this code violates nearly all of my basic coding conventions, this is a sort of code I would have written when I've just started to work with Java, and have tried then to challenge the language conventions.

I've been dealing with very bad code for the last years, but this... I cannot make heads or tails of it...
It is noodles all over the place, using too many static methods and members calling back and forth mixed with broadcast receivers and services all together throwing a swingers party... it is bad Java, mixed with bad Android, if Java could have spoken, it would have shouted "RAPE !!!", it is shamley unbelievable.

This is crazy, I know that "Anyone can cook", but would you actually eat anyone's cooking?
I'm expecting more from you Google!

I'm now in the middle of getting rid of this darn jar file, and I see that the basic registration to the GSF service remained practically the same, they have simply mapped some errors and some use cases, with nasty(ing) if statements.

...
After 2 days...
...

I've finally managed sending a GCM from a device to itself via my server, I've used my JSONer to serialize the and deserialize the JSON, and was surprised to discover that the actual GCM payload MUST be JSON Array...

WTF?

If you already force something, force it to be a JSON Object, and let the people use whatever stupid implementation they want within that object.

Force the payload to be an JSON Array, and to add a key - value extras in the intent which derived from the array... it is an unnecessary overhead!!

Any logical application would use a JSON Object as the payload, and use GSON or any other parser to serialize and deserialize the payload.

No comments:

Post a Comment