nael-lilik / mconf

Automatically exported from code.google.com/p/mconf
0 stars 0 forks source link

Remove the internal getter and setters #82

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
based on this coment on the Android Designing for Performance topic is better 
tu use getters and setter just between the classes, not internally

"Avoid Internal Getters/Setters

In native languages like C++ it's common practice to use getters (e.g. i = 
getCount()) instead of accessing the field directly (i = mCount). This is an 
excellent habit for C++, 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.

On Android, this is a bad idea. 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.

Without a JIT, direct field access is about 3x faster than invoking a trivial 
getter. With the JIT (where direct field access is as cheap as accessing a 
local), direct field access is about 7x faster than invoking a trivial getter. 
This is true in Froyo, but will improve in the future when the JIT inlines 
getter methods."

http://developer.android.com/guide/practices/design/performance.html

Original issue reported on code.google.com by ale.lion...@gmail.com on 10 May 2011 at 2:06

GoogleCodeExporter commented 9 years ago

Original comment by fceca...@gmail.com on 10 May 2011 at 7:58

GoogleCodeExporter commented 9 years ago

Original comment by ale.lion...@gmail.com on 18 Jul 2011 at 6:48

GoogleCodeExporter commented 9 years ago
What do you think about create a wiki page to describe the "Best practices" for 
our project, and move this and others issues to there?

Original comment by fceca...@gmail.com on 7 Aug 2011 at 11:45

GoogleCodeExporter commented 9 years ago

Original comment by fceca...@gmail.com on 5 Sep 2011 at 2:57