5

In Android documentation there is an article about "Performance Tips" that recommends avoiding theuse of internal getters/setters. A recent publication in the MOBILESoft 2016 conference agrees with this recommendation.

However, according to the lint documentation:

As of Android 2.3 (Gingerbread), this optimization is performed automatically by Dalvik, so there is no need to change your code; this is only relevant if you are targeting older versions of Android.

Is there any official and updated information regarding this?

Luis Cruz
  • 393
  • 1
  • 14
  • 1
    According to this answer from "Ben, one of the engineers working on the JIT @ Google" http://stackoverflow.com/questions/4912695/what-optimizations-can-i-expect-from-dalvik-and-the-android-toolchain/4930538#4930538 you don't need to worry about using internal getters/setters starting from Android 2.3 (Gingerbread) – antonio Jul 14 '16 at 14:37
  • Android has a limitation of 64k methods (in total of all classes of your app) per dex file. Therefore saving unnecessary methods may make sense if your app grows larger. – Robert Jul 14 '16 at 17:57

1 Answers1

0

I can't give my opinion about the publication, but I think this can support what lint documentation says.

My own guideline is prefer clean code / structure (in this case if you don't use getter/setter, you might have code duplications scattered across your classes and makes changes would be hard because you need to do it in some places) rather than micro performance improvement.

Community
  • 1
  • 1
whdinata
  • 61
  • 5