Separation of concerns does not necessitate that you plan out every detail before you start coding. And agile does not mean that you just write the code down as it comes to mind. Agile means not being too attached to your initial idea of what the project will look like and to be ready to refactor should the need arise (as it usually does), not being afraid to throw big pieces of code out in the process.
Separation of concerns can very well make refactoring a lot easier, so MVC can be a big helper of agility.
Agile development is typically a process of rapid prototyping and refactoring. MVC's separation of concerns can often make both processes easier and faster.
话虽如此,MVC 模式具有巨大的吸引力。它如此有效的主要原因之一是它倾向于强调 API。这种隔离使得更改系统的某些部分变得更加容易,而不会对不相关的部分产生重大影响。如果系统的某个层有缺陷,通常很容易更改该层而不影响其他层,因为它们是由定义良好的 API 分隔的。如果 API 本身有缺陷,那么通常可以更改公开的 API,而不影响任一层的实际逻辑(尽管这往往比第一种缺陷更困难)。
Design patterns are a fundamental part of quick development. Popular design patterns are popular because they have wide utility. Relying heavily on patterns can make a workable architecture for a project crystallize much more quickly. The common vocabulary afforded by design patterns make it easier for a team to communicate the structures of a project and focus on the domain specific issues. Should one pattern turn out to be inconvenient for the progress of the project, the relation ship that pattern has with other alternatives are likely well understood, simplifying the task of refactoring to an alternative layout.
That being said, the MVC pattern has tremendous gravity. One of the major reasons it works so well is that it tends to emphasize API's. This sort of isolation makes it much easier to change certain parts of a system without having a major effect on unrelated parts. If a layer of the system has a defect, it's normally easy to alter that layer without affecting other layers, because they are separated by a well defined API. If an API is itself deficient, then it is often possible to alter the API exposed without effecting the actual logic of either layer (Although this tends to be more difficult than the first kind of deficiency).
When you find the right balance between structure and flexibility, it's worth its weight in gold.
I tend not to like most (current) MVC paradigms, because I believe they introduce pointless abstraction, reinvent the wheel, and add a lot of rigidity.
But I also tend to have highly structured programs that separate content from business logic from data access, and have as few "configurations" as possible in order to accomplish 1 thing. Ideally, to accomplish 1 thing, you should only have to edit 1-2 things.
Needless abstraction is the root of many problems.
The key phrase in agile is 'the simplest thing that could possibly work'.
If the simplest solution to a problem is:
a single script
a single web page
a single installation of a standard tool like a wiki
a single-user single-database 'just edit the data' editor
Then those won't have MVC, and will be the appropriate agile solutions.
If it is obvious from the start of the project that nothing like that is going to come close to solving the problem, it would be pointlessly literal process-following to try them and wait to fail before trying the next simplest solution.
发布评论
评论(5)
关注点分离并不需要您在开始编码之前计划好每个细节。敏捷并不意味着您只需将想到的代码写下来。敏捷意味着不要太执着于项目的最初想法,并准备好在需要时进行重构(就像通常那样),不要害怕在此过程中抛出大段代码。
关注点分离很好地使重构变得更加容易,因此 MVC 可以成为敏捷性的一大帮手。
Separation of concerns does not necessitate that you plan out every detail before you start coding. And agile does not mean that you just write the code down as it comes to mind. Agile means not being too attached to your initial idea of what the project will look like and to be ready to refactor should the need arise (as it usually does), not being afraid to throw big pieces of code out in the process.
Separation of concerns can very well make refactoring a lot easier, so MVC can be a big helper of agility.
敏捷开发通常是快速原型设计和重构的过程。 MVC 的关注点分离通常可以使这两个过程变得更容易、更快。
Agile development is typically a process of rapid prototyping and refactoring. MVC's separation of concerns can often make both processes easier and faster.
设计模式是快速开发的基本组成部分。流行的设计模式之所以流行,是因为它们具有广泛的实用性。严重依赖模式可以使项目的可行架构更快地具体化。设计模式提供的通用词汇使团队更容易交流项目的结构并专注于特定领域的问题。如果一种模式对项目的进展不方便,那么该模式与其他替代方案的关系很可能会被很好地理解,从而简化了重构为替代布局的任务。
话虽如此,MVC 模式具有巨大的吸引力。它如此有效的主要原因之一是它倾向于强调 API。这种隔离使得更改系统的某些部分变得更加容易,而不会对不相关的部分产生重大影响。如果系统的某个层有缺陷,通常很容易更改该层而不影响其他层,因为它们是由定义良好的 API 分隔的。如果 API 本身有缺陷,那么通常可以更改公开的 API,而不影响任一层的实际逻辑(尽管这往往比第一种缺陷更困难)。
Design patterns are a fundamental part of quick development. Popular design patterns are popular because they have wide utility. Relying heavily on patterns can make a workable architecture for a project crystallize much more quickly. The common vocabulary afforded by design patterns make it easier for a team to communicate the structures of a project and focus on the domain specific issues. Should one pattern turn out to be inconvenient for the progress of the project, the relation ship that pattern has with other alternatives are likely well understood, simplifying the task of refactoring to an alternative layout.
That being said, the MVC pattern has tremendous gravity. One of the major reasons it works so well is that it tends to emphasize API's. This sort of isolation makes it much easier to change certain parts of a system without having a major effect on unrelated parts. If a layer of the system has a defect, it's normally easy to alter that layer without affecting other layers, because they are separated by a well defined API. If an API is itself deficient, then it is often possible to alter the API exposed without effecting the actual logic of either layer (Although this tends to be more difficult than the first kind of deficiency).
当您在结构和灵活性之间找到适当的平衡时,它就物有所值。
我倾向于不喜欢大多数(当前的)MVC 范例,因为我相信它们引入了毫无意义的抽象,重新发明了轮子,并增加了很多僵化。
但我也倾向于使用高度结构化的程序,将内容与业务逻辑和数据访问分开,并且为了完成一件事而使用尽可能少的“配置”。理想情况下,要完成 1 件事,您只需编辑 1-2 件事。
不必要的抽象是许多问题的根源。
When you find the right balance between structure and flexibility, it's worth its weight in gold.
I tend not to like most (current) MVC paradigms, because I believe they introduce pointless abstraction, reinvent the wheel, and add a lot of rigidity.
But I also tend to have highly structured programs that separate content from business logic from data access, and have as few "configurations" as possible in order to accomplish 1 thing. Ideally, to accomplish 1 thing, you should only have to edit 1-2 things.
Needless abstraction is the root of many problems.
敏捷的关键词是“可能有效的最简单的事情”。
如果问题的最简单解决方案是:
那么这些就没有 MVC,并且将成为合适的敏捷解决方案。
如果从项目一开始就很明显,没有任何类似的方法能够接近解决问题,那么尝试它们并等待失败后再尝试下一个最简单的解决方案将是毫无意义的。
The key phrase in agile is 'the simplest thing that could possibly work'.
If the simplest solution to a problem is:
Then those won't have MVC, and will be the appropriate agile solutions.
If it is obvious from the start of the project that nothing like that is going to come close to solving the problem, it would be pointlessly literal process-following to try them and wait to fail before trying the next simplest solution.