-
Notifications
You must be signed in to change notification settings - Fork 1
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
Libraries <=> Abstract interfaces <=> Dotsimus code #4
Comments
Certainly, an interesting idea, I personally never had to do abstractions to this level thus I don't really know what hurdles this entails and how much extra complexity it adds. |
and I like the Golden Bridge joke there ;) |
Regarding unit testing, it's a tough area to dive in, and most implementations I've seen do it just for the sake of having tests and not to speed up/help development. It's probably better to not mock the API (leave that to the library developers), but to test the bot core in that everything works fine. This could branch down to utilities such as message formatters and case helpers. Also, about your main point about using library functions, I somewhat agree. It is probably best to not use high-level interfaces too much but we shouldn't sacrifice general code quality just in the chance that discord.js may be discontinued in the future (also keep in mind that discord.py only had one core maintainer, whereas discord.js has like 4). Just for the record, discord.js helpers such as |
I agree, and actually after some thinking, I don't think the abstract interface is the best idea, it's time-consuming and can get complex when trying to support various libraries. |
Abstraction
Bridge
For portability reasons, it's better to avoid using libraries like discord.js everywhere in the code, instead, rely on abstract interfaces for Dotsimus, and implement those abstract interfaces properly (implement what needed). discord.js should be used inside implementations of these interfaces and nowhere else: these interfaces act as a bridge between the libraries and dotsimus.
Currently only discord.js have to be bridged (it's the only external module) since it's a pretty big one, internal nodejs modules are fine (and small modules too).
Learn more about bridges here:
https://en.wikipedia.org/wiki/Golden_Gate_BridgeReasons
The primary reason is for easier portability. Here are good reasons to rely on bridges instead:
Overall if something ever change in the Discord API and/or in the library, then it shouldn't affect the entire codebase, those are ideas. Hope you understand 😃
The text was updated successfully, but these errors were encountered: