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.

By Debashish Chakrabarty

Debashish Chakrabarty, a Software Consultant based at Pune, has been on the Internet since the “geocities” days but opened his Blogger account in October 2002. Apart from this blog he also maintains a Hindi blog NuktaChini.

One reply on “"this" is no good!”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.