对(基于 PHP 的)Web 应用程序使用 MVC 方法是否一定意味着它比其他方法更具可扩展性?
据我了解,MVC 框架相当庞大(Zend、Cake、CodeIngniter),因此谈论可扩展性并建议使用 MVC 似乎是相反的。
From what I understand MVC frameworks are pretty hefty (Zend,Cake,CodeIngniter), so it almost seems contrary to talk about scalability and suggest using MVC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Zend、Cake、CodeIgniter...它们都附带了一堆您不需要的东西。基本的 MVC 框架很简单,不需要很多文件即可工作。
此外,基于 MVC 结构构建的应用程序的可扩展性并不比其他方法高或低,但可能更有组织性。这是主观的。
Zend, Cake, CodeIgniter... they all come with a bunch of stuff you don't need. A basic MVC framework is simple, and does not need many files to work.
Also, applications built upon a MVC structure are no more or less scalable than other approaches may be, but may be more organized. It's subjective.
尽管 MVC 的要点很简单 - 将数据访问(模型)、GUI 创建(视图)和流程控制(控制器)作为单独的组件 - 但它可以通过非常不同的方式实现。
从纯粹的技术角度来看,MVC 与计算可扩展性关系不大。它更多地涉及人为因素,并有一种方法将大量代码组织成更容易理解的有意义的子单元。
Although the point of MVC is simple - having data access (Model), GUI creation (View) and flow control (Controller) as separate components - it can be implemented in very different ways.
From a purely technical viewpoint, MVC has very little to do with computational scalability. It's more about the human factor and having a way to organize huge piles of code into meaningful sub-units that are much easier to understand.
我每天都使用 codeigniter,与提到的其他人相比,它的重量非常轻。
您必须考虑到您可能不会使用最大框架中提供的大量功能,因此仅仅因为文件在那里,它不一定很重,除非您在实际执行代码中包含大量文件。
通过考虑何时以及何时不使用框架提供的功能,您可以帮助使您自己的代码在这些情况下具有可扩展性。好好学习内置函数的 PHP,因为它们几乎总是比框架中的任何东西都快(因为它们是用 C 编写的)。
一个好的框架实际上应该只是帮助您构建代码并在您需要时为您提供额外的功能,而不是通过大量额外的处理来拖累您的应用程序。
I work with codeigniter every day and compared to the others mentioned it's very light weight.
You have to consider that you will likely not use a lot of the functionality provided in the largest frameworks so just because the files are there, it's not necessarily heavy unless you include lots of the files in your actual executing code.
You can help make your own code scalable in these situations by considering when and when not to use functionality provided by the framework. Learn PHPs built in functions well as they will almost always be faster than anything in a framework (because they are written in C).
A good framework should really just help you structure you code and give you extra functionality when you ask for it, not lumber your application with a lot of extra processing.