<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Guilherme Froes</title>
    <description>The latest articles on DEV Community by Guilherme Froes (@guifroes).</description>
    <link>https://dev.to/guifroes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F116%2Fbdab20a5-236f-4420-8b64-eb91e1221d74.jpeg</url>
      <title>DEV Community: Guilherme Froes</title>
      <link>https://dev.to/guifroes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/guifroes"/>
    <language>en</language>
    <item>
      <title>TDD: Act-First to Drive Design</title>
      <dc:creator>Guilherme Froes</dc:creator>
      <pubDate>Fri, 14 Aug 2020 00:32:22 +0000</pubDate>
      <link>https://dev.to/guifroes/tdd-act-first-to-drive-design-3ob</link>
      <guid>https://dev.to/guifroes/tdd-act-first-to-drive-design-3ob</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I know tests should drive the design, but I never really understood how to do it. And I don’t feel like asking so people don’t think I’m anti-TDD.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;One of my students&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Over the years being a tech lead, I saw this is a common challenge. And that having tests driving the design is difficult because we have to think differently.&lt;/p&gt;

&lt;p&gt;I know a trick for that: you have to write the tests in a different way.&lt;/p&gt;

&lt;p&gt;I’ll show you.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a good test looks like
&lt;/h2&gt;

&lt;p&gt;A good test follows Act, Arrange, Assert, the famous AAA format.&lt;/p&gt;

&lt;p&gt;Arrange is where you set up the test. You create objects, data, configurations. Everything necessary for the test to run.&lt;/p&gt;

&lt;p&gt;Act is where you execute the code to be tested.&lt;/p&gt;

&lt;p&gt;Assert is where you check if the result is correct. You compare it with what you expected.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;10H 10C 10S 10D 2H is a four of a kind&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// arrange&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;hand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;PokerHand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;10H 10C 10S 10D 2H&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// act&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;//assert&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;handName&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Four of a kind&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You read the test in the chronological order in which things happen: first arrange, then act and finally assert.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to write tests
&lt;/h2&gt;

&lt;p&gt;But that’s not the order you should write the test.&lt;/p&gt;

&lt;p&gt;Kent Beck, the person who “&lt;a href="https://www.quora.com/Why-does-Kent-Beck-refer-to-the-rediscovery-of-test-driven-development-Whats-the-history-of-test-driven-development-before-Kent-Becks-rediscovery"&gt;rediscovered&lt;/a&gt;” TDD, recommends writing the test in reverse, beginning with the assert, followed by the act and then arrange.&lt;/p&gt;

&lt;p&gt;Check it out:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When I test assert-first, I find it has a powerful simplifying effect. When you are writing a test, you are solving several problems at once, even if you no longer have to think about the implementation.&lt;/p&gt;

&lt;p&gt;Where does the functionality belong? Is it a modification of an existing method, a new method on an existing class, an existing method name implemented in a new place, or a new class?&lt;/p&gt;

&lt;p&gt;What should the names be called?&lt;/p&gt;

&lt;p&gt;How are you going to check for the right answers?&lt;/p&gt;

&lt;p&gt;What is the right answer?&lt;/p&gt;

&lt;p&gt;What other tests does this test suggest?&lt;/p&gt;

&lt;p&gt;Pea-sized brains like mine can’t possibly do a good job of solving all of these problems at once. The two problems from the list that can be easily separated from the rest are: “What is the right answer?” And “How am I going to check?&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Kent Beck, on Test Driven Development: By Example &lt;strong&gt;(page 128, &lt;strong&gt;Assert First&lt;/strong&gt;)&lt;/strong&gt;&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Kent argues that by writing the assert first, you’ll have the answers for these questions right away and then work backwards to answer the other ones.&lt;/p&gt;

&lt;p&gt;I agree, but only if your main purpose for testing is making sure the result is correct.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Driven &lt;del&gt;Development&lt;/del&gt; Design
&lt;/h2&gt;

&lt;p&gt;When we’re designing, we’re creating how the object interacts with the world. When we’re designing, more important than the operation’s results, is the operation in itself: its name, its dependencies, parameters format and name, result type and so on.&lt;/p&gt;

