Posts Tagged ‘Just-in-time compilation’

Screenshot of Android Emulator for SDK version...
Image via Wikipedia

The debate of using Dependency Injection  in Android has always been half-assed in a way. First, some background.

On Mobile initialization is the bottleneck as opposed to Enterprise where the application is started once so we do not care about initialization times. In dependency injection there is an initialization setup penalty.

People have argued that that setup penalty means avoid DI. One counter has been use singletons-by-choice(a former NextStep pattern..yes its one of the coding patterns in iphone dev). However, the use of synchronized in such a pattern means you have the same penalty of initialization that you have if using DI and only occurs for the classes you have designated singleton-by-choice.

Does a singleton-element enum have the same initialization penalty? Its probably greater as we are warned as Android Developers not use enum in our SQLite ORM coding as its very slow.

My thinking is that since Android 2.2 onward has a JIT that we no longer have these concerns and now have a choice of DI, singleton-by-choice, singleton-element enum, and even can implement a real MVC framework. Will the start-times matter for those pre-Android 2.2non-JIT devices?  I do not think those devices will be around that much as a market percentage in the next 12 to 18 months. I think we can use l the patterns rather than quibble and claim oen pattern is the miracle worker as opposed to having all those patterns in one’s toolbox.

The only aspect where the choice becomes important is in testing and unlike several months ago we now have some mock frameworks becoming available for android such as android-mock which evens the playing field as you could use all the above patterns.

Enhanced by Zemanta
Advertisements