Skip to content

Separation of algorithm and structure principle

将算法与结构进行分离原则。

在维基百科Visitor pattern中有如下描述:

In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying the structures.

在维基百科Iterator pattern中有如下描述:

The iterator pattern decouples algorithms from containers; in some cases, algorithms are necessarily container-specific and thus cannot be decoupled.

Generic programming

Separation of algorithm and structure也是generic programming的思想。