Doubt Spring MVC Controller

Asked

Viewed 35 times

0

I’m studying Spring MVC, and I’m developing a system that will contain questions and answers. Like the Controller, I create one for Questionscontroller and one for Answerscontroller, or just 1 for both

3 answers

1

In your system, the user will ask a question and you will return the answer in the same request, right?

If that is so, you will only have one Controller, it will receive the request from the user with the question, you will process in a Service, if you need to save something in the database use Repository and return the answer to the control that in turn will return the answer in the request.

0

That depends on how you’re shaping the system. You could for example have a single entity to manage the questions, so it would handle both the answers and the questions.

-1

This is very relative to how you want to model, complementing Daniel’s answer above, the domain of the application should govern the nomenclatures if you want to address questions and answers that characterize a question should adopt

"Questioncontroller" as name.

Another tip is to use English names for nomenclatures because in addition to the language being in English is a great practice, in the future you can work on global projects and English is a global language present in 80% of the world codes outside.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.