Closed arteymix closed 8 years ago
The only thing you don't like that I liked is extensive use of 'this'. Here is my reason:
this
says the name we are using is from the instance scope. The scope is not local, not global, but instance.
Without this
the way we infer a name refers to instance member is to first check if it is not defined in the local scope, and then reject all possible conflicts from the global scope. It makes it harder to comprehend the code for a slow mind like mine -- or we make some risky assumptions, e,g. the global scope is empty.
Also, due to potential name conflicts we will have to use this
here an there anyways.
My reasoning for this
is that we typically only work with private members. If we have a property with a private storage, it will be prefixed with _
, removing the need for this
.
Moreover, it's always advantageous to access the property directly since it avoid a getter overhead. We only protect internals from the outside world.
The other case where we might need this
to disambiguate is the constructor, but we should use GObject construction style instead.
Also I mean less this
, not absolutely no this
. I just say we should design the code to avoid having to disambiguate.
I agree with you on avoiding the accessor functions.
I am also fine with your preference of not using this
when not necessary.
I'd like to note that sellf/this
is everywhere in raw GObject C, and also in Python. C++ and Java do not require this
. My perspective may have been bias due to this.
I like some elements of the current style:
I would like to see:
foo ()
)this
public class Vast.Array
)