Java – models, views, and controllers – what should be created?

According to good programming practice, which controller, model and view components should be created first at the beginning of program running, and which should create the other two?

I mean, does the main function first create a controller, and then the controller should create models and views and make itself aware in some way?

Or should I first create the view and initialize the controller before displaying, which will create the model?

Or should the model come first? Or should they all be created in parallel in the main function? What is the correct way to implement MVC?

Editor: I'm interested in general answers, but I'm currently using java swing and Windows Phone 7

Solution

I think each one can be created separately

>If the controller is responsible for creating the model, this means that you cannot have a model without a controller, and there is always a one-to-one mapping between the model and the controller For example, for a website, you can have a controller for regular data and another XML version for that data (although this is usually the same controller, you only need to specify the protocol to use). > If the controller is responsible for creating the view, it ends with a one - to - one mapping between the controller and the view The controller only processes incoming requests, executes some logic, and provides answers It should not care who is asking for data For example, for web applications, you can use RSS feeds and HTML pages, both using the same controller Another example is your typical rails application where a controller maps to multiple views (index view, display view, edit view,...)

However, someone has a responsibility to integrate them, but this will be your main application and not a part of it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>