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.

120 lines
4.7 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 - Be Ready To Throw Your Code Away</h1>
<span class="post-date">
2019-06-19
<a href="https://blog.juliobiason.me/tags/book/">#book</a>
<a href="https://blog.juliobiason.me/tags/things-i-learnt/">#things i learnt</a>
<a href="https://blog.juliobiason.me/tags/code/">#code</a>
</span>
<p>A lot of people, when they start with TDD, get annoyed when you say that you
may have to rewrite a lot of stuff, including whatever your already wrote.</p>
<span id="continue-reading"></span>
<p>TDD was <em>designed</em> to throw code away: The more you learn about your problem,
the more you understand that, whatever you wrote, won't solve the problem in
the long run. Also, as you slowly solve new problems, you may notice some
pattern in the code emerging (you're doing the same thing over and over, with
only minor changes). That's a good time to go over and rewrite everything to
take advantage of this pattern.</p>
<p>You shouldn't worry about this. Your code is not a wall (or any physical
object): if you have to throw it away, you didn't wasted materials. Surely it
means your time writing code was lost, but you got a better understanding
about the problem now, or you may start to think in a more concise way to
solve the problem.</p>
<p>Not only that, but as you progress through your project, solving problems and
getting &quot;acquainted&quot; with the problem, you'll also notice that the
<a href="/books/things-i-learnt/spec-first">spec</a> will also change. This means that
the problem your code solve wasn't exactly the problem you <em>needed</em> to solve;
your code is trying to solve something that isn't exactly the problem.</p>
<p>Also, specs changing is really common. One thing that you can be sure is that
it won't change <em>everywhere</em>. Some of the things you solved will stay the
same, some others will be completely removed and some others added. And you
will see that you'll refactor your code a lot, and throw a lot of code away.
And not just code that solves the problem, but also the tests for that code.</p>
<p>... unless you focus mostly on <a href="/books/things-i-learnt/integration-tests">integration
tests</a>.</p>
<div>
<div style="float:left">
&lt;&lt; <a href="&#x2F;books&#x2F;things-i-learnt&#x2F;paper-notes">Be Ready To Throw Your Code Away</a>
</div>
&nbsp;
<div style="float:right">
<a href="&#x2F;books&#x2F;things-i-learnt&#x2F;future-trashing">Future Thinking Is Future Trashing</a> &gt;&gt;
</div>
</div>
</div>
</div>
</body>
</html>