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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:11:26+00:00 2026-05-13T11:11:26+00:00

Just trying to grasp the MVC by doing … and still not sure got

  • 0

Just trying to grasp the MVC by doing … and still not sure got it right ..

    using System;
    using System.Text;

    namespace MVPConsoleApp
    {
        class Program
        {
            static void Main(string[] args)
            {
                View objView = new View(); 
                Controller objController = new Controller(objView);
                objController.BuildUi();
                objView.WaitAndRead();

            }


        } //eof Program


        class View
        {

            private string _Prop1Gui  ;
            public string Prop1Gui 
            {
                get { return _Prop1Gui; }
                set { _Prop1Gui = value; } 
            }

            private string _Prop2Gui;
            public string Prop2Gui
            {
                get { return _Prop2Gui; }
                set { _Prop2Gui = value; }
            }

            public void WaitAndRead()
            {

                string bothProps = Console.ReadLine();
                string [] bothStrings = bothProps.Split(new char [] { ' ' } );
                this.Prop1Gui= bothStrings[0];
                this.Prop2Gui = bothStrings[1]  ; 

                Controller objController = new Controller(this);
                objController.StoreData();
                objController.BuildUiAftgerInput();
                this.WaitAndRead();
            }

            public void ShowMsg ( Model objModel) 
            {
                Console.WriteLine("objModel.ModelProp1  " + objModel.ModelProp1 +  
                    " objModel.ModelProp2 " + objModel.ModelProp2);
                Console.WriteLine("Write the new props separated by space !"); 
            }

        } //eof class 

        class Controller
        {
            View View { get; set; }
            Model Model { get; set;  } 


            public Controller(View objView)
            {
                this.View = objView;
                this.LoadData();
             }

            public void BuildUi()
            {
                this.View.ShowMsg(this.Model);
            }

            public void LoadData()
            {
                //get the data from db 
                Model objModel = new Model();
                objModel.ModelProp1 = "ModelProp1";
                objModel.ModelProp2 = "ModelProp2";
                this.Model = objModel;                 
            } //eof LoadData() 

            public void StoreData()
            {
                Model objModel = new Model();
                objModel.ModelProp1 = this.View.Prop1Gui;
                objModel.ModelProp2 = this.View.Prop2Gui;
                this.Model = objModel; 
            }

            public void BuildUiAftgerInput()
            {
                this.View.ShowMsg( this.Model);
            }

        } //eof class 

        class Model
        {
            public string ModelProp1 { get; set; }
            public string ModelProp2 { get; set; } 
        } //eof class 
    } //eof namespace 
  • 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-13T11:11:26+00:00Added an answer on May 13, 2026 at 11:11 am

    In short, the pattern of MVC should follow:

    • view receives user input and passes it to the controller
    • controller updates the model in response to user input (can also modify view directly)
    • model notifies the view of the change
    • view updates itself based on changes to model.

    In otherwords your View should be observing your Model. At the moment your View does not know when the Model changes hence it cannot update itself accordingly.

    You should look at introducing something like the Observer Pattern.

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

Sidebar

Related Questions

Just trying to still get my head around IOC principles. Q1: Static Methods -
I've really been trying, but I am just not getting blocks very well. I
I was just trying to grasp better understanding of pointers to pointers and on
Trying to get a grasp of using PDO, and I'm using some pre-made functions
Just trying to get diff to work better for certain kinds of documents. With
just trying to test for equality in this piece of code, but getting a
Just trying to establish whether prototype can do something like $$('#ID a:last').css('color','#111'); Any ideas
Just trying to get my head around what can happen when things go wrong
Just trying to canvas some opinions here. I was wondering how people go about
Just trying to understand that - I have never used it before. How is

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.