What is an anti-pattern?

前端 未结 14 1151
日久生厌
日久生厌 2020-12-04 04:52

I am studying patterns and anti-patterns. I have a clear idea about patterns, but I don\'t get anti-patterns. Definitions from the web and Wikipedia confuse me a lot.

<
14条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 05:14

    A pattern is an idea of how to solve a problem of some class. An anti-pattern is an idea of how not to solve it because implementing that idea would result in bad design.

    An example: a "pattern" would be to use a function for code reuse, an "anti-pattern" would be to use copy-paste for the same. Both solve the same problem, but using a function usually leads to more readable and maintainable code than copy-paste.

提交回复
热议问题