<?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: Owen Luke</title>
    <description>The latest articles on DEV Community by Owen Luke (@hiowenluke).</description>
    <link>https://dev.to/hiowenluke</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%2F209895%2F203b2494-b076-4ca7-a1f5-f00961c1e78d.jpeg</url>
      <title>DEV Community: Owen Luke</title>
      <link>https://dev.to/hiowenluke</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hiowenluke"/>
    <language>en</language>
    <item>
      <title>Why we should split long code into small functions or files?</title>
      <dc:creator>Owen Luke</dc:creator>
      <pubDate>Tue, 08 Oct 2019 15:00:13 +0000</pubDate>
      <link>https://dev.to/hiowenluke/why-we-should-split-long-code-into-small-functions-or-files-5gjl</link>
      <guid>https://dev.to/hiowenluke/why-we-should-split-long-code-into-small-functions-or-files-5gjl</guid>
      <description>&lt;p&gt;As they said:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Unix Principle&lt;/em&gt;: "Do one thing and do it well".&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Clean Code&lt;/em&gt;: "The first rule of functions is that they should be small".&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Node.js Best Practices&lt;/em&gt;: "Ensure that each unit is kept small and simple".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simply put, this can leads to &lt;strong&gt;MURDER&lt;/strong&gt; which is a good thing (the answer comes from &lt;a href="https://stackoverflow.com/questions/13256453/what-is-the-advantage-of-breaking-a-code-into-several-small-functions-in-c"&gt;stackOverflow&lt;/a&gt;, by John Dibling):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;M&lt;/strong&gt; - Maintainability. Smaller, simpler functions are easier to maintain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;U&lt;/strong&gt; - Understandability. Simpler functions are easier to understand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;R&lt;/strong&gt; - Reuseability. Encourages code reuse by moving common operations to a separate function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;D&lt;/strong&gt; - Debugability. It's easier to debug simple functions than complex ones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;E&lt;/strong&gt; - Extensibility. Code reuse and maintainability lead to functions that are easier to refactor in 6 months.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;R&lt;/strong&gt; - Regression. Reuse and modularization lead to more effective regression testing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Based on these principles, &lt;a href="https://github.com/hiowenluke/kdo"&gt;kdo&lt;/a&gt; was born as an open source project.&lt;/p&gt;

&lt;p&gt;You can easily split long code into small functions or files, execute them via kdo, makes the code clear, easy to read and maintain. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6caTp_Gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/hiowenluke/kdo/master/doc/img/demo0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6caTp_Gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/hiowenluke/kdo/master/doc/img/demo0.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VwbOK4o3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/hiowenluke/kdo/master/doc/img/demo1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VwbOK4o3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/hiowenluke/kdo/master/doc/img/demo1.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Very simple and useful, right? Just &lt;a href="https://github.com/hiowenluke/kdo"&gt;try it now&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
