java - Best way to describe this tree like multiple choice questions/answers algorithm in UML -


there 2 classes: question , answer. instance of question contains list of answers, each answer points follow question. each selected answer triggers relevant next question until answer no followup question selected.

what uml diagram best describe questionnaire flow this:

q1: "are hungry?" [yes, no]   yes->q2: "what want eat?" [apple, pear, banana]       apple->q4: "green or red?" [green, red]       pear ->q5: "big or small?" [big, small]   no ->q3: "are thirsty?" [yes, no]       yes->q6: "what drink?" [tea, coffee, water, vodka]           tea  ->q7: "any sugar?" [1 spoon, 2 spoons, 3 spoons]           vodka->q8: "are old enough it?" [yes, no]       

a class diagram describe relationship between classes not question-answer flow.

object diagram have information relationship between objects , object's inner structure make hard read question/answer flow interested in.

activity diagram work if questions true or false, decision diamond shaped icon used true , false flow. wouldn't work if question has 7 possible answers.

so problem find type of diagram describe flow in basic , clear way.

different diagrams are used different things , provide different model of details. if want present relations between classes in model class diagram 2 associations

question 1 <-- answers --> 1..* answer answer 1 <-- follow-up --> 0..1 question 

will fine (i intentionally not classes because not want suggest implementation). in tools example enterprise architect can use diagram generate source code. based on question think want.

if on other hand want show control flow should use 1 of behaviour diagrams. sequence or communication diagrams show how objects of model interacts (which methods used) each other implement specific use case. if use states in model can show on state machine diagram.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -