android - Java Best Practice: nested getters? or delegates? -


no doubt n00b question, appreciate guidance or link.

i writing android game app, includes plenty of interaction between activity , other classes. in doing so, i'm not sure better practice example calling "updateplayer" method.

choice chained getters, might have in myactivity:

mgame.getplayerlist().getcurrentplayer().updatescore(score); 

choice b delegation (hopefully using term correctly):

mgame.updatecurrentplayerscore(score); 

then in game:

playerlist.updatecurrentplayerscore(score); 

then in playerlist:

currentplayer.updatescore(score); 

i can see advantage of choice b because free change structure , behavior of playerlist , game, sure adds lot of one-line methods.

am thinking corrrectly? there choice c or d?

personally i've thought coding styles matter of opinion. if coding works , simplest you. example in java name variables in camel case (intvar) in python use underscores (int_var). wouldn't matter if used underscores in java , camel case in python in independent environment.

however...

in place people must read , understand code, i'd try follow conventional coding styles as possible clarity.

for scenario, ever floats boat. traditionally getters , setters accepted coding style java.

extending classes might on not showing implementation of higher level classes.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -