I know I'm not the only Java teacher who finds the
"this." default confusing to beginning students. I'd
prefer, at least at the beginning of my course, that
every method call be of the form
objectOrClass.methodName(args) and that every instance
variable reference be of the form objectOrThis.varName.
I tried writing a Check of my own to enforce this, and
I didn't have too much trouble with methods: it seems
to me that anywhere I find an IDENT whose parent (not
grandparent) is a METHOD_CALL, it's relying on the
"this." default. But instance variables are trickier,
because I don't see any easy way to tell where and how
a given IDENT is declared -- is it an instance
variable, a local variable, a parameter, or not a
variable at all (e.g. a method or a class)?
Log in to post a comment.