mardi 15 août 2017

Alternatives to if else nesting for command line parsing

I am creating a bot which will take in commands starting with !command then it will have actions like poll or help. These actions will have further options and they can be variable in number. For example: !command poll create somepollurl If somepollurl is omitted, it should take a default url. (Above is just an example of how complicated the logic can be.)

Currently the code which I have is getting too much nested and hence less readable and difficult to maintain. This may also lead to bugs and unexpected loopholes in the logic that may be exploited by malicious users.

I was wondering if there could be better ways to deal with the issue so that the code is more readable and bug free.

Aucun commentaire:

Enregistrer un commentaire