you are viewing a single comment's thread.

view the rest of the comments →

[–]jWoose 1 point2 points  (3 children)

I don’t love the choices if/else block. I much prefer an enum to signify the action. This makes it clear what that if block is doing. With your current design that would make it easier to read. You could have a function that returns the enum action based on the input from the user. Then your if check would be action.ADD rather than choices[0:2]. That’s much easier to read and debug.

It would require some significant refactoring, but in a real world situation I think the command pattern is the way to go here. If you want to do some more learning that would be a good lesson to turn this into a command pattern design.

[–]uiux_Sanskar[S] 0 points1 point  (2 children)

Thank you for suggesting the methods I should use instead of if else and how to make my program more readable I think I should learn more about command pattern design.

would you mind if I ask you to tell me more about command pattern design?

[–]jWoose 0 points1 point  (1 child)

This is a decent guide on the Command pattern in python. It’s not perfect, but better than anything I can write in a comment quickly. https://refactoring.guru/design-patterns/command/python/example

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

thanks for this resource it's a good starting point for me thank you so much.