this. is used when not really needed

Thread is closed for posting
3 posts, 0 answers
  1. Andrei
    Andrei avatar
    30 posts
    Member since:
    May 2012

    Posted 05 Jul 2012 Link to this post

    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. Ivan
    Ivan avatar
    106 posts

    Posted 06 Jul 2012 Link to this post


    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,
    the Telerik team

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

  3. Leon
    Leon avatar
    5 posts
    Member since:
    May 2012

    Posted 05 Dec 2012 Link to this post

    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.

Back to Top