&lt;p&gt;What matters is not the answers to those questions, but to these ones:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Where does the functionality belong? Is it a modification of an existing method, a new method on an existing class, an existing method name implemented in a new place, or a new class?&lt;/p&gt;

&lt;p&gt;What should the names be called?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And if this is the most important, the executed code should be the focus of the test. The result is secondary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you want to use tests to drive the design, test act-first.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Do it this way and see how your mind will flow from “test mode” to “design mode”.&lt;/p&gt;

&lt;p&gt;(Header photo by &lt;a href="https://unsplash.com/@rodlong?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Rod Long&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/act?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;)&lt;/p&gt;




&lt;p&gt;Learn how to fix the most common software design mistake people make. &lt;a href="https://guifroes.com"&gt;Subscribe to my newsletter&lt;/a&gt; and get the FREE email course.&lt;/p&gt;




&lt;p&gt;The post &lt;a href="https://guifroes.com/tdd-act-first-to-drive-design/"&gt;TDD: Act-First to Drive Design&lt;/a&gt; appeared first on &lt;a href="https://guifroes.com"&gt;gui froes&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>tdd</category>
      <category>testing</category>
      <category>softwaredesign</category>
      <category>oop</category>
    </item>
    <item>
      <title>Solving Real World Bad Design by Applying the Tell, don’t Ask Principle</title>
      <dc:creator>Guilherme Froes</dc:creator>
      <pubDate>Thu, 28 Feb 2019 18:02:00 +0000</pubDate>
      <link>https://dev.to/guifroes/solving-real-world-bad-design-by-applying-the-tell-don-t-ask-principle-607</link>
      <guid>https://dev.to/guifroes/solving-real-world-bad-design-by-applying-the-tell-don-t-ask-principle-607</guid>
      <description>&lt;p&gt;Can you spot bad design when you see it? Can you tell what’s wrong here?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (!response.getStatusCode().is2xxSuccessful()) {
    logError(response.getBody()); 
    throwException(response.getStatusCode()); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The snippet above is an example of a pattern we often see in the wild:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(someObject.getSomeAttribute()) { 
    doSomethingWith(someObject); 
} else { 
    doSomethingElse(someObject); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Why should I care?
&lt;/h2&gt;

&lt;p&gt;For us to understand what are the issues and why this is bad design, let’s take a look at the full picture. This is where that snippet came from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class PaymentProcessorClient { 
// some code removed for brevity's sake 
    public Sale processPayment(Payment payment) {
        ResponseEntity&amp;lt;Sale&amp;gt; response = rest.postForEntity("https://payment.com/payment", payment, Sale.class);

        if (!response.getStatusCode().is2xxSuccessful()) {
            logError(response.getBody()); 
            throwException(response.getStatusCode()); 
        } 
        logSuccessfulPayment(payment, response.getBody()); 
        return response.getBody(); 
    } 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This class is what is usually called a &lt;em&gt;client&lt;/em&gt;, its purpose is to talk to some external service. In this particular case, it is responsible for creating a payment on the fictional &lt;em&gt;payment.com&lt;/em&gt; web service.&lt;/p&gt;

&lt;p&gt;(By the way, this is real code from a real product that my team is working on right now. I just made some minor changes to preserve our client’s identity and not to expose them to any risk. I also removed some code to save space. These changes should not interfere with the understanding of the concept I’m trying to explain here.)&lt;/p&gt;

&lt;p&gt;Let’s take a closer look on the &lt;em&gt;processPayment&lt;/em&gt; method. The first line is where the main functionality is: it makes the call to the service and saves the response in the &lt;em&gt;response&lt;/em&gt; variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ResponseEntity&amp;lt;Sale&amp;gt; response = rest.postForEntity("https://payment.com/payment", payment, Sale.class);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next, it looks into &lt;em&gt;response&lt;/em&gt; and, if the payment creation was not successful, it logs an error and throws an exception:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (!response.getStatusCode().is2xxSuccessful()) { 
    logError(response.getBody()); 
    throwException(response.getStatusCode()); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If the payment creation went fine, it logs the result and returns the response body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logSuccessfulPayment(payment, response.getBody()); 
return response.getBody();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This code works, but as I said, it could be better designed. I’m going to show why and how.&lt;/p&gt;

&lt;h3&gt;
  
  
  It leads to duplication
&lt;/h3&gt;

&lt;p&gt;In our example, every time you make a call to the external service, you have to check the response and do something based on what that response looks like. If you have 3 operations like “make a payment”, “void a payment” and “do a refund”, you would have this structure repeated 3 times.&lt;/p&gt;

&lt;p&gt;Code duplication is bad on itself, but the real problem is the duplication of an idea, or concept – &lt;em&gt;based on what the response looks like, do something with it&lt;/em&gt;. This concept is expressed in multiple places in your code and, because of that, if it changes, or the implementation changes, you need to change in all the places it is expressed, which is very inefficient and error prone.&lt;/p&gt;

&lt;p&gt;The duplication also makes it harder to reuse the code since the concept is not isolated and expressed in one unique way and place.&lt;/p&gt;

&lt;h3&gt;
  
  
  It increases coupling
&lt;/h3&gt;

&lt;p&gt;When we have something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;response.getStatusCode().is2xxSuccessful()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;PaymentProcessorClient&lt;/em&gt; class needs to know how the &lt;em&gt;response&lt;/em&gt; and the &lt;em&gt;statusCode&lt;/em&gt; objects are implemented. It needs to know that &lt;em&gt;response&lt;/em&gt; object has a &lt;em&gt;getStatusCode&lt;/em&gt; method and that the &lt;em&gt;statusCode&lt;/em&gt; object has a &lt;em&gt;is2xxSuccessful&lt;/em&gt; method. This knowledge about how other objects are implemented is a form of &lt;strong&gt;coupling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What happens if one of these object’s implementation change? What if the &lt;em&gt;is2xxSuccessful&lt;/em&gt; method gets deprecated and replaced by &lt;em&gt;is201Created&lt;/em&gt; or something similar? You would have to go into your &lt;em&gt;PaymentProcessorClient&lt;/em&gt; code and change it. You would have to change one class for other reason than a change in the main logic or responsibility of the class.&lt;/p&gt;

&lt;p&gt;This excessive and unnecessary coupling (plus the duplication issue I talked above) have cascading effects, making one change to one class trigger a wave of changes throughout your code base. It shouldn’t be hard to see why this is dangerous and highly undesirable.&lt;/p&gt;

&lt;h3&gt;
  
  
  It clutters the code
&lt;/h3&gt;

&lt;p&gt;Let’s remember what the &lt;em&gt;PaymentProcessorClient&lt;/em&gt; and &lt;em&gt;processPayment&lt;/em&gt; method are supposed to do: talk to external payment service and make a payment.&lt;/p&gt;

&lt;p&gt;Now, notice all the code that’s not strictly making a payment on the service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Sale processPayment(Payment payment) { 
    ResponseEntity&amp;lt;Sale&amp;gt; response = rest.postForEntity("https://payment.com/payment", payment, Sale.class); 

    if (!response.getStatusCode().is2xxSuccessful()) { 
        logError(response.getBody()); 
        throwException(response.getStatusCode()); 
    } 

    logSuccessfulPayment(payment, response.getBody()); 
    return response.getBody(); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We have code looking into the response, code logging information and code throwing exceptions. All of this needs to happen, but they’re more surrounding or supporting the main idea of this class. Their presence also makes it harder to read and understand the idea of &lt;em&gt;PaymentProcessorClient.processPayment,&lt;/em&gt; making it harder and more expensive to maintain this code.&lt;/p&gt;

&lt;h2&gt;
  
  
  How can you make this better?
&lt;/h2&gt;

&lt;p&gt;The solution here is to separate the two concepts that are tangled up:&lt;/p&gt;

&lt;p&gt;Concept 1: making the call to the external service;&lt;/p&gt;

&lt;p&gt;Concept 2: act based on the response from the service.&lt;/p&gt;

&lt;p&gt;The first concept is implemented by &lt;em&gt;PaymentProcessorClient&lt;/em&gt;‘s &lt;em&gt;processPayment&lt;/em&gt; method, we still need to find a home for the second one. Since it involves looking into the &lt;em&gt;response&lt;/em&gt; and based on that doing something with the &lt;em&gt;response&lt;/em&gt;, having this concept implemented by the &lt;em&gt;response&lt;/em&gt; object – or something similar, sounds reasonable. Let’s see what it could look like.&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;The first thing we need to do is to rename the &lt;em&gt;Sale&lt;/em&gt; object to &lt;em&gt;SaleDTO&lt;/em&gt;. So far, what we’ve been calling sale is just what the external service sends back to us after we make a payment. It’s just a data structure, so it makes sense to rename it &lt;em&gt;SaleDTO&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public SaleDTO processPayment(Payment payment) {
    ResponseEntity&amp;lt;SaleDTO&amp;gt; response = rest.postForEntity("https://payment.com/payment", payment, SaleDTO.class); 

    if (!response.getStatusCode().is2xxSuccessful()) { 
        logError(response.getBody()); 
        throwException(response.getStatusCode()); 
    } 

    logSuccessfulPayment(payment, response.getBody()); 
    return response.getBody(); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;SaleDTO&lt;/em&gt; just holds the data we get back from the service. We need a real object that implements the concept of a sale and will have the behaviour we want – that was previously done by &lt;em&gt;PaymentProcessorClient&lt;/em&gt;. Let’s create a new class &lt;em&gt;Sale&lt;/em&gt;, and it will be what we return from &lt;em&gt;processPayment&lt;/em&gt; method. &lt;em&gt;Sale&lt;/em&gt; will be built with a &lt;em&gt;ResponseEntity&lt;/em&gt; object and the &lt;em&gt;Payment&lt;/em&gt; object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Sale processPayment(Payment payment) { 
    ResponseEntity&amp;lt;SaleDTO&amp;gt; response = rest.postForEntity("https://payment.com/payment", payment, SaleDTO.class); 

    if (!response.getStatusCode().is2xxSuccessful()) { 
        logError(response.getBody()); 
        throwException(response.getStatusCode()); 
    } 

    logSuccessfulPayment(payment, response.getBody()); 
    return new Sale(payment, response); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next, we move the behaviour that was previously on &lt;em&gt;PaymentProcessorClient&lt;/em&gt; to &lt;em&gt;Sale&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Sale { 

    public Sale(Payment payment, ResponseEntity&amp;lt;SaleDTO&amp;gt; saleResponse) { 
        this.saleResponse = saleResponse; 

        if (isResponseUnsuccessful()) { 
            logError(saleResponseBody()); 
            throw new Exception(saleResponseStatusCode()); 
        } 

        logSuccessfulPayment(payment, saleResponseBody()); 
    } 

    private SaleDTO saleResponseBody() { 
        return this.saleResponse.getBody(); 
    } 

    private HttpStatusCode saleResponseStatusCode() { 
        return this.saleResponse.getStatusCode(); 
    } 

    private boolean isResponseUnsuccessful() { 
        return !saleResponseStatusCode().is2xxSuccessful(); 
    } 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The last step is to clean &lt;em&gt;PaymentProcessorClient&lt;/em&gt;‘s &lt;em&gt;processPayment&lt;/em&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Sale processPayment(Payment payment) { 
    ResponseEntity&amp;lt;SaleDTO&amp;gt; response = rest.postForEntity("https://payment.com/payment", payment, SaleDTO.class); 
    return new Sale(response, payment); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We applied here the &lt;a href="https://martinfowler.com/bliki/TellDontAsk.html"&gt;Tell, don’t ask&lt;/a&gt; principle. Instead of asking an object something about it and then doing something with the object or asking it to do something, we just tell the object what we want, and it should take care of it. In our case we just tell the object to exist!&lt;/p&gt;

&lt;p&gt;Now we have a clean &lt;em&gt;PaymentProcessorClient&lt;/em&gt; and a &lt;strong&gt;smart&lt;/strong&gt; _ &lt;strong&gt;Sale&lt;/strong&gt; _ &lt;strong&gt;object that knows what to do&lt;/strong&gt; when something goes wrong. Let’s see how this design solves the problems we described.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is the design better now?
&lt;/h2&gt;

&lt;p&gt;The need for duplication of the concept – reacting to a bad response – is gone. It is implemented by the &lt;em&gt;Sale&lt;/em&gt; class that is created to capture the response of all operations on the external service, like refund and void payments.&lt;/p&gt;

&lt;p&gt;Coupling between &lt;em&gt;PaymentProcessorClient&lt;/em&gt; and the &lt;em&gt;Response&lt;/em&gt; and &lt;em&gt;StatusCode&lt;/em&gt; classes is gone. Those are now coupled to the &lt;em&gt;Sale&lt;/em&gt; class, which feels better to me because they are more related to each other.&lt;/p&gt;

&lt;p&gt;We made those classes a little less coupled, isolating the dependency on private methods by using the &lt;a href="https://www.martinfowler.com/bliki/SelfEncapsulation.html"&gt;SelfEncapsulation&lt;/a&gt; technique. Check out &lt;em&gt;saleResponseBody&lt;/em&gt;, &lt;em&gt;saleResponseStatusCode&lt;/em&gt; and &lt;em&gt;isResponseUnsuccessful&lt;/em&gt; methods.&lt;/p&gt;

&lt;p&gt;Some coupling will always exist since objects need to know something about each other in order to collaborate and work together.&lt;/p&gt;

&lt;p&gt;The code also looks cleaner and more understandable since we moved it to more appropriate locations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Easy to spot, simple to fix, big impact
&lt;/h2&gt;

&lt;p&gt;Every time you see this pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(someObject.getSomeAttribute()) { 
    doSomethingWith(someObject); 
} else { 
    doSomethingElse(someObject); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There’s a very good chance that there’s an opportunity for design improvement.&lt;/p&gt;

&lt;p&gt;This design leads to duplication, unnecessary coupling and cluttered code.&lt;/p&gt;

&lt;p&gt;Identifying some underlying concept and moving it to its proper object will get you code that’s easier, cheaper and more pleasurable to write and maintain.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://guifroes.com/real-world-tell-dont-ask/"&gt;Solving Real World Bad Design by Applying the Tell, don’t Ask Principle&lt;/a&gt; appeared first on &lt;a href="https://guifroes.com"&gt;Gui Froes&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>oop</category>
      <category>architecture</category>
      <category>java</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Build people, not tech</title>
      <dc:creator>Guilherme Froes</dc:creator>
      <pubDate>Mon, 04 Feb 2019 23:53:49 +0000</pubDate>
      <link>https://dev.to/guifroes/build-people-not-tech-31kk</link>
      <guid>https://dev.to/guifroes/build-people-not-tech-31kk</guid>
      <description>&lt;p&gt;Retrospectives, build-measure-learn and continuous improvement are all activities and practices that companies and their agile teams do to support project delivery and product development.&lt;/p&gt;

&lt;p&gt;I think this is wrong.&lt;/p&gt;

&lt;p&gt;These things are way too important to be only supporting the business.&lt;/p&gt;

&lt;p&gt;Not long ago, businesses used technology to accelerate, to automate, to improve themselves somehow. Teams would form, the technological product would be built, and the business would cary on with its life.&lt;/p&gt;

&lt;p&gt;It is different now. &lt;strong&gt;The business is the technology.&lt;/strong&gt; The very existence of the business depends on the continuous production and operation of technology.&lt;/p&gt;

&lt;p&gt;Because of that, companies should focus not on producing technology but on continuously cultivating people’s capabilities.&lt;/p&gt;

&lt;p&gt;Retrospectives, build-measure-learn and continuous improvement must abandon the position of supporting activities and occupy business’ center of attention. Teams and their learning capabilities – not their products – are business’ competitive advantage. And this should reflect on investments, recruiting and promotions.&lt;/p&gt;

&lt;p&gt;Technology companies must transform into knowledge and skills companies.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://guifroes.com/build-people-not-tech/"&gt;Build people, not tech&lt;/a&gt; appeared first on &lt;a href="https://guifroes.com"&gt;Gui Froes&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>business</category>
      <category>organizations</category>
      <category>agile</category>
    </item>
    <item>
      <title>Clever code is bad. Don’t write clever code.</title>
      <dc:creator>Guilherme Froes</dc:creator>
      <pubDate>Tue, 25 Sep 2018 01:27:44 +0000</pubDate>
      <link>https://dev.to/guifroes/clever-code-is-bad-don-t-write-clever-code-5ei</link>
      <guid>https://dev.to/guifroes/clever-code-is-bad-don-t-write-clever-code-5ei</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Wait! Isn’t code supposed to be smart? Programming IS hard! We have to be smart!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nope.&lt;/p&gt;

&lt;p&gt;Code is supposed to be simple. And programming is no place for being a smart-ass. Let me explain.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is clever code
&lt;/h2&gt;

&lt;p&gt;Clever code is code that when you read it your face goes like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8o-09x3w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/guifroes.com/wp-content/uploads/2018/09/confused-obama.jpg%3Ffit%3D300%252C225%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8o-09x3w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/guifroes.com/wp-content/uploads/2018/09/confused-obama.jpg%3Ffit%3D300%252C225%26ssl%3D1" alt="Obama looking confused"&gt;&lt;/a&gt;&lt;em&gt;“Interesting..”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Or like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tguJTjHs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/guifroes.com/wp-content/uploads/2018/09/will-smith-is-confused.jpg%3Ffit%3D640%252C387%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tguJTjHs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/guifroes.com/wp-content/uploads/2018/09/will-smith-is-confused.jpg%3Ffit%3D640%252C387%26ssl%3D1" alt="Will Smith looking confused"&gt;&lt;/a&gt;&lt;em&gt;“Oh! I get it..”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Or like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZUw819rQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/guifroes.com/wp-content/uploads/2018/09/mark-ruffalo_1646329c.jpg%3Ffit%3D460%252C288%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZUw819rQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/guifroes.com/wp-content/uploads/2018/09/mark-ruffalo_1646329c.jpg%3Ffit%3D460%252C288%26ssl%3D1" alt="Mark Ruffalo is confused"&gt;&lt;/a&gt;&lt;em&gt;“Riiight..”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clever code is code that should be instantly and effortlessly understood  –&lt;/strong&gt;  &lt;strong&gt;but it’s not.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It can exist in many forms. It can be that one liner that does too much.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;“WTF?”&lt;/em&gt; (Apparently, this multiplies it by 4 and makes it positive – who knows. Got it from &lt;a href="https://www.simplethread.com/dont-be-clever/"&gt;here&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;It can also be that super over designed set of classes that is so abstract that you spend an hour navigating the inheritance hierarchy and still have no idea what’s going on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w-EAvnMv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/guifroes.com/wp-content/uploads/2018/09/tumblr_o16n2kBlpX1ta3qyvo1_1280.jpg%3Fresize%3D1024%252C768%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w-EAvnMv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/guifroes.com/wp-content/uploads/2018/09/tumblr_o16n2kBlpX1ta3qyvo1_1280.jpg%3Fresize%3D1024%252C768%26ssl%3D1" alt=""&gt;&lt;/a&gt;&lt;em&gt;“See? It’s THAT simple!”&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“But that code looks pretty simple to me! What’s the problem?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yes, code cleverness is subjective, a matter of opinion. What is hard for me to understand might be easy to you. And that’s my point with this article:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We don’t write code for ourselves, we write for others (and the other might be future-you)!&lt;/strong&gt;&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--OKA2Lr3y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/705003311083229184/qTBCIxpk_normal.jpg" alt="Programming Wisdom profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Programming Wisdom
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="comment-mentioned-user" href="https://dev.to/codewisdom"&gt;@codewisdom&lt;/a&gt;

      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” - Martin Fowler
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      12:37 PM - 06 Jun 2018
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1004341385808539649" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1004341385808539649" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      521
      &lt;a href="https://twitter.com/intent/like?tweet_id=1004341385808539649" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      1468
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;Clever code is bad because if it’s not understandable it’s not maintainable.&lt;/p&gt;

&lt;p&gt;It’s bad because debugging it will take energy that could be applied to higher value activities such as building new features, improving tests, automating tasks or trying new technologies and tools that will deliver value to your customer.&lt;/p&gt;

&lt;p&gt;And it’s bad because it makes coding look harder than it is. It makes people feel that they don’t know stuff and causes friction where we should be making things easier, smoother.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level up as a developer
&lt;/h2&gt;

&lt;p&gt;Caring about the consequences of clever code and avoiding them is one of the things that makes you a senior developer, not the number of tricks or obscure language constructs, or your ability to write a whole program with one line of code.&lt;/p&gt;

&lt;p&gt;It’s common for beginners to write clever code. Not the absolute beginners – they are still learning the language – but those who are already fluent and learning new tricks. Those folks are proud and want to show off all their skills.&lt;/p&gt;

&lt;p&gt;We should learn new tricks but also learn when to use them. And more important: learn the fact that *&lt;em&gt;being capable of doing something, doesn’t mean that we should. *&lt;/em&gt; The same way you don’t wear shorts to a wedding and you don’t wear a suit to the beach, there’s a time and a place for everything.&lt;/p&gt;

&lt;p&gt;One sure way that I can spot a beginner is by the clever code one produces. It shows that the person doesn’t quite get that software development &lt;strong&gt;is a social activity&lt;/strong&gt; and that there’s no place for ego.&lt;/p&gt;

&lt;p&gt;A big part of the transition from beginner to senior dev is this understanding that our purpose is to build value to the organisation that employs us and that code is only a tool and should be treated as such.&lt;/p&gt;

&lt;p&gt;So, if you want to become a senior dev or a technical leader, you must master and teach less experienced folks how to keep the codebase clever code free.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;“Okay, got it. What should I do now?”&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;It’s hard not to let some clever code slip into the codebase every once in a while. After all, it’s not always evident that some code is clever – it might be simple to you, right?&lt;/p&gt;

&lt;p&gt;That’s why we need to watch ourselves all the time. Here’s a few ideas that will help:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Use the common way of doing stuff&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Usually, there is more than one way of doing something. Use the oldest, most boring, obvious way, that any beginner would understand. No magic, no frameworks, &lt;strong&gt;no anything that would require extra knowledge or brain cycles to understand.&lt;/strong&gt;  Instead of doing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;strcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Don’t try to save space on your hard drive or screen&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;It doesn’t matter if you end up with more code and bigger files: storage is cheap, people’s effort and time are expensive.&lt;/p&gt;

&lt;p&gt;Extract methods, use meaningful names – use as many words as you need to make your intent come across. Use spaces, line breaks, format accordingly. Turn this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;people&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;getAge&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;people2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;people3&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Into this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;allPeople&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;personNamed&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isAllowedToDrink&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;listOfDrinkingPeople&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;listOfNotDrinkingPeople&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Objects with behavior help a lot as well.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Get feedback&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Pair programming is great for this. Ask your colleague: “Do you understand this?” “Or is it better this way?” Look if they are making one those faces.&lt;/p&gt;

&lt;p&gt;Watch your own reaction for feedback: if you make a face reading some code you’ve written, change it!&lt;/p&gt;

&lt;p&gt;Do code reviews – have the team reading the code and giving feedback to one another.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s next?
&lt;/h2&gt;

&lt;p&gt;Now you know what clever code is, why it is bad and how not to write it. &lt;strong&gt;But what about the other people on your team? If you want to know how to talk them into writing clean code, checkout &lt;a href="https://guifroes.com/the-one-skill-i-wish-i-master-as-a-tech-lead/"&gt;this article&lt;/a&gt; in my site.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://guifroes.com/clever-code-is-bad/"&gt;Clever code is bad. Don’t write clever code.&lt;/a&gt; appeared first on &lt;a href="https://guifroes.com"&gt;Gui Froes&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cleancode</category>
      <category>beginners</category>
    </item>
    <item>
      <title>3 books that will take you to the next level</title>
      <dc:creator>Guilherme Froes</dc:creator>
      <pubDate>Fri, 23 Mar 2018 20:19:47 +0000</pubDate>
      <link>https://dev.to/guifroes/3-books-that-will-take-you-to-the-next-level-4b56</link>
      <guid>https://dev.to/guifroes/3-books-that-will-take-you-to-the-next-level-4b56</guid>
      <description>&lt;p&gt;You can write code and make the computer do what you want – no problem. You can even do it in more than one language and you’re fluent in many frameworks. You know all your data structures and algorithms and can use databases and external APIs without breaking a sweat. And you’ve been doing it for some years now.&lt;/p&gt;

&lt;p&gt;However, even with all this knowledge and skill and always getting the job done, sometimes you’re not sure if you’re doing it right.&lt;/p&gt;

&lt;p&gt;Maybe your code starts pretty good, everything in place and working fine, but after a while, when new functionality is being added, it starts to become confusing and messy. Or bugs start to pop up and it becomes harder and harder to fix stuff without breaking something else.&lt;/p&gt;

&lt;p&gt;You spend a lot of time chasing and killing bugs, and coding, which used to be fun, &lt;strong&gt;becomes frustrating&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You feel that there must be a better way to do things. And there is!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What you need is a new set of skills. &lt;strong&gt;You need to level up.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many ways to do it but here I’m going to recommend 3 books that will transform the way you think about and write code. Of course there are many more that are worth your time and money, but I think these 3 cover a lot of ground and will get you a great bang for you buck.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330/" rel="noopener noreferrer"&gt;Practical Object-Oriented Design in Ruby: An Agile Primer&lt;/a&gt; – Sandi Metz&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330/" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi2.wp.com%2Fguifroes.com%2Fwp-content%2Fuploads%2F2018%2F03%2Fpractical-object-oriented-design-in-ruby-metz-sandi.jpg%3Fresize%3D229%252C300%26ssl%3D1" alt="Practical Object-Oriented Design in Ruby book cover"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You probably think you know OOP but Sandi will show you there’s way more to it, and how proper OOP design allows you to write &lt;strong&gt;beautifully simple maintainable code&lt;/strong&gt;. It doesn’t really matter that the examples are in Ruby, the concepts are universal and if you’re familiar with any OOP language you should be good.&lt;/p&gt;

&lt;p&gt;By the way, Sandi is awesome and you should read all her books and watch all her talks. Seriously.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530" rel="noopener noreferrer"&gt;Test Driven Development: By Example&lt;/a&gt; – Kent Beck&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi2.wp.com%2Fguifroes.com%2Fwp-content%2Fuploads%2F2018%2F03%2Ftdd_by_example.jpg%3Fresize%3D240%252C300%26ssl%3D1" alt="Test-Driven Development By Example book cover"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TDD is a style of development where you write a tiny test, write the code to make the test pass, refactor the code and repeat this same short cycle for each new code behaviour. Those tests guide you to a better design while keeping a safety net for refactoring and fixing bugs. TDD by Example is the book where its creator (or “re-discoverer”) describes the classic technique that will, for sure, turn the way you write code upside down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627" rel="noopener noreferrer"&gt;Growing Object-Oriented Software, Guided by Tests&lt;/a&gt; – Steve Freeman &amp;amp; Nat Pryce&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Fguifroes.com%2Fwp-content%2Fuploads%2F2018%2F03%2Fgoos.jpg%3Fresize%3D225%252C300%26ssl%3D1" alt="Growing Object-Oriented Software, Guided by Tests book cover"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This book covers a lot of ground combining OOP design, TDD and use of Mock Objects for growing complex codebases. It describes the building of a system from scratch with the decisions, tools and techniques, all shown with the evolution of the code. It’s one of my very favorites and probably the one I recommend the most.&lt;/p&gt;

&lt;p&gt;As I said, there are many more excellent books I could recommend for someone aiming to acquire a more senior set of coding skills, but this short list should be enough to introduce you to a new world and bring you back the joy of programming.&lt;/p&gt;

&lt;p&gt;What are you waiting for?&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://guifroes.com/3-books-that-will-take-you-to-the-next-level/?utm_source=dev.to&amp;amp;utm_medium=post_footer"&gt;3 books that will take you to the next level&lt;/a&gt; appeared first on &lt;a href="https://guifroes.com/?utm_source=dev.to&amp;amp;utm_medium=post_footer"&gt;Gui Froes&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>books</category>
      <category>code</category>
      <category>craftsmanship</category>
    </item>
  </channel>
</rss>
