Question / Answer Checker Software Design Pattern

I would like to create some kind of survey / audit software. I'm brainstorming how to build my classes, and if there is a design template that could support me. Because it must be something that makes life more peaceful ...

My application should have questions containing a title and description. And then I have several types of answers.

So ... one type can be yes / no answer. Another type can be a value from 1 to 10. Another type is a free text answer. Another type can be three given text options, where you can choose one (dinner was great, good, nod bad)

So, on a survey planning site, I would write down my questions and assign answer types.

And when doing the survey, I want to direct it as a set of questions with an answer ...

The main question is how to combine all the different types of answers and how to store them in the database?

I looked at the composite and strategic pattern, but I'm not sure ... and I know that there is no perfect solution, and it always depends ...

But it would be great if someone could share best practices regarding how they dealt with similar topics ...

Thanks in advance...

+3
source share
1 answer

What do you seem to be asking here, what are the different entity matching strategies that are available to you in the database? In short, you can:

  • table for each object
  • ( , , ) -
  • 1:1

ORM (), .

:

AbstractQuestion

. , ask() answer(). AbstractQuestion , . , MultiChoiceQuestion ask() , ( AbstractQuestion ask()), ( ), , ask() , . varargs - .

, , AbstractQuestion.

, . AbstractQuestion ask(), , answer() .

, . , , .

+2

Source: https://habr.com/ru/post/1775621/