You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By making usage of a command system we can make the creation of commands really easy.
A user only needs to create 1 class that extends a "Command" class.
This automatically requires the override of multiple methods that create the help command, and more.
We would have to decide whenever we want reflection or hardcoded commands
By making usage of reflection, the user only needs to extend 1 class. (Which would also be required when hardcoded commands)
The command will automatically be added, and automatically run.
Disabling commands can be done by overriding a (non abstract) method (isDisabled a.e) that by default returns false.
This is really easy for everyone.
I can't comment on advantages of hardcoded commands, if anyone has any I'll add those here.
Feel free to add counter arguments against either in the commands, those will be added to this message.
React with the corresponding emoji to vote
🚀 Reflection
🥇 Hardcoded commands
Reacted by Daniel Tischner, I-Al-Istannen and d3vel0per
I don't think reflection would be good, since we aim to be a beginner friendly and reflection isn't really beginner friendly at all. It could also cause portability issues over different Java versions.
How would it not be beginner friendly?
I feel like it's even more beginner friendly, they don't have to add it to any collection or file.
Just extending a class would be enough.
could also cause portability issues over different Java versions.
I'd assume we will use the latest Java, but feel free to discuss this in #13
We really need not use reflection as such. We can leverage something like a service registry pattern.
Commands would have various classes of interfaces based on the kind of work they are supposed to do. And all command implementations will register in a central command registry at compile time which by definition would be a hardcoded list. It would be a ticking timebomb if any new command added dynamically gets deployed in production just because it adheres to a "command interface". We should have some control over the which commands are OK to run in production vs which aren't. Either it starts as a static list, can become a dynamic list managed in the database or if we have very fancy use cases rather use a rules engine. This way apart from the primary deployment even the command deployments can be rolled out in a controlled manner.
Its another case if we want to leverage a DI framework which of course will use reflection/proxying behind the scenes but does the use case ask for those level of abstractions YAGNI
Additionally since the new bot is supposed to be an aggregation of a whole lot of existing features I feel it would be good if the commands are isolated from each other in the runtime ie. a single bad command shouldn't bring down the whole bot engine.
After Googling "service registry pattern" I couldn't really find a good explanation, or well I don't understand what you mean exactly.
It sounds really complicated, I could be misunderstanding it.
But my original intention was to go for a approach like Chewtils did regarding Commands itself. (Not this code, probably not even close to it, but the idea)
A simple run method, with other methods that get the command name, it's description etc.
This is extremely simple.
adheres to a "command interface". We should have some control over the which commands are OK to run in production vs which aren't
Regarding this statement.
Disabling commands can be done by overriding a (non abstract) method (isDisabled a.e) that by default returns false.
And we shouldn't have non production things in a production branch regardless.
Commands that are WIP should be in a different branch or a fork.
Additionally since the new bot is supposed to be an aggregation of a whole lot of existing features I feel it would be good if the commands are isolated from each other in the runtime ie. a single bad command shouldn't bring down the whole bot engine.
Reflection doesn't matter with this, this will be no issue.
On errors only the event errors out.
Not the bot.
We really need not use reflection as such.
Feel free to add a reaction as vote, same applies for @illuminator3
Activity
illuminator3 commentedon Sep 5, 2021
I don't think reflection would be good, since we aim to be a beginner friendly and reflection isn't really beginner friendly at all. It could also cause portability issues over different Java versions.
Tais993 commentedon Sep 5, 2021
How would it not be beginner friendly?
I feel like it's even more beginner friendly, they don't have to add it to any collection or file.
Just extending a class would be enough.
I'd assume we will use the latest Java, but feel free to discuss this in #13
d3vel0per commentedon Sep 5, 2021
We really need not use reflection as such. We can leverage something like a service registry pattern.
Commands would have various classes of interfaces based on the kind of work they are supposed to do. And all command implementations will register in a central command registry at compile time which by definition would be a hardcoded list. It would be a ticking timebomb if any new command added dynamically gets deployed in production just because it adheres to a "command interface". We should have some control over the which commands are OK to run in production vs which aren't. Either it starts as a static list, can become a dynamic list managed in the database or if we have very fancy use cases rather use a rules engine. This way apart from the primary deployment even the command deployments can be rolled out in a controlled manner.
Its another case if we want to leverage a DI framework which of course will use reflection/proxying behind the scenes but does the use case ask for those level of abstractions YAGNI
Additionally since the new bot is supposed to be an aggregation of a whole lot of existing features I feel it would be good if the commands are isolated from each other in the runtime ie. a single bad command shouldn't bring down the whole bot engine.
Tais993 commentedon Sep 5, 2021
After Googling "service registry pattern" I couldn't really find a good explanation, or well I don't understand what you mean exactly.
It sounds really complicated, I could be misunderstanding it.
But my original intention was to go for a approach like Chewtils did regarding Commands itself. (Not this code, probably not even close to it, but the idea)
A simple run method, with other methods that get the command name, it's description etc.
This is extremely simple.
Regarding this statement.
And we shouldn't have non production things in a production branch regardless.
Commands that are WIP should be in a different branch or a fork.
Reflection doesn't matter with this, this will be no issue.
On errors only the event errors out.
Not the bot.
Feel free to add a reaction as vote, same applies for @illuminator3
[-]Creation of basic command system[/-][+]How to design a basic command system[/+][-]How to design a basic command system[/-][+]How to design a basic command system?[/+]Tais993 commentedon Sep 7, 2021
If no-one will elaborate further on their decision reflection vs hardcoded is decided?
Tais993 commentedon Sep 7, 2021
I'll be making a PR, which will be open for feedback.
Zabuzard commentedon Sep 9, 2021
Good discussions. I feel we have enough info to create a first proposal (@Tais993 is actually already working on it).
Closing this for now. Discussions about the first draft can be done here: #59