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 6118501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:26:38+00:00 2026-05-23T15:26:38+00:00

I am trying to design a subclass that will contain responses to multipart questions

  • 0

I am trying to design a subclass that will contain responses to multipart questions and some logic to evaluate/act on them. For example, FoodSurvey would be a subclass of BaseSurvey

BaseSurvey
  Name
  Date
  Submit()

FoodSurvey <- BaseSurvey
  DoYouLikeIcecream
  IfSoWhatFlavour
  WouldYouLikeAFreeSample
  SendSample(flavour)
  ...

FoodSurvey could have several dozen or more questions, and I would need to valdate each answer based on others, as well as run some other processes specific to FoodSurvey (as opposed to CarSurvey) that may depend on multiple answers (ex: SendSample(rockyRoad)).

I have toyed with the idea of a Question class with a Questions collection in each Survey but this quickly started to look like a Survey ‘engine’ which seemed like it 1.) was overkill, 2.) was error prone and 3.) limited the logic I could use to validate answers.

Are there any accepted best practices regarding designing this type of class?

If it matters, the classes will eventually be used in an ASP.NET website or web application.

  • 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-23T15:26:39+00:00Added an answer on May 23, 2026 at 3:26 pm

    I like your approach of having a ‘Question’ class. In more detail, this model could use a type/object patter – sort of like the relationship between a type and an object. The code could look like this:

    class Question
    {
        public string Text { get; set; }
    }
    
    class QuestionAnswer
    {
        public Question Question { get; set; }
        public string Answer { get; set; }
    }
    
    interface ISurveyValidator
    {
        bool Validate(SurveyType type, IEnumerable<QuestionAnswer> answers);
    }
    
    class SurveyType
    {
        public string Name { get; set; }
    
        public IList<Question> Questions { get; set; }
    
        public ISurveyValidator Validator { get; set; }
    
        public Survey CreateSurvey(IEnumerable<QuestionAnswer> answers)
        {
            if (!this.Validator.Validate(this, answers))
                throw new Exception();
            return new Survey
            {
                Type = this,
                Date = DateTime.Now,
                Answers = answers.ToList()
            };
        }
    }
    
    class Survey
    {
        public SurveyType Type { get; set; }
        public DateTime Date { get; set; }
        public IList<QuestionAnswer> Answers { get; set; }
    }
    

    This would allow you to provide custom validation for each survey type.

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

Sidebar

Related Questions

I'm trying to design some bookmarklets right now, that connect back to a server
Trying to design simple aspect,that will print word logg to console,when any of public
I'm trying to design a table that will help me determine if a licence
I am trying to design a dropdown menu that covers the entire width of
I am trying to design model associations in rails that consist of the following
I'm trying to design a couple of classes that inherit a partial function, but
I am trying to design some kind of user to user relationship, such as
I am trying to design a layout so that I can change the views
I am trying to practice OO design. I've made the following classes, which will
I'm trying to design a calendar-type table that is built dynamically based on data

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.