I want to practice MVC with java but at the first I want to create a simple console app and separate it into MVC I know I can separate MODEL from console(view + controller) but how can I separate view and controller in this situation?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well you can mimic that behavior by having a class that handles user console input (controller) and another class that deals with rendering the model on the console output (view).
It’s not really what MVC is for, but if you really want to do it…
Edit: Ok, I’m going to give you some concrete ideas about the controller. You know that in a GUI app, you have the so-called “message loop”. You will need to mimic this in your console app. Try to start a parallel thread that receives console input in an infinite loop. When input is received, call a handler method from the controller class.