This is a migrated thread and some comments may be shown as answers.

[Solved] this. is used when not really needed

2 Answers 84 Views
Code Generation
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrei
Top achievements
Rank 1
Andrei asked on 05 Jul 2012, 07:33 PM
Hi guys,

One of the (annoying) things that I'd like to mention is a usage of this. prefix when dealing with fields that are initialized from a constructor. You see, I prefer a style when private fields are named like _field and when initialized from a constructor there is no need to put this. to identify the field. However, JustCode always does it, either when you want to add initialization of already present fields to the constructor or when you want to add an initialized field to a class after you add a new parameter to the constructor.

JustCode has a setting about this. however all you can set is ''Only if necessary' ' which makes sense of cource if you use another naming convention when your fields don't have an underline and their names can collide with those you use as parameters to constructors or methods.

So I think this 'Only if necessary' option should be a bit polished to be able to identify various cases when it's not really necessary to use this.

2 Answers, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 06 Jul 2012, 02:52 PM
Hello,

Thank you for your feedback. I tried and was able to reproduce your issue.
The "'Only if necessary" option means that "this" qualifier will be added only if the member identifier equals the identifier of the parameter identifier.
So "this" qualifier should not be added in your case where you have "_i" as a field identifier and "i" as a parameter one.
We fixed this issue and the fix will be included in our next internal build.
Thank you for your help!

Kind regards,
Ivan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Leon
Top achievements
Rank 1
answered on 05 Dec 2012, 12:26 PM
As per my experiments on "This. " function it is useless if we put into query where we have to identify a single word. Because it can be search by simple other coded functions too.

Tags
Code Generation
Asked by
Andrei
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Leon
Top achievements
Rank 1
Share this question
or