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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:41:15+00:00 2026-05-29T08:41:15+00:00

I’m writing a flashcard program and am running into an issue I always seem

  • 0

I’m writing a flashcard program and am running into an issue I always seem to face when writing this sort of Forms program.

I’ll describe the program then the issue.

In this program, one main form controls almost all of the action. Depending on the user’s input and form events, different buttons/controls may become enabled or disabled, text in various boxes may be populated, etc.

For example:

  • Some questions might be multiple choice and others require typed input.
  • The user inputs their answer and clicks a button — if they get something wrong, they have the option to override the ‘wrong answer’ judgement and say it was really a different, correct variant.
  • Statistics regarding which questions were answered correctly are kept and used in the decision about what flash cards to show next.

Now the issue.

How do I best create a clean interaction between the “form” code (for example, handling the OK button’s onclick command, and enabling or disabling various controls) and the “logic” code (underlying data stores, program logic that does not have immediate implications for display)? If it is all mixed together in the form object code it does not seem right.

Can anyone suggest a design pattern (especially one widely used) that manages this cleanly?

In case it is relevant I am thinking of something like this:

  • Object Model:
    • Class MyForm: the form itself.
    • Class FormController:
      • Child class of MyForm.
      • Instantiation requires an object of type MyForm.
      • FormController’s job is to put its MyForm object into a particular “state,” by enabling/disabling controls, displaying various text, etc.
      • FormController exposes a small set of public functions which deal with semantically high-level request for the form state (such as “DisplayNewQuestion(QuestionData d)”)
    • Class Session: Contains all underlying persistent data or objects involving this session, including lists of possible questions, objects that select the next question from the list, etc.
    • Class Driver: Drives both the Session and FormController objects. For example, it would ask the Session object for a new question, and pass it to the FormController object to update the form.

The advantage to something like this is that icky form code and nice logic code are now completely separable. But is it worthwhile? Are there better or more common design patterns for this?

Thanks a ton!

  • 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-29T08:41:15+00:00Added an answer on May 29, 2026 at 8:41 am

    I am always most comfortable with Model View Controller in this situation. The Shade Tree Developer wrote the most informed series I have ever read on the subject, see here

    The jist of MVC is

    Model contains the data to be displayed

    View is your form and only has logic for displaying and informing of user interactions

    Controller contains the glue to make it all happen, including the business logic.

    The depenencies should be

    Model doesnt know about the view or the controller

    View knows about the model and knows how to extract data from it to display

    Controller knows about the Model and the view, instansiates them both and wires them together.

    The model raises an event when it changes, the view captures this event and refreshes its display accordingly.

    The view raises an event when a user interaction occurs, the controller captures this event and performs the correct action for the interaction whether that be updating the model or saving or clearing or whatever.

    The view should not write to the model itself

    You will see a lot of code where the form creates the controller but imo this is wrong. It came about because of people trying to apply this pattern in asp.net webforms where you have no control over the lifecycle, the first thing that always got created was a view so you had no choice but to have this create your controller, however in winforms you are in control, so make it clean, have the controller create the view.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I am writing an app with both english and french support. The app requests

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.