Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC++ application architecture Ari Jaaksi.

Similar presentations


Presentation on theme: "1 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC++ application architecture Ari Jaaksi."— Presentation transcript:

1 1 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC++ application architecture Ari Jaaksi

2 2 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC++ application architecture Model View Controller C++ OMT++ = MVC++ Model View Controller C++ OMT++ = MVC++

3 3 Ari Jaaksi 1997 / Roope Raisamo 2000 OMT++ OMT (Rumbaugh et al./ GE) “OMT/NMS” (NTC) Fusion (Coleman et al. / HP) OMT+ (Nokia) OMT++ (Nokia Networks) UML (Rumbaugh, Booch, Jacobson / Rational)

4 4 Ari Jaaksi 1997 / Roope Raisamo 2000 OMT++ process Class Specification Class Implementation Dialogue Diagrams, Operation Specifications Class Declarations Implementation of Methods OOD OOP Object Analysis Behaviour Analysis User Interface Specification Design Class Diagrams Sequence Diagrams, Statechart Diagrams Object Design Behaviour Design Analysis Class Diagrams Operations, Use Cases OOA

5 5 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC & OMT++ & C++ => MVC++ Original MVC (SmallTalk) is Adapted to C++ Adapted to Java programs Essential part of OMT++ Based on agreements naming division of labour communication Base classes Text templates

6 6 Ari Jaaksi 1997 / Roope Raisamo 2000 “GUI-Hanger” syndrome FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; } FuncX(…) { do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; do this; do that; }

7 7 Ari Jaaksi 1997 / Roope Raisamo 2000 Some application architectures Min=0 Max=400 Value=50 AbstractionControlPresentation PAC (J.Coutaz) ControllerView Model MVC Model (Reenskaug) Application User interface Simple Separation (N.N) Frame View Docu ment Docu ment View MDI (MFC)

8 8 Ari Jaaksi 1997 / Roope Raisamo 2000 Objectives of MVC++ 1. To separate applications into parts which each have their own job and purpose, 2. To get more reusable software components, 3. To make software easier to maintain and understand, 4. To fill the gap between the analysis and design phases VIEW CONTROLLER MODEL

9 9 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC++ triad Controller -knows how this particular application works -controls the view and the model Model -"real world" -works when the controller asks it to work View -user interface -knows how to communicate with the end user

10 10 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC++ application in action Actions of the End User =Manipulation Observations of the End User =Feedback End UserViewController Model Decisions Interpreted actions Results Actions Action requests Action requests User Interface

11 11 Ari Jaaksi 1997 / Roope Raisamo 2000 Working together Balance: 7800:- ModelControllerView controller::BalanceWanted() { b = model->GetBalance(); view->ShowBalanceFM(b); }; 7800.00 Balance Get view::GetPressedMM() { controller->BalanceWanted(); }; view::ShowBalanceFM(int b) { TextField.WriteInt(b); }; int model::GetBalance() { return(balance); };

12 12 Ari Jaaksi 1997 / Roope Raisamo 2000 A typical MVC task 1. The end user manipulates the view (e.g. presses a button). 2. The user's actions are interpreted by the view. 3. The view passes the interpreted commands to the controller. 4. The controller decides what should be done in a situation like this. 5. According to its own intelligence the controller makes the model act. 6. The model acts independently. 7. After the model has completed the tasks, the control returns to the controller. It decides if the changes in the model should cause changes in the view. 8. If so, the controller gets all the information needed from the model. 9. The controller passes the information to the view. 10. The view displays the information in its own way.

13 13 Ari Jaaksi 1997 / Roope Raisamo 2000 View layer the user interface contains e.g. the windowing system all the callback functions of the windowing system all the widgets of the windowing system knows how to communicate with the end user knows how to present things to the end user knows how to receive the end user’s actions does not decide what to do with the user’s actions lets the controller decide has feedback, manipulation and query methods has methods like ShowObjectIDFM(), PresentBTSStateFM() to present things to the end user, has methods like ButtonXXXPressedMM(), SliderYYYMovedMM() to capture the end user’s actions, has methods like GetSelectionQM(), GetChosenElementQM() to capture the end user’s selections made some time ago is instantiated by the controller; communicates with the controller

14 14 Ari Jaaksi 1997 / Roope Raisamo 2000 Model layer the “real world” is capable of completing “real world” tasks independently is controlled by the controller the controller makes the model act the model is not aware of the view has methods like GetObjectID(), ChangeBTSState() etc.

15 15 Ari Jaaksi 1997 / Roope Raisamo 2000 Controller layer brains of the application makes application specific decisions knows how this application should behave controls the application by making the model and the view act knows WHAT the model and the view are capable of doing knows WHAT the model and the view should do doesn’t know HOW things are done inside the model and the view instantiates the view and often the model too has corresponding methods for manipulation methods of the view a typical task: 1. Gets the user’s commands interpreted by the view. 2. Decides what to do with user’s commands. 3. Asks the model to work. ( model->ChangeBTSState(...); ) 4. Asks the view to present the results. ( view->PresentBTSStateFM(...); )

