MVC on the command line

后端 未结 4 1388
后悔当初
后悔当初 2021-02-05 19:58

I am looking into the MVC from a Command line point of view (not web and no framework).. nice and simple. the only thing that confuses me is the View part of this? (well it may

4条回答
  •  失恋的感觉
    2021-02-05 20:33

    Is it really necessary to apply a 3 letter acronym here? if you must:

    1. user sees the console screen, which shows the view (lines of texts)
    2. user types something on command line, which is an even from view
    3. controller gets the event, i.e. the user input
    4. controller does something accordingly, and updates the model (persons)
    5. controller tells the view to repaint, i.e. print some more lines.

    psuedocode:

    Person // model
       update();
    
    View
       modelUpdated()
           println(Person.name); ...
    
    Controller
         main()
             while( input = getInput() )
                 person.update(...);
                 view.modelUpdated();
    

提交回复
热议问题