Open GoogleCodeExporter opened 9 years ago
The idea behind this is to get rid off a simple initialization in constructor
(like 'mField = field;') and retain only the meaningful parts.
Original comment by alarmo.l...@gmail.com
on 14 Jan 2015 at 1:45
Not quite sure I get what you mean here. For every field where we wold have
generated 'this.fieldName = argName', we should instead invoke
'setFieldName(argName);' if the setter exists?
Calling setters from the constructor is not exactly great coding style; the
object hasn't actually been initialized fully yet. But it's a common enough
pattern, I suppose.
Original comment by reini...@gmail.com
on 31 Jan 2015 at 3:57
"For every field where we wold have generated 'this.fieldName = argName', we
should instead invoke 'setFieldName(argName);' if the setter exists?"
Yes, that's what I mean.
There was many fields (in SimpleRecyclerViewAdapter), that could be simply
initialized in a constructor and a single field (mBaseAdapter), that required a
complex initialization process. Because of it, I couldn't use @RequiredArgs
annotation to hide this constructor.
"Calling setters from the constructor is not exactly great coding style"
I understand. To prevent bad things from happening, we could check that the
setter is 'final', and forbid usage of 'useSetters=true' if it's not.
(
http://stackoverflow.com/questions/8501735/using-setter-methods-in-constructor-b
ad-practice )
Original comment by alarmo.l...@gmail.com
on 2 Feb 2015 at 2:09
Original issue reported on code.google.com by
alarmo.l...@gmail.com
on 14 Jan 2015 at 1:38