开发者

MVC without ORM is not real MVC?

开发者 https://www.devze.com 2022-12-27 10:50 出处:网络
at the moment im integrating ORM (doctrine) into a MVC framework (codeigniter). then it hit me that this was the obvious way of setting up a MVC:

at the moment im integrating ORM (doctrine) into a MVC framework (codeigniter).

then it hit me that this was the obvious way of setting up a MVC:

the controller calls the models that are representing database tables.

look at this picture:

MVC + ORM

then i wondered, how can a MVC without ORM be real MVC? cause then the models are not real objects, rather aggregations of different functions that perform CRUD, then returning the result to the controller. and there is no need for a state (object properties) i guess so the functions would be all static?

correct me if im wrong on this one.

i guess a lo开发者_StackOverflow社区t of people are using models without ORM. please share your thoughts. how do your models look like?


MVC is a general purpose UI pattern originally conceived for OO languages (I believe Smalltalk was the first).

If you don't have a relational database as a back end (say, a binary serialized file format) you have no need of an ORM layer.

The two are quite distinct and can exist without each other.


MVC has nothing to do with objects. That makes it quite simple to have MVC without an ORM.


What about applications which don't use a database but use some other serialization for their data (such as writing out an XML file)? MVC and ORM are orthogonal concepts. MVC is about how you organize your internal object interactions, and ORM is about how you serialize and deserialize the model. You can certainly use MVC without ORM by simply substituting a different serialization method.

The controller part of MVC is not about making the low-level calls to serialize, it is about tying together views and models to create the proper user experience and task flow.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号