16 16 Ari Jaaksi 1997 / Roope Raisamo 2000 Some facts... view part consists of view objects controller part consists of controller objects model part consists of model objects every controller class has a view class of its own every view class has a controller class of its own there are typically many controller-view class pairs in an application there is the main controller controlling the main window and all other controllers normally every window/dialogue of an application forms a view class

17 17 Ari Jaaksi 1997 / Roope Raisamo 2000 « controller » MainController MVC++ application « view » MainView « view » SubViewA « view » SubViewB ModelA ModelC ModelD View Layer Controller Layer Model Layer « controller » SubControllerA « controller » SubControllerB ModelB 11 1 1 * Could be any cardinality 1 11 1

18 18 Ari Jaaksi 1997 / Roope Raisamo 2000 « controller » MainController Very simple view objects « view » MainView « view » SubViewA « controller » SubControllerA « view » SubViewB « controller » SubControllerB ModelA ModelBModelC ModelD Very Simple View Very Simple View 11 1 1 1 1 1 1

19 19 Ari Jaaksi 1997 / Roope Raisamo 2000 Methods of the view There are three main categories of methods in a view class: Manipulation Methods (MM) callback methods, associated with widgets these methods typically call the controller Feedback Methods (FM) these methods are used by the controller show things to the end user Query Methods (QM) these methods are used by the controller investigate the state of the view xxxView::ButtonPressedMM() { controller->ActionWanted(); } A Manipulation Method xxxView::ShowTextFM(char *txt) { XmTextSetString(widgetX,txt); } A Feedback Method char *xxxView::GetNameQM() { return(XmTextGetString(widgetY)); } A Query Method

20 20 Ari Jaaksi 1997 / Roope Raisamo 2000 Constructing an MVC hierarchy 0.The main program creates an instance of the program object of the application. 1.The program object creates the main controller. 2.The main controller creates the view that initializes the windowing system 3.The main controller creates its model. 4.The main controller creates controller A 5.Controller A creates its view. 6.Controller A creates its model. 7.The main controller creates controller B 8.Controller B creates its view. 9.Controller B creates its model.

21 21 Ari Jaaksi 1997 / Roope Raisamo 2000 Constructing an MVC hierarchy #2 0. The main program creates an instance of the program object of the application. 1. The program object creates the main controller. 2. The main controller creates the view that initializes the windowing system 3. The main controller creates the model. 4. The main controller creates the controller A 5. Controller A creates its view. 6. The main controller sets a link between the controller A and the model. 7. The main controller creates the controller B 8. Controller B creates its view. 9. The main controller sets a link between controller B and the model. Model C Main ControllerMain View Main Program Controller AController B View AView B 1. Creates2. Creates 5. Creates8. Creates 4. Creates7. Creates 3. Creates 6. Sets

22 22 Ari Jaaksi 1997 / Roope Raisamo 2000 Attempt to connect a view and a controller class xxxView_c... xxxcontroller->ActionAsked() uses xxxController_c { public: ActionAsked(); }; xxxView_c... xxxcontroller->ActionAsked() uses yyyController_c { public: ActionAsked(); }; NJET! 1 1 11 1 1

23 23 Ari Jaaksi 1997 / Roope Raisamo 2000 Connecting view and controller xxxView_c... xxxAbsViewPartner->ActionAsked() xxxController_c: public xxxAbsViewPartner { public: ActionAsked(); }; xxxAbsViewPartner_c { ActionAsked{abstract} }; uses xxxView_c... xxxAbsViewPartner->ActionAsked() yyyController_c: public xxxAbsViewPartner { public: ActionAsked(); }; xxxAbsViewPartner_c { ActionAsked{abstract} }; uses Da!

24 24 Ari Jaaksi 1997 / Roope Raisamo 2000 Abstract partners Main Controller Some Controller Main View Some View Model AModel B Abstract Main View Partner Abstract Some View Partner Abstract Some Controller Partner Program uses 1

25 25 Ari Jaaksi 1997 / Roope Raisamo 2000 Base classes « mvclib » MVCBase_c « mvclib » MVCProgramBase_c « mvclib » MVCControllerBase_c « mvclib » MVCViewBase_c ownPrg_cownMainCo_c « mvclib » MVCModelBase_c ownModel_c « mvclib » MVCMainController Base_c « mvclib » MVCSubController Base_c « mvclib » MVCSubViewBase_c « mvclib » MVCMainView Base_c ownSubCo_c ownMainVi_c ownSubVi_c uses

26 26 Ari Jaaksi 1997 / Roope Raisamo 2000 References Krasner G.E., Pope S.T., "A Cookbook for Using the Model-View-Controller User Interface Paradigm in Smalltalk-80", Journal of Object-Oriented Programming, August/September, 1988. Jaaksi A., “Object-Oriented Development of Interactive Systems”, Diss. Tampere University of Technology, Publications 201, 1997. Jaaksi et al., “Tried & True Object Development - Industry-Proven Approaches with UML”, Cambridge University Press, 1999. NET internal training material, slidesets...


Download ppt "1 Ari Jaaksi 1997 / Roope Raisamo 2000 MVC++ application architecture Ari Jaaksi."

Similar presentations


Ads by Google