You cannot know ahead of time how someone else will want to modify your code
And this is exactly why I make implementation private. Otherwise my implementation becomes my public interface and I can't change it without breaking somebody else's patch.
If you’ve got a tricky interaction between a few private functions it’s very helpful to be able to test them!
Then refactor those tricky functions into another class with testable interface.
var SomeModule = (function(trickyFunctionality) {
function publicFunction() {
trickyFunctionality.doTheTrick()
}
return {
publicFunction: publicFunction
}
})(new Tricky())
Comments
And this is exactly why I make implementation private. Otherwise my implementation becomes my public interface and I can't change it without breaking somebody else's patch.
Then refactor those tricky functions into another class with testable interface.