Skip to main content

Design Patterns are not solutions


Design Patters Should be Used to Name Solution, Not Find Them

Most of the times I saw design patterns being applied, they were applied as a way to find a solution, so you end up twisting a solution -- and, sometimes, the problem it self -- to fit the pattern.

My guess is that the heavy use of "let's apply this design pattern" before even understanding the problem -- or even trying to solve it -- comes as a form of cargo cult: "We saw that people used this pattern and solved their problem, so let's use it too and it will solve our problem". Or, worse: "Design pattern is described by Famous Person, so we must use it".

Here is the thing: Design pattern should not be used as a way to find solution to any problems. You may use some of them as base for your solution, but you must focus on the problem, not the pattern.

"Do a visitor pattern will solve this?" is the wrong question. "What should we do to solve our problem?" is the real question. Once you went there and solved the problem you may look back and see if it is a visitor pattern -- or whatever pattern. If it doesn't, that's alright, 'cause you solved the problem. If it did... well, congratulations, you now know how to name your solution.

I've seen this happening a lot: People have a problem; people decided to use a pattern; the pattern doesn't actually solve the problem (not in the 100% mark, but above 50%); what happens then is that people start twisting the problem to fit the pattern or, worse, add new layers to transform the problem into the pattern.

Source: https://blog.juliobiason.net/books/things-i-learnt

Whats your take on Design Patterns? Feel free to share your thoughts in comments below.





Comments

Popular posts from this blog

Team Work

Ramo Vigrahavan Dharmah

A great verse from Ramayana: आहार निद्रा भय मैथुनं च  सामान्यमेतत् पशुभिर्नराणाम् । धर्मो हि तेषामधिको विशेष:  धर्मेण हीनाः पशुभिः समानाः ॥ AhAra-nidrA-bhaya-maithunam cha samAnam_etat_pashubhir_narANAm | dharmo hi teShAm adhiko visheSho dharmeNa hInAH pashubhiH samAnAH|| Eating, Sleep, Fear and Sex ; these habits are common between human beings and animals. It is the Dharma which is the special quality of the human beings. Without the Dharma, they are similar to the animals.  Rama is The Embodiment Of Dharma.  Maaricha, while speaking to Ravana- (Aranya Kandam 37-13): रामो विग्रहवान् धर्मः साधुः सत्य पराक्रमः | राजा सर्वस्य लोकस्य देवानाम् इव वासवः || ३-३७-१३|| raamo vigrahavaan dharmaH saadhuH satya paraakramaH | raajaa sarvasya lokasya devaanaam iva vaasavaH || 3-37-13 "Rama is the embodiment of righteousness, he is an equable person with truthfulness as his valour, and as with Indra to all gods he is the king of entire world. [3-37-13] Another great phra

Microsoft moving to Live (Online sofware services)

Microsoft plans to launch Internet-based complements to its core products(Windows and Office), that create opportunities for the company to sell online subscriptions and advertising. Windows Live is a set of Internet-based personal services, such as e-mail, blogging and instant messaging. Office Live will come in both ad-based and subscription versions that augment MS' Office suite. The programs won't replace the paid software but instead seem aimed at capturing its online share. Windows Live at Live.com . From BBC The move to online software services is closely linked to the spread of high-speed access to the internet, as online software services are only as good as a user's access to the web. Mr Gates, who is Microsoft's chairman and chief software architect, said the strategic shift would change his company's approach to doing business: "We are trying to put a 'service plus software' mentality into many of the product groups inside Microsoft."