Saturday, 18 January 2020

Is it the proper way to hide methods that should be private?

Is it OK to hide private methods of a class within the module that exports this class? I mean there is a class that exposes some methods as a public interface and I want to hide internal methods that are not a part of the public interface. Here is an example:```javascript function thePrivateFunction(dependency) {}class MyClass { constructor(dependency) { this.dependency = dependency; } thePublicMethod() { thePrivateFunction(dependency); } }module.exports = MyClass;```

Submitted January 18, 2020 at 10:35AM by f1xxmAn

No comments:

Post a Comment