Table Data Gateway and Model

前端 未结 1 1807
眼角桃花
眼角桃花 2021-01-22 22:00

I\'ve heard the phrase \"fat model, thin controller\" and believe I understand it\'s implications. While working through the Zend Quickstart Guide I have come across the Table D

相关标签:
1条回答
  • 2021-01-22 22:46

    The MVC schema could be updated as follow :

    +------------+
    | Controller |
    +------------+
        ^   ^
        |   |          +------------+      +-------------+
        |   |------->  | Model      | <--> | Data access |
        |   |          +------------+      +-------------+
        |   |
        v   v
    +------------+
    | View       |
    +------------+
    

    The data access part is just an other level of abstraction (based on the Data Gateway design pattern, or any other pattern/technique) which is the specific part that talk to your persistent level (text files, database or any other) which can be easily replaced if you ever need to change your persistent level in your application (ie: going from MySQL to Oracle).

    This way, the only part you have to rewrite is the data access level and the rest of the application is still working. The task of the model is now to format data in a way that can be used either by the controller or by the view.

    This might not be the best or the most complete answer, but its at least a beginning.

    0 讨论(0)
提交回复
热议问题