According to good programming practices, at the beginning of the program runtime, which of the Controller, Model and View components should be created first and which of them should create the other two?
I mean, should the main function first create the controller, then the controller should create both the model and the view and make itself known to them somehow?
Or should I rather begin with creating the view, which, before displaying itself, would initialise the controller, which would create the model?
Or maybe the model should come first? Or they all should be created in the main function in parallel? What's the right way of implementing MVC?
edit: I'm interested in a general answer, though currently I'm working with Java Swing and Windows Phone 7.
An MVD is a diagram that is used for defining how and what components will be used for an information exchange.
First, the browser sends a request to the Controller. Then, the Controller interacts with the Model to send and receive data. The Controller then interacts with the View to render the data. The View is only concerned about how to present the information and not the final presentation.
A view model or viewpoints framework in systems engineering, software engineering, and enterprise engineering is a framework which defines a coherent set of views to be used in the construction of a system architecture, software architecture, or enterprise architecture.
Model-View-Controller (MVC) concept is used in SAP UI5 development to keep the application data separate from the user interactions. This allows you to develop the web applications and make changes to the applications independently. Model-View-Controller plays a different role in UI development −
I'd say that Controller and Model objects could be created by main function while View should be created by Controller (possibly based on Model data).
Controller should be created by application main function (working trhead? whatever) whenever new request comes to application. A request may contain some serialized data which could be deserialized by main thread to create and fill new Model object which is in turn passed to Controller for further processing. When controller finishes processing it may (or may not) create a View to pass processing results to client.
Also a Model class could be created by Controller to serve data processing needs (save data to database etc.) or to serve as a base for return View.
Summarizing:
I think each of them can be created individually.
It is however someone's responsibility to tie them all together, but that would be your main application and neither one of those components
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With