<?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: Ricardo Valencia</title>
    <description>The latest articles on DEV Community by Ricardo Valencia (@valenc3x).</description>
    <link>https://dev.to/valenc3x</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%2F31295%2F943c80fb-cead-4b8d-9abe-b2b72b8e2319.jpeg</url>
      <title>DEV Community: Ricardo Valencia</title>
      <link>https://dev.to/valenc3x</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/valenc3x"/>
    <language>en</language>
    <item>
      <title>Code consistency vs using new features</title>
      <dc:creator>Ricardo Valencia</dc:creator>
      <pubDate>Wed, 13 Jun 2018 22:43:31 +0000</pubDate>
      <link>https://dev.to/valenc3x/code-consistency-vs-using-new-features-38p2</link>
      <guid>https://dev.to/valenc3x/code-consistency-vs-using-new-features-38p2</guid>
      <description>&lt;p&gt;So, lets say you added a new feature to an existing Java project, and when adding unit test you see that other similar tests are using null checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&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="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Value should be 10"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&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;But you know about Optionals so your test could look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Optional&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofNullable&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;ifPresent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Value should be 10"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&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;Another example could be type annotations in Python&lt;/p&gt;

&lt;p&gt;Which is more important to you? Keep the code consistent but not using new features or use new features even if code will end up looking inconsistent?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Only considering that using or not using new features is not a decision based on performance, security or any other concern&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My initial approach would be keep it consistent but add a low priority task to refactor code if/when necessary, but curious to find out what others think.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>development</category>
    </item>
  </channel>
</rss>
