Examples of misusing a design pattern

Design patterns are great in that they distill a potentially complex technique into something idiomatic. Often the fact that he has a name helps to communicate and understand.

The downside is that it’s easier to try and use them as a silver bullet, applying them to all situations without thinking about the motivation behind them, and taking second place to consider whether a given pattern is actually appropriate for the situation.

In contrast to this question , I am not looking for design patterns that are often misused, but I would like to see some examples of really solid design patterns, poor use. I'm looking for cases where someone "missed the point" and either applied the wrong pattern or even applied it poorly.

The point is, I would like to emphasize that design patterns are not an excuse to turn off critical analysis. Also, I want to emphasize the need to understand not only what patterns are, but why they are often a good approach.

+1


source to share


3 answers


I have an application that I maintain that uses the vendor pattern for pretty much everything - without too much trouble. Many levels of inheritance. As an example, there is a data provider interface that is implemented by the abstract BaseDataProvider, which in turn is extended by the SqlDataProvider. In each of the hierarchies, there is only one specific implementation of each type. Apparently the developer received a Microsoft document on the implementation of the Enterprise Architecture and, since many people use this application, decided that he needed all the flexibility to support multiple databases, multiple corporate directories and multiple calendering systems, although we only use MS SQL Server. Active Directory and Exchange.

To top it off, configuration elements such as credentials, URLs, and paths are hard-coded everywhere and override the data passed through parameters into more abstract classes. Changing this app is a lot like pulling thread on a sweater. The more you pull, the more things get unraveled and you end up making changes throughout your code to make something that should have been simple.



I'm slowly rewriting it - partly because the code is terrible and partly because there are actually three applications collapsed into one, one of which is not even needed.

+3


source


Good to share a little experience. In C #, I had a cool design that used a lot of templates. I really used them a lot to keep the story short, I won't name all of them. But when I actually tested with real data, 10 ^ 6 objects weren't "smooth" with my pretty designs. And while profiling it, I just saw that all those levels of indirection are beautifully class polymorphisms, proxies, etc. Were too big .. so I think I could rewrite it using a better template to make it more efficient, but I didn't have the time, so I practically hacked it procedurally and so far, well, it works better ... sigh, sad story.



+1


source


I saw an asp.net application where a developer (then a junior, now quite capable) managed to effectively make his codewords, counting each page as unique, which worked brilliantly on his local machine right up to the point where testers were fighting for control of the login screen ...

A purely misunderstanding of the realm of "unique" and the mind seeking to use these design patterns.

+1


source







All Articles