Out of curiosity, why does the _createHasManyRepositoryFactoryFor function start with an underscore even though it is publically exposed?
I'm sorry, I guess it's protected. Is it convention to start protected methods with an underscore?
I don't think it's strictly enforced. IMO, with private/protected/public modifiers in TypeScript, we don't have to play such conventions. YMMV.
I find it slightly odd because users of the system will be accessing those methods a lot. That's just my opinion though.
It kinda makes you feel like you're not supposed to use them, or that you're monkey patching the code.
@codejamninja I tend to agree with you.
@codejamninja Good question!
I think it was me who introduced the convention of using underscores. My problem with private/protected/public modifies is that they are not available nor enforced in JavaScript, at least AFAIK.
At the same time, I can see how protected methods with a name starting with underscore can look weird.
I am proposing to make the following changes. What do you think, @strongloop/loopback-maintainers?
For current protected methods like _createHasManyRepositoryFactoryFor:
createHasManyRepositoryFactoryFor)_createHasManyRepositoryFactoryFor), mark it as deprecated and implement it by calling the new method (createHasManyRepositoryFactoryFor)Document the naming style: public and protected members don't start with underscore. Discuss what style to use for private members as part of the pull request.
Unfortunately, we did not yet manage to update our style guide for TypeScript and move it into loopback-next. To keep things simple, I think it's best to add the new content to the current outdated style guide here: https://github.com/strongloop/loopback.io/blob/gh-pages/pages/en/contrib/style-guide.md
Of course, if there is a volunteer willing to migrate that style guide to loopback-next and update it to our actual style, then we would gladly accept such contribution!
I created a pull request to solve this
Most helpful comment
@codejamninja Good question!
I think it was me who introduced the convention of using underscores. My problem with private/protected/public modifies is that they are not available nor enforced in JavaScript, at least AFAIK.
At the same time, I can see how protected methods with a name starting with underscore can look weird.
I am proposing to make the following changes. What do you think, @strongloop/loopback-maintainers?
For current protected methods like
_createHasManyRepositoryFactoryFor:createHasManyRepositoryFactoryFor)_createHasManyRepositoryFactoryFor), mark it as deprecated and implement it by calling the new method (createHasManyRepositoryFactoryFor)Document the naming style: public and protected members don't start with underscore. Discuss what style to use for private members as part of the pull request.
Unfortunately, we did not yet manage to update our style guide for TypeScript and move it into loopback-next. To keep things simple, I think it's best to add the new content to the current outdated style guide here: https://github.com/strongloop/loopback.io/blob/gh-pages/pages/en/contrib/style-guide.md
Of course, if there is a volunteer willing to migrate that style guide to loopback-next and update it to our actual style, then we would gladly accept such contribution!