Have you failed a job interview?
Send us your job interview questions and get correct answers.

BP156: Do not use "this" keyword

Do not use this. keyword unless you have extremely good reason to do so.

It adds unnecessary noise to the code and the only reason why you probably need to use it in your classes is that you use the same names for private fields and for parameters.

To solve this, prefix private parameter names with underscore. Thanks to this:

  • You can remove this. keyword
  • You can easily figure out whether the field is private or not just by looking at its name (Underscore prefix = private)

Download Better Coder application to your phone and get unlimited access to the collection of enterprise best practices.

Get it on Google Play