如果您最近观看了深入了解 Channel9 的节目,这是一个经常提到的主题是编程中的数学对偶性。 TomasP 有一篇关于面向对象编程中的对偶性的优秀博客文章。
自从微软研究院发现观察者设计模式实际上是迭代器模式的数学对偶以来,就出现了这种情况。从那时起,他们在 各种方式。
我的问题是:
编程中存在哪些数学对偶性?
面向对象编程是一个好的开始。主要的 GoF 设计模式有:Decorator、State、Iterator、Facade、Strategy、Proxy、Factory Method、Adapter、Observer、Template Method、Composite、Singleton、Abstract Factory 和 Command。 这里是一个很好的对象图海报。
If you have watched Going Deep shows of the Channel9 lately, one very frequently mentioned topic is mathematical duality in programming. TomasP has a good blog post about duality in object oriented programming.
This has been since Microsoft Research found that the observer design pattern is actually a mathematical dual of the iterator pattern. Since then they have used the duality concept in various ways.
My question is:
What mathematical dualities are there in programming?
Object oriented programming is a good start. The major GoF design patterns are: Decorator, State, Iterator, Facade, Strategy, Proxy, Factory Method, Adapter, Observer, Template Method, Composite, Singleton, Abstract Factory and Command. Here is a good object-graph-poster.
发布评论
评论(4)
我想说编程中的主要二元性是代码数据二元性,在 Lisp 中表现得最为明显,而且在大多数提供自省功能的当代语言中也很明显。
I'd say the primary duality in programming is the code-data duality, most clearly exposed in Lisp, but also clear in most contemporary languages which provide introspection functionality.
不确定这是否完全是您想要的,因为它更多的是 FP 而不是 OO,但当然有 柯里-霍华德对应(又名柯里-霍华德同构),将程序与证明“等同”,将类型与公式“等同”。
Not sure if it is entirely what you were looking for, as it's more FP than OO, but there is of course the Curry-Howard Correspondance (a.k.a. Curry-Howard Isomorphism) that "equates" programs with proofs and types with formulae.
你可能会争辩说,观察者/迭代器的二元性(在某种程度上,与我一起工作:-))是更一般的面向对象继承范式以及委托和聚合的替代范式的体现。在前者中,更专业的对象使用基本功能(指向上)来继承通用功能,而在后者中,更通用的对象使用委托来访问更专业的功能(指向下/出) - 关于 oo 这一事实有很多学术讨论。设计可以用任何一种形式来表达,并且由于形式之间的差异是(合理的)严格和定义的,我认为它可以被归类为双重
参见奥兰多条约 2 了解更多信息
You could argue that the duality of observer/iterator is (sort of, work with me here :-) ) a manifestation of the more general OO paradigms of inheritence and the alternate paradigm of delegation and aggregation. In the former, more specialized objects use base functionality (point up) to inherit general capabilities and in the latter, more generalized objects use delegation to access more specialized functionality (point down/out) - there is much academic discussion about the fact that oo designs can be expressed in either form, and since the variance between forms is (reasonably) rigourous and defined, I'd say it could be classified as a dual
See Treaty of Orlando 2 for more info
我认为对象和闭包/匿名函数是对偶的。
对象是一堆数据,具有一组“附加”到它的例程(即它的方法)。
从函数式编程的意义上来说,闭包是对函数的(可调用)引用,附加了一组数据(以其绑定的自由变量的形式)。
I think of objects and closures/anonymous functions as duals.
An object is a bunch of data, with a set of routines that are "attached" to it (i.e. its methods).
A closure, in the functional-programming sense of the word, is a (callable) reference to a function, with a set of data attached (in the form of its bound free variables).