dimanche 18 mars 2018

What pattern should I use for a console menu system taking inputs?

I have an assignment that will be a console menu system with a main menu and 4 sub menus. The menu will take input from the user to decide which submenu to traverse to. Submenus will also need to read, update, delete data from a database.

I want to know what possible design patterns could I use to best implement this? I've heard that state, strategy, command and builder patterns could all be possible solutions.

I also want to know how I can remove as many loops and conditionals as i can to write more efficient readable code. My classmate was doing this using MVP and builder pattern but i didnt understand how he did it. E.g. writing this code better.

While(true){
If(input==1) //go to this menu
If (input==2) //go this menu

Etc.. it becomes unreadable after a while.

Which pattern should i research more for this program? How can i remove the loops and if statements to write more readable code?

Aucun commentaire:

Enregistrer un commentaire