I am a fan of Dudo, and recently I am writing a static code analysis tool to
conduct performance analysis for Android apps. I found Internal Getters/Setters
in Dudo's code.
As suggested by Android Developers,"In native languages like C++ it's common
practice to use getters (i = getCount()) instead of accessing the field
directly (i = mCount). This is an excellent habit for C++ and is often
practiced in other object oriented languages like C# and Java, because the
compiler can usually inline the access, and if you need to restrict or debug
field access you can add the code at any time.
However, this is a bad idea on Android. Virtual method calls are expensive,
much more so than instance field lookups. It's reasonable to follow common
object-oriented programming practices and have getters and setters in the
public interface, but within a class you should always access fields directly."
We found the violations in these class:
Class name: com.caverock.androidsvg.SVGAndroidRenderer
--Handler name:
com.caverock.androidsvg.SVGAndroidRenderer.updateStyle(Lcom/caverock/androidsvg/
SVGAndroidRenderer$RendererState;Lcom/caverock/androidsvg/SVG$Style;)V
--Called inner Getter or Setter:
com.caverock.androidsvg.SVGAndroidRenderer.getCurrentFontSize()F
Class name: net.margaritov.preference.colorpicker.ColorPickerDialog
--Handler name:
net.margaritov.preference.colorpicker.ColorPickerDialog.updateHexLengthFilter()V
--Called inner Getter or Setter:
net.margaritov.preference.colorpicker.ColorPickerDialog.getAlphaSliderVisible()Z
--Handler name:
net.margaritov.preference.colorpicker.ColorPickerDialog.updateHexValue(I)V
--Called inner Getter or Setter:
net.margaritov.preference.colorpicker.ColorPickerDialog.getAlphaSliderVisible()Z
--Handler name:
net.margaritov.preference.colorpicker.ColorPickerDialog.setAlphaSliderVisible(Z)
V
--Called inner Getter or Setter:
net.margaritov.preference.colorpicker.ColorPickerDialog.getColor()I
--Handler name:
net.margaritov.preference.colorpicker.ColorPickerDialog.setHexValueEnabled(Z)V
--Called inner Getter or Setter:
net.margaritov.preference.colorpicker.ColorPickerDialog.getColor()I
Class name: com.caverock.androidsvg.SVG
--Handler name: com.caverock.androidsvg.SVG.getViewList()Ljava/util/Set;
--Called inner Getter or Setter:
com.caverock.androidsvg.SVG.getElementsByTagName(Ljava/lang/Class;)Ljava/util/Li
st;
Although I admit that it is a minor issue, but I sincerely hope that it can
help you to improve Dudo.
You may find more useful information in this references:
http://developer.android.com/training/custom-views/custom-drawing.html
Original issue reported on code.google.com by winson...@gmail.com on 2 Apr 2014 at 6:38
Original issue reported on code.google.com by
winson...@gmail.com
on 2 Apr 2014 at 6:38