methods - How far should I go to avoid internal getters/setters within a class -


i have more of "how much" question. have java class defines several getters/setters use external classes (about 30 altogether). however, java class requires use of these variables in cases.

i understand concept of using member fields instead of getter methods within class, getters in case perform function (unmasking integer specific) create value returned.

so performance , memory reduction perspective, few calls within class need values, i'm curious if should...

a. call getter

b. unmasking wherever need values throughout class, getter

c. create variables hold values, load these calling getters on startup, , use within class (30 or integers may not serious memory risk, need add code keep updated if user sets new values...since value updated , masked).

any thoughts appreciated!

a) call getter - pointed out it's right , clean way in case.

b) , c) premature optimization , more harm (unless know particular spot hot spot in code , jit-compiler not able optimize you).

if hit performance problems @ point, profile application , optimize hot spots manually.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -