Donnerstag, 6. Februar 2014

Making a case for android.app.Application

In the documentation of android.app.Application it says:
There is normally no need to subclass Application. In most situation, static singletons can provide the same functionality in a more modular way. If your singleton needs a global context (for example to register broadcast receivers), the function to retrieve it can be given a Context which internally uses Context.getApplicationContext() when first constructing the singleton.
But is that right? Or it there is a case for android.app.Application?

Samstag, 25. Januar 2014

enum and switch in Java

Here we go again:

 error: variable Wait_Time might not have been initialized
               this.wait (waitTime);
                          ^
Of course the variable is initialised. It's a switch/case over an enum with all possible cases covered. And sure as hell when I add a default case I get:

        'default' branch is unnecessary

But this is what you get when a programming language was under engineered in it's beginning. Recently there is a lot of discussion on over engineering and the problems it gives you. But trust me: under engendering is as bad.

So which evil to choose to get around the problem … Wait … not a question at all: You can disable warnings but you can't disable errors.

Opera 15 and bejond