Misused design patterns

前端 未结 15 1460
故里飘歌
故里飘歌 2021-02-01 19:54

Are there, in the canonical Gang of Four list, any design patterns that you often find misused, misunderstood or overused (other than the highly debated Singleton)? In other wor

相关标签:
15条回答
  • 2021-02-01 20:54

    Factory Patterns...

    I was parachuted into a project before where every single MyObject in the system had an equivalent MyObjectFactory for generating new instances. There was no concept of abstraction or extended classes... just plain old ClassX & ClassXFactory.

    And no-one could explain why... "It was just the way things had always been done"

    0 讨论(0)
  • 2021-02-01 20:55

    The observer pattern is pretty useless in C# because it has events.

    0 讨论(0)
  • 2021-02-01 21:00

    Actually, what I see most often is the lack of use of an appropriate pattern. Typical scenario: me: "Hey, module A already has a piece of code that loops through a set of objects and performs database operation X on them, why didn't you reuse that code?" coder: "well, but I had to do operation Y on those objects." me: "what about using refactoring it to use the Command pattern to execute X or Y as appropriate?"

    I once saw usage of the Subject-Observer pattern get out of hand. It was implemented between processes using the database to persistently store the Subject. Because of the sheer number of updates to the subject, and the number of observers, the load on the database was tremendous, and caused an unforeseen system-wide slowdown.

    0 讨论(0)
提交回复
热议问题