CodeConnoisseur74 / pdi-to-do-app

1 stars 0 forks source link

refactored main function #2

Closed CodeConnoisseur74 closed 1 year ago

CodeConnoisseur74 commented 1 year ago

I refactored the main by creating a dictionary called 'actions. Each key corresponds to the user's choice in the menu and the value of the corresponding function.

When the user makes a choice, 'actions.get(choice) is used to retrieve the function associated with that choice.

I the user makes a valid choice, the function is called, otherwise,an error message is printed.

Now each action is defined in it's own function (No more 'stairway of elifs').

I welcome your feedback :)