<?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: Trent</title>
    <description>The latest articles on DEV Community by Trent (@dev_trent).</description>
    <link>https://dev.to/dev_trent</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%2F35493%2F7957ecd9-7b9b-40e6-beb5-65c389ada276.jpg</url>
      <title>DEV Community: Trent</title>
      <link>https://dev.to/dev_trent</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dev_trent"/>
    <language>en</language>
    <item>
      <title>Kotlin - First Impression</title>
      <dc:creator>Trent</dc:creator>
      <pubDate>Sun, 07 Jan 2018 16:23:21 +0000</pubDate>
      <link>https://dev.to/dev_trent/kotlin---first-impression-5f7a</link>
      <guid>https://dev.to/dev_trent/kotlin---first-impression-5f7a</guid>
      <description>&lt;p&gt;&lt;em&gt;Cross-post from &lt;a href="https://trent-dev.github.io/"&gt;Trent's Dev Blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It's been 3 weeks since I started a new project written entirely in Kotlin. These 3 weeks were great. I could enjoy functional programming from my Scala experience with strict static typing I always love. All of this, without sacrificing productivity. Great Kotlin features that I keep using are :  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kotlinlang.org/docs/reference/data-classes.html"&gt;Data Class&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can create immutable value classes with just one line of code. Java can do this too, but it's almost too verbose for Java to use it this way. It is very useful for declaring custom data types with small number of values. I mostly use it to enhance static typing of certain primitive type value sets. It is possible to include compile-time type checks for almost everything, while making code more concise and readable with less error-prone variable handling. &lt;a href="https://kotlinlang.org/docs/reference/multi-declarations.html"&gt;Destructuring Declarations&lt;/a&gt; makes it more easy and convenient to use.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kotlinlang.org/docs/reference/extensions.html"&gt;Extension Functions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Extension Functions really make Kotlin special compared to Java. It is almost too powerful, yet I find myself using it constantly. All the methods in Android you wish the library already had - whether it's simply starting an Activity or opening a Camera with specific parameters - are in your finger tips, such that you can customize the framework(or the language) any way you want. Be careful not to include any external state(variable) in the methods though. It might unnecessarily complicate the program(it would be similar to using a singleton to store state). If you are using Extension Functions merely for syntactic sugar, I suggest you decide the scope of the method carefully.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Higher-order functions(&lt;a href="https://medium.com/@tpolansk/the-difference-between-kotlins-functions-let-apply-with-run-and-else-ca51a4c696b8"&gt;&lt;code&gt;let&lt;/code&gt;, &lt;code&gt;apply&lt;/code&gt;, &lt;code&gt;run&lt;/code&gt;, &lt;code&gt;use&lt;/code&gt; etc.&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Functions like &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;apply&lt;/code&gt;, &lt;code&gt;run&lt;/code&gt;, &lt;code&gt;use&lt;/code&gt; are very valuable for keeping a clear code. They help to separate procedural code into blocks of operations performed on a variable. This is very useful, because even with Extension Functions it's impractical to hide all sequential operations to a variable in a separate function. In this aspect, &lt;code&gt;apply&lt;/code&gt; is very interesting, in that it is designed to couple variable assignment with custom initialization. Combined with &lt;code&gt;?&lt;/code&gt; operator, those functions can also keep unnecessary null checks to a minimum. Use them generously. Just keep in mind to don't nest them too much. In fact, I never nest them. It would introduce unnecessary depth, along with possible &lt;code&gt;it&lt;/code&gt; &amp;amp; &lt;code&gt;this&lt;/code&gt; &amp;amp; &lt;code&gt;return&lt;/code&gt; headaches.&lt;/p&gt;

&lt;p&gt;All in all, I think Kotlin is a very satisfying language. I plan to dive more deeper into the language, and explore more techniques for writing cleaner, more manageable code. I suggest you do too. Until next time!&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>programming</category>
      <category>tips</category>
    </item>
    <item>
      <title>Structure Over Familiarity</title>
      <dc:creator>Trent</dc:creator>
      <pubDate>Sat, 21 Oct 2017 09:16:07 +0000</pubDate>
      <link>https://dev.to/dev_trent/structure-over-familiarity-35e</link>
      <guid>https://dev.to/dev_trent/structure-over-familiarity-35e</guid>
      <description>&lt;p&gt;&lt;em&gt;Cross-post from &lt;a href="https://trent-dev.github.io/"&gt;Trent's Dev Blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Always prefer good structure over familiarity.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It worries me when some team members prefer shorter code &amp;amp; familiarity over maintainability &amp;amp; extensibility. To me, these aspects sound quite arbitrary. I think these aspects are more of a QoL(Quality of Life) improvements for the first developer working on the code, than actual better code. Good qualities to have, but not quite necessary. As modern software industry develops, codebases are getting larger and larger, and more people are being involved in a project. Thus, &lt;strong&gt;it is more important to write good structured code that team members can easily understand, compared to certain QoL improvements for the first writer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Also, some people argue that it is faster to program writing badly structured code. &lt;strong&gt;I argue that there is no trade-off between program time &amp;amp; code quality - in fact, I think quite the opposite, that it is faster to program even a mildly interesting program using good code structure.&lt;/strong&gt; Program with good structure may have more LOC compared to a hack job, but LOC doesn't necessarily equate time spent programming. Following a properly-learned good program structure helps a developer arrange program requirements into strict categories, thus helping them to make decisions faster and execute in confident manner. &lt;strong&gt;They can program freely, confident that their program will be easily readable &amp;amp; maintainable, and function correctly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In summary, following a good code structure is to be preferred against shorter code or familiarity. Also, it's a myth that it takes more time to program using a good code structure. &lt;strong&gt;We should strive to break out of the mold we are used to, and always improve, to write good structured code that can ease life for others.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>programming</category>
      <category>devtips</category>
    </item>
  </channel>
</rss>
