
 That Iterator Again - wglb
http://www.tbray.org/ongoing/When/201x/2010/04/18/Content-Provider-Redux
======
jimbokun
More like this please.

I really like Bray's style of trying something, posting it on the Internet,
letting the Internet tell him how he is doing everything wrong, then
summarizing the responses about how to do it right (or explain why he's going
to continue to do it wrong, like in this case where for his case the
performance impact just doesn't matter). His Wide Finder series followed the
same formula.

With regard to the content, I like to use reflection when I'm marshalling
objects into and out of some serialization format. The most recent example is
marshalling Java-Beanish objects into JSON in response to AJAX calls. I figure
with the overhead of serializing everything to a String, and pushing those
bytes across a network, the reflection hit won't be perceptible.

I also like Jerome Lacoste's solution keeping the Iterator interface but
dumping the reflection.

<http://github.com/lacostej/android-providerhelper/>

"We get almost best of both world:

* good performance (almost no reflection) * code easy to read."

------
RodgerTheGreat
Using reflection really hamstrings the JVM JIT- This stack overflow thread
corroborates the "factor of ten" figure, in this case for object
instantiation: [http://stackoverflow.com/questions/435553/java-reflection-
pe...](http://stackoverflow.com/questions/435553/java-reflection-performance)

