机制mechanism 策略 policy。Xwindow的设计准则里边有一条:提供机制,而不是提供策略。不明白,g之。
机制就是提供的功能,比如在驱动程序的编写中,你要提供怎样和硬件交流的方式,这就叫机制。 而策略则是指你怎样去使用已有的机制完成你自己的特定的功能,比如在驱动程序的编写中,你该怎样去利用硬件机制完成特定的功能。
不仅仅在驱动方面,在很多,如网络安全方面都有相应的概念。
The distinction between mechanism and policy is one of the best ideas behind the
Unix design. Most programming problems can indeed be split into two parts:
“what capabilities are to be provided” (the mechanism) and “how those capabilities
can be used” (the policy). If the two issues are addressed by different parts of
the program, or even by different programs altogether, the software package is
much easier to develop and to adapt to particular needs.
摘自ldd2英文版。就是说机制(mechanism)是"what", 而策略(policy)是"how"。