0

In one presentation deck of Reto Meier, I read his suggestion to prefer virtual methods over interface but there were no more explanation. Apart from the runtime overhead is there anything else which specifically hurts app performance in android ? Because to make code more flexible and readable I heavily use interface in my android project.

Jeevan
  • 8,532
  • 14
  • 49
  • 67
  • 3
    http://developer.android.com/training/articles/perf-tips.html References what you were talking about. That being said, using interfaces shouldn't hurt any typical application by a noticeable amount. This is especially true in 2.2 and above since JIT makes a significant difference in speed overall. – Justin Breitfeller May 22 '13 at 19:08
  • Are you creating a Game or some heavy data processing? If not why are you concerned about that. If you are on the other hand doing something heavy, it is better to design your code at the beggining then to optimize it later. – Marko Lazić May 22 '13 at 19:09
  • 1
    http://stackoverflow.com/questions/2637377/in-java-is-there-a-performance-gain-in-using-interfaces-for-complex-models – Bush May 22 '13 at 19:10
  • "On devices without a JIT, it is true that invoking methods via a variable with an exact type rather than an interface is slightly more efficient" – Diego Torres Milano May 22 '13 at 21:30

1 Answers1

3

The performance cost with today's devices is insignificant. This advice was for the devices of 4 years ago like the G1, who had much slower CPUs. Make your code more readable and maintainable, and don't bother with this type of optimization

yoah
  • 7,180
  • 2
  • 30
  • 30