Closed tomdye closed 5 years ago
To be clear, my feeling is private
methods and properties of ES Classes should always be prefixed. Non-exported functions (nominally private functions) or non-exported variables should not be prefixed.
It is still likely that ECMAScript will likely move to private fields eventually, meaning we would need to refactor significantly. Having a common syntax for the TypeScript private
construct could make that refactoring easier.
While I get the need for private methods in certain instances, mostly the convenience of scoping to the instance, we should be careful around use of them, because they are not truly private (just like the properties). When working with TypeScript, it will guard against name collisions, but we can't be certain that everyone using Dojo 2 will use TypeScript. We should consider using the pattern more often of a non-exported function which takes and instance argument.
The general consensus is that ALL private methods and fields are prefixed with _
. The style guide should be updated to be more explicit about this.
@tomdye commented on Tue Apr 04 2017
Discussion
Do people feel that we should prefix
private
functions / variables with anunderscore
. Currently, I believe that our guidelines are to prefix private variables, but I have noticed a few PR's being raised with prefixed functions too. The key here is that we need to be consistent in our approach across our repos.