Remember the rant about
bright kids with
no experience?
Well, turns out, experience is something you *do* get, but sometimes right after the world laughs in your face. And sometimes even that is not sufficient.
Consider, for example, the
SensorManager. Consider how it is a concrete class, and there is no way for you to provide *your*
mocks to develop an application, unless you add an extra abstraction layer. And how you have to come up with an
abomination (see line 81) to fight it?
And how much simpler would it be if they just made
SensorManager an interface and made
getSystemService() return a concrete implementation?
But I have a hunch that we're stuck with it - it didn't change from Android 1.0 to 4.0.3.
Wonder how many jewels like this are there in Google's APIs.
PS: It is not a fault of
OpenIntents' guys that they had to create this abomination, they did the only thing they could under the circumstances - kids at Google didn't leave us any other choice.