dimanche 7 février 2021

Architecture for user-assigned button commands

Trying to find a decent approach to the following problem:

I have a button, well lots of them, and I want the user to be able to choose from a list what function to assign to what button. i.e. button one changes the volume, button two calls mom, button three adds some data to a database etc... maybe one button does two or more of these things at the same time.

I've used the 'Command Pattern' in the past to provide an interface for the buttons to have commands, but what I don't know is how to save/store the assigned commands in the database?

How should this be done? I guess I would have a package which contains classes for all the different commands... would they have an ID that is stored in the database? Then when the buttons are loaded they check the database ID and find the command class with that id? That seems like not a very efficient way to do it?

How would I save a reference to a command class?

Aucun commentaire:

Enregistrer un commentaire