separation of concerns

来源:互联网 发布:管家婆v7.2导入数据 编辑:程序博客网 时间:2024/05/12 14:45

In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections, such that each section addresses a separate concern.

The term separation of concerns was probably coined by Edsger W. Dijkstra in his 1974 paper "On the role of scientific thought".

Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that one is willing to study in depth an aspect of one's subject matter in isolation for the sake of its own consistency, all the time knowing that one is occupying oneself only with one of the aspects. We know that a program must be correct and we can study it from that viewpoint only; we also know that it should be efficient and we can study its efficiency on another day, so to speak. In another mood we may ask ourselves whether, and if so: why, the program is desirable. But nothing is gained —on the contrary!— by tackling these various aspects simultaneously. It is what I sometimes have called "the separation of concerns", which, even if not perfectly possible, is yet the only available technique for effective ordering of one's thoughts, that I know of. This is what I mean by "focusing one's attention upon some aspect": it does not mean ignoring the other aspects, it is just doing justice to the fact that from this aspect's point of view, the other is irrelevant. It is being one- and multiple-track minded simultaneously.

separation of concerts应该翻译为关注分离?之前没有看到过类似的概念,不知道正式的翻译是什么。其意思与模块化编程或者分层设计程序是相似。但是Dijkstra更多讲的思考方法,所以可以适用很多地方,如同分析综合法、辩证法。他的论文的英文表述方法比较奇怪,看不大懂。这里翻译个大概。

“以我的亲身经验来解释下智慧的思考方式有什么特点。当你想在某个领域的某个方面进行深入的研究时,必须让自己集中注意力在某一个点上。就像写程序一样,首先程序必须正确,然后还要有效率。但是当你在考虑程序正确性的时候,最好只集中在这一点,而效率是另一个问题,改天再考虑它吧。也许某天你还会问自己为什么需要写这个程序。如果同时思考好几个方面的问题,将会一无所获。我叫这“关注分离”——它即使不是完全可能的,至少也是最可行的方法,将你的想法有效的组织起来。我所说的“将你的注意集中到某一个点上”就是这个意思,并不是其他方面不重要,只是从当前这点来看,其他的问题是无关的。你的头脑有多条道路,每个道路通向不同的目的地,不能让它们相互串了。”


0 0