Design patterns vs Frameworks

后端 未结 12 1647
清歌不尽
清歌不尽 2021-01-31 10:52

Can someone illustrate what really is the difference between the two?

12条回答
  •  盖世英雄少女心
    2021-01-31 11:04

    Here is GOF's answer:

    Because patterns and frameworks have some similarities, people often wonder how or even if they differ. They are different in three major ways:

    • Design patterns are more abstract than frameworks. Frameworks can be embodied in code, but only examples of patterns can be embodied in code. A strength of frameworks is that they can be written down in programming languages and not only studied but executed and reused directly. In contrast, the design patterns in this book have to be implemented each time they're used. Design patterns also explain the intent, trade-offs, and consequences of a design.

    • Design patterns are smaller architectural elements than frameworks. A typical framework contains several design patterns, but the reverse is never true.

    • Design patterns are less specialized than frameworks. Frameworks always have a particular application domain. A graphical editor framework might be used in a factory simulation, but it won't be mistaken for a simulation framework. In contrast, the design patterns in this catalog can be used in nearly any kind of application. While more specialized design patterns than ours are certainly possible (say, design patterns for distributed systems or concurrent programming), even these wouldn't dictate an application architecture like a framework would.

提交回复
热议问题