Categories
Technology

"this" is no good!

Eric Burke has a very sound advice against using “this” in your Java code, an advice against the conventions. Prefixing object field references with “this”, says Eric, clutters up code and may indicate too much complexity. “If you really need to differentiate local variables from object fields, consider prefixing your object fields with “_” or some other character (instead of using this)”, he opines. I couldn’t  agree with him more on the following:

Don’t blindly follow conventions for the sake of following conventions. Follow conventions because they improve your code. If the coding convention encourages repetition, increases clutter, and relies upon human consistency to be effective, maybe the convention is flawed.