java – Android: should you strive to minimize the number of characters in names and identifiers?

Question:

Should we strive to minimize the number of characters in identifiers and resource names in order to increase performance and reduce the memory footprint?

Here's an example of line names ranging from the longest but understandable to the shortest but challenging to think about what that means:

  • string name="menu_item_set_everyday_tasks"
  • string name="menui_set_everyday_tasks"
  • string name="menui_seteverydaytasks"
  • string name="menui_setevrdtasks"
  • string name="setevrdtasks"
  • string name="setevrdtsks"

Of course, this discussion is meaningful when we have in one application on the order of several hundred IDs, string resources, etc.

Answer:

There is no need.
XML resource files do not appear in the compiled code in their pure form. Instead, the development environment automatically converts string names to numeric identifiers and places them as static numeric constants in the R.java class. Numeric variables, as you know, occupy a fixed number of bytes.

More details, for example, here: http://developer.alexanderklimov.ru/android/theory/resources.php#string

Scroll to Top