Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6908689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:35:40+00:00 2026-05-27T08:35:40+00:00

I have a class Form , which holds a hash of Question items. class

  • 0

I have a class Form, which holds a hash of Question items.

class Form
{
    Dictionary < int , Answer> listOfQuestions;
}

class Question
{
    int questionId = 2;
    int dependsOnQuestion = 1;
    string answer;
    public bool IsDependancyMet() {/*problem*/}
}

I want a single Question to depend on an answer of another question, say, if the answer to question 1 is “Married”, display question 2, otherwise, don’t display it.

What would be the proper way of implementing that?

Would that be adding of a reference of the Form instance to the question instance, to let the later one access to the hash of questions. Though I don’t like it.

The other way is to add a method to the Form class, which receives an question ID and checks whether all it’s dependencies are met, but then again, the question should be aware of the form instance.

ON the bottom line:
Who should check the dependencies and how, to leave the system modular and each class the less aware of it’s environment as possible? Or at least avoid cycle referencing.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:35:41+00:00Added an answer on May 27, 2026 at 8:35 am

    What about something along the lines of

    class Form
    {
        Dictionary < int , Answer> listOfQuestions;
        int firstQuestion;
    
        public void NextQuestion() {
           // ... cycle through `listOfQuestions` looking for a question
           // whose dependencies are fullfilled and ask it.
        }
    }
    
    class Question
    {
        // ...
        public List<int> GetDependencies();
        public void Ask();
        // ...
    }
    

    Form keeps track of the global ‘questioning’ state, while individual questions only have knowledge of their direct dependencies. To me, this seems like a relatively clean approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a class which a form can inherit from and it handles
I have a winforms form which is inherited from another form. e.g. class StartForm
Hi I have a form class which looks like below:- class UserCreateForm(wtf.Form): name=wtf.TextField('Name',validators=[validators.Required(),username_check]) email=wtf.TextField('Email')
Assume I have a form class SampleClass(forms.Form): name = forms.CharField(max_length=30) age = forms.IntegerField() django_hacker
I override ProcessCmdKey() in my MDI parent form class and have some keyboard shortcut
I am developing a web form using Visual Web Developer Currently I have class
Say I have this simple form: class ContactForm(forms.Form): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True)
I have a windows form app written in C#. the main_form class instantiates an
Currently, I have something like: public partial class Form1 : Form { delegate void
I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.