Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider an approach to specify exported interface with less duplication #198

Open
davidyuk opened this issue Feb 1, 2023 · 2 comments
Open
Labels
breaking Marks a breaking change enhancement New feature or request

Comments

@davidyuk
Copy link
Member

davidyuk commented Feb 1, 2023

Currently, all exported classes are stored in a separate api folder. Each class actually a wrapper around the corresponding "private" class with some methods/arguments removed.

Pros of this approach:

  • not possible to accidentally expose something to the public API

Cons:

  • documentation duplicated, boilerplate code

In some cases there is the same interface of "private" class and exposed one, for example, AciContractCallEncoder can be exported as

module.exports = require('../AciContractCallEncoder')

without exposing anything extra.

Additionally, traditional approaches to specify visibility of a class method may be used, like prefixing with _ (to be able to access in other library classes), or prefixing with # to make it a proper private method. Then wrapping classes won't be necessary.

@dincho
Copy link
Member

dincho commented Feb 1, 2023

Yes, # is the way to go. However, #114
We should probably try again, as it is 2023 already :)

I definitely don't want any lib/user/app to be able to use private methods/data.

@davidyuk
Copy link
Member Author

#114 still may be the case. But I have no problems with # in sdk, maybe because it gets transpiled to something compatible.

@dincho dincho added enhancement New feature or request breaking Marks a breaking change labels Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Marks a breaking change enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants