设计模式与反模式的区别

Difference between the design pattern and anti-pattern

我正在阅读有关设计软件架构的理论,我看到有一些理论,例如 SOLID 原则、设计模式和反模式,我们在设计软件时应该考虑这些理论。

我的问题:设计模式和反模式有什么区别,它们解决什么问题?

简单差异为:

设计模式:

软件工程师在多年实践和解决问题的过程中开发的高效解决方案。

反模式:

对于某些类型的问题实际上不好或有缺陷的已知解决方案。

来自维基百科:

An anti-pattern is a common response to a recurring problem that is usually ineffective and risks being highly counterproductive.[1][2] The term, coined in 1995 by Andrew Koenig,[3] was inspired by a book, Design Patterns, which highlights a number of design patterns in software development that its authors considered to be highly reliable and effective.

The term was popularized three years later by the book AntiPatterns, which extended its use beyond the field of software design to refer informally to any commonly reinvented but bad solution to a problem. Examples include analysis paralysis, cargo cult programming, death march, groupthink and vendor lock-in.

一些反模式的例子:

  1. https://javaantipatterns.wordpress.com/
  2. https://sourcemaking.com/antipatterns

希望这是有道理的。