Architectures for GUI Systems

We will consider two architectures for designing systems with graphic user interfaces. The first is conceptually simpler to understand the second is closer to the prevailing designs. This consideration is separate from the architecture of an implementation such as X windows. The MVC architecture is still at a conceptual level.

The Model, View, Controller (MVC) Architecture

MVC Picture

With acknowledgements to Dave Collins.


class counter: public model {

     public:

          decrement();

          increment();

          reset();

          getValue();

   private:

          setValue();

};



class counterView : public  View{

         public:

          counterView(); // fire up a view 

               // of an initialized counter

          updateCounterView();

};



class counterControl : public Control{

        public :

            counterControl();

            decrement();

            increment();

            reset();

  };

The Model View (MV) Architecture

Here the controller is collapsed into the view. This is the usual Windows orientation.

The following example is based upon the MacApp interface. Similar things can be done with other interfaces.


class model {

	private:

               View*  pView;

           protected:

               void changed()  {  // model has changed, 

                                     // update the view

                      pView -> update();}

           public:

               void setView(View* pv) {

                     pView = pv;  // tell the model 

                                     // this is its view

                    pView -> setModel(this);}

};



class  View public TWindow {

          protected:

               Model* pModel;

          public:

                // Set the model for this view

               void setModel(Model* pm) {pModel = pm:}

               virtual void update(){}

};


Return to GUI home page.

Last Changed: 8 May 1995