0

I am writing an application in Java which use MVC pattern design. I have 4 major classes: Main, Controller, Model, View. Main initialize the other three and run launchMenu() in a infinite loop, a method included in Controller. This launchMenu from Controller runs a launchMenu method of another class: MenuHandler, which set up the Actions (using my own Command design pattern) and assign them to each option from my enum UserOperationsMenu.
I have several doubts on how to handle UserOperationsMenu.EXIT.

My question is about what would be better and more logic:

  1. Using an exception I catch up in the body of Main's loop and throw it in my ExitAction class assigned to UserOperationsMenu.EXIT?
  2. Creating an object Delegate in Controller which I pass to MenuHandler and ExitAction so that I can command from ExitAction to exit the program?

I've thought about using a boolean variable in my while in Main, and returning false when I want to finish the program. But I don't like the idea, though.

NOTE: I don't want to use System.exit(0) directly because first I have to do several tasks outside my ExitAction.

Jorge
  • 101

0 Answers0