The source content for blog.juliobiason.me
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.6 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!-- Enable responsiveness on mobile devices-->
<!-- viewport-fit=cover is to support iPhone X rounded corners and notch in landscape-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, viewport-fit=cover">
<title>Julio Biason .Me 4.3</title>
<!-- CSS -->
<link rel="stylesheet" href="https://blog.juliobiason.me/print.css" media="print">
<link rel="stylesheet" href="https://blog.juliobiason.me/poole.css">
<link rel="stylesheet" href="https://blog.juliobiason.me/hyde.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">
</head>
<body class=" ">
<div class="sidebar">
<div class="container sidebar-sticky">
<div class="sidebar-about">
<a href="https:&#x2F;&#x2F;blog.juliobiason.me"><h1>Julio Biason .Me 4.3</h1></a>
<p class="lead">Old school dev living in a 2.0 dev world</p>
</div>
<ul class="sidebar-nav">
<li class="sidebar-nav-item"><a href="&#x2F;">English</a></li>
<li class="sidebar-nav-item"><a href="&#x2F;pt">Português</a></li>
<li class="sidebar-nav-item"><a href="&#x2F;tags">Tags (EN)</a></li>
<li class="sidebar-nav-item"><a href="&#x2F;pt&#x2F;tags">Tags (PT)</a></li>
</ul>
</div>
</div>
<div class="content container">
<div class="post">
<h1 class="post-title">Things I Learnt The Hard Way - Design Patters Are Used to Name Solution, Not Find Them</h1>
<span class="post-date">
2019-06-25
<a href="https://blog.juliobiason.me/tags/books/">#books</a>
<a href="https://blog.juliobiason.me/tags/things-i-learnt/">#things i learnt</a>
<a href="https://blog.juliobiason.me/tags/design-patterns/">#design patterns</a>
</span>
<p>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.</p>
<span id="continue-reading"></span>
<p>My guess is that the heavy use of &quot;let's apply <em>this</em> design pattern&quot; before
even understanding the problem -- or even trying to solve it -- comes as a
form of <a href="/books/things-i-learnt/cargo-cult">cargo cult</a>: &quot;We saw that people
used this pattern and solved their problem, so let's use it too and it will
solve our problem&quot;. Or, worse: &quot;Design pattern is described by <em>Famous
Person</em>, so we must use it&quot;.</p>
<p>Here is the thing: Design pattern should <em>not</em> 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 <em>problem</em>, not the <em>pattern</em>. </p>
<p>&quot;Do a visitor pattern will solve this?&quot; is the wrong question. &quot;What should we
do to solve our problem?&quot; 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 <em>solved the problem</em>. If it
did... well, congratulations, you now know how to name your solution.</p>
<p>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.</p>
<div>
<div style="float:left">
&lt;&lt; <a href="&#x2F;books&#x2F;things-i-learnt&#x2F;gherkin">Gherkin Is Your Friend to Understand Expectations</a>
</div>
&nbsp;
<div style="float:right">
<a href="&#x2F;books&#x2F;things-i-learnt&#x2F;data-flow">Thinking Data Flow Beats Patterns</a> &gt;&gt;
</div>
</div>
</div>
</div>
</body>
</html>