patternjavaModerate
Arguments in constructors matching fields
Viewed 0 times
constructorsargumentsmatchingfields
Problem
What is your opinion in arguments in constructors matching members as in the following example
I find this annoying since I have to use
public Join(final int parent, final TIntHashSet children) {
this.parent = parent;
this.children = children;
}I find this annoying since I have to use
this. and also some code review applications generate warnings.Solution
I've personally always found the
_parent or Hungarian-notation letters at the beginning far uglier than just saying this. this is very straightforward, especially if somebody else is reading your code. If I inherit somebody else's code and they use _ I change it immediately.Context
StackExchange Code Review Q#471, answer score: 12
Revisions (0)
No revisions yet.