In MVC where do you put references to your model Classes?

前端 未结 5 1673
野的像风
野的像风 2021-02-04 06:33

I have been wondering for a while, after asking different people and without any of them providing what I would call an \"at least a bit concrete answer\":

Quest

5条回答
  •  执念已碎
    2021-02-04 07:26

    In my applications I usually rename the AppDelegate class to AppController, if that helps explain things better conceptually. Your app controller is responsible for creating and/or configuring the model controller (which manages your collection of model objects) and window or view controllers, setting up references between them if needed, and calling methods on these controllers in response to NSApplication delegate methods or high level action methods from the main menu. Depending on how complex your application is you might also have additional model or view controllers which are created outside your app controller.

    Of course if you have a simple application there's no real reason not to have your app controller play the role of the model controller if you want. What you want to avoid is file with hundreds of lines of code, all doing conceptually unrelated tasks.

提交回复
热议问题