<?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>Forem: Kiru</title>
    <description>The latest articles on Forem by Kiru (@kiru_io).</description>
    <link>https://forem.com/kiru_io</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%2F756519%2Fbece14fd-5dd3-4215-8317-31dbd5c0e767.jpg</url>
      <title>Forem: Kiru</title>
      <link>https://forem.com/kiru_io</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kiru_io"/>
    <language>en</language>
    <item>
      <title>Unconventional Programming Opinion: You become an unofficial maintainer once you update your framewor</title>
      <dc:creator>Kiru</dc:creator>
      <pubDate>Fri, 09 Jun 2023 11:40:40 +0000</pubDate>
      <link>https://forem.com/kiru_io/unconventional-programming-opinion-you-become-an-unofficial-maintainer-once-you-update-your-framewor-5dfg</link>
      <guid>https://forem.com/kiru_io/unconventional-programming-opinion-you-become-an-unofficial-maintainer-once-you-update-your-framewor-5dfg</guid>
      <description>&lt;p&gt;&lt;a href="https://kiru.io/blog/posts/2023/unconventional-programming-opinion-framework-maintainer/"&gt;I published this article on my blog.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TLDR: Dear framework developer, please consider us, the framework users, as the unofficial maintainer of your framework. When you change things, think about the wider cost.&lt;/p&gt;

&lt;p&gt;Warning: This is going to be a short gibberish, brain-fart and/or rant.&lt;/p&gt;

&lt;p&gt;Recently I was migrating a project from a framework v385 to v366 and felt the pain wasting time to apply some internal refactoring the framework team did to my own project.&lt;/p&gt;

&lt;p&gt;Imagine if I had the following functions in my code and I wanted to refactor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const isUnicorn = (animal) =&amp;gt; {
  return hornCheck(animal)
        &amp;amp;&amp;amp; !isThisCodeImaginary(animal)
        &amp;amp;&amp;amp; areWeInMysticalLand();
}
const hornCheck = (animal) =&amp;gt; animal.horns.length == 1;
const isThisCodeImaginary = (animal) =&amp;gt; 1/0;
const areWeInMysticalLand = () =&amp;gt; true;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Renaming any of those functions would cost me nothing. Now, if the same code was a framework, and your users defined the areWeInMysticalLand function, then changing it would be easy for you. For the users, you would leave an entry in the migration notes.&lt;/p&gt;

&lt;p&gt;As a developer and user of the before-mentioned imaginary framework, you literally are changing your code to satisfy the refactoring the framework developers did.&lt;/p&gt;

&lt;p&gt;Obviously this is a made up example and I don’t want to point the fingers to the poor maintainers. I just want to give you a different perspective on how to think about small changes.&lt;/p&gt;

&lt;p&gt;With each new version of frameworks, languages, and tools around us, I wonder, when do we stop doing stuff in the name of better and improvements.&lt;/p&gt;

&lt;p&gt;That’s it?&lt;br&gt;
Yep, I don’t want to waste your and my time.&lt;/p&gt;

&lt;p&gt;Let me go back searching the internet for why v366 gives me an error.&lt;/p&gt;

&lt;p&gt;See ya later.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>framewo</category>
    </item>
    <item>
      <title>Unconventional Programming Tips: Search Better</title>
      <dc:creator>Kiru</dc:creator>
      <pubDate>Mon, 06 Feb 2023 09:19:36 +0000</pubDate>
      <link>https://forem.com/kiru_io/unconventional-programming-tips-search-better-3gla</link>
      <guid>https://forem.com/kiru_io/unconventional-programming-tips-search-better-3gla</guid>
      <description>&lt;p&gt;Originally posted on &lt;a href="https://kiru.io/blog/posts/2023/unconventional-programming-tips-search-better/" rel="noopener noreferrer"&gt;my personal blog&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is this for?
&lt;/h2&gt;

&lt;p&gt;This article is mainly intended for programmer.&lt;br&gt;
If you frequently search for code snippets in your code base, then this article is for you.&lt;/p&gt;
&lt;h2&gt;
  
  
  How I used to search
&lt;/h2&gt;

&lt;p&gt;One of the most common tasks when I code is not actually writing or reading code,&lt;br&gt;
but rather looking for something. I have a code base and want to find the following function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function isSign(firstNumber0: NumberPad | null) {
  return firstNumber0 == NumberPad.PLUS || firstNumber0 == NumberPad.MINUS;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I could search for &lt;code&gt;function isSign&lt;/code&gt; or &lt;code&gt;isSign&lt;/code&gt; to find the above function.&lt;br&gt;
Both would yield the expected results.&lt;br&gt;
Though, In many cases you would end up with many more unrelated results as well, and have to filter them by hand:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0h4p2cq2tzkrgaupk839.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0h4p2cq2tzkrgaupk839.png" alt="Search Result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I am using &lt;a href="https://github.com/BurntSushi/ripgrep" rel="noopener noreferrer"&gt;rg&lt;/a&gt; for demonstration purposes. The searches are mostly done in a decent IDE.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed
&lt;/h2&gt;

&lt;p&gt;Once I was working on a python project and was frequently searching for functions.&lt;br&gt;
Remember, python functions are like &lt;code&gt;def myFunction()&lt;/code&gt;.&lt;br&gt;
A team member (🙏 &lt;a href="https://florian.cassayre.me/" rel="noopener noreferrer"&gt;Florian&lt;/a&gt;) pointed out,&lt;br&gt;
that I could just look for &lt;code&gt;f myFunction&lt;/code&gt;. That was tiny hint, but then,&lt;br&gt;
I have been using that technique for almost daily.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I search now
&lt;/h2&gt;

&lt;p&gt;To find the above function, you could look for &lt;code&gt;n isSign&lt;/code&gt; or even shorter terms are &lt;code&gt;n i&lt;/code&gt; or &lt;code&gt;Sign(&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The general rule is: &lt;strong&gt;If you want to search better, then look for the most uncommon part of the search term&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This trick works even better with HTML. For example, on this blog,&lt;br&gt;
I want to find where the menu is defined. There is a &lt;a href="https://dev.to/til"&gt;TIL&lt;/a&gt; item, so in the source code, there must be a tag like &lt;code&gt;&amp;lt;a&amp;gt;TIL&amp;lt;/a&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In those cases, I made a habit of looking for &lt;code&gt;TIL&amp;lt;&lt;/code&gt;. That way, I don't see all the noisy content where TIL is&lt;br&gt;
defined in comments or text.&lt;/p&gt;

&lt;p&gt;Once you start frequently using this technique,&lt;br&gt;
you start immediately spotting what is common (in your code base) and what is uncommon.&lt;/p&gt;

&lt;p&gt;This tip is not limited to code. You want to find any text, then train yourself (by experience) to the uncommonness:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91742fydt2dn11cpgdf6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91742fydt2dn11cpgdf6.png" alt="Eye"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you!
&lt;/h3&gt;

&lt;p&gt;Thank you for reading the full article ! If you learned something new,&lt;br&gt;
you may find my &lt;a href="https://kiru.io/blog/posts/2021/coding-comments/" rel="noopener noreferrer"&gt;unconventional tips for coding comments&lt;/a&gt; interesting as well.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>search</category>
    </item>
    <item>
      <title>Unconventional Programming Tips: Comments</title>
      <dc:creator>Kiru</dc:creator>
      <pubDate>Thu, 18 Nov 2021 14:48:01 +0000</pubDate>
      <link>https://forem.com/kiru_io/unconventional-programming-tips-comments-cc0</link>
      <guid>https://forem.com/kiru_io/unconventional-programming-tips-comments-cc0</guid>
      <description>&lt;p&gt;Originally posted on my &lt;a href="https://kiru.io/articles/coding-comments/"&gt;personal blog&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Random thoughts on programming&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I was recently reading &lt;a href="https://stackoverflow.blog/2021/07/05/best-practices-for-writing-code-comments/"&gt;Best Practices for writing code comments&lt;/a&gt; by Ellen Spertus. &lt;br&gt;
While there are some helpful tips, it misses the most important ones for me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Add "why" comments when you write the code.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add all the other comments when you read the code.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
What is the main purpose of comments? &lt;br&gt;

They should help me understand the code easier. More than often, when I write the code, it is immediately clear what I was trying to solve. I have the context and the reason for my decisions are freshly in my mind.

&lt;/p&gt;

&lt;p&gt;
Few days later, re-reading the code, I don't know anymore why I wrote the code like that. That is when I add the most valuable comments. Many people tell you not to duplicate code with comments, but if it makes it easier to understand the code - why not? Don't follow any advices blindly - even the above ones.
&lt;/p&gt;

&lt;p&gt;Consider this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (element.parentElement != null){
   // do some stufff
}

while (element.parentElement != null){ // we didn't reach root
   // do some stufff
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a daily basis, I don't tend to write many while loops. That makes while loops not always easy to grasp. If I encounter one, it is not very easy to understand the conditions. In the above case, the condition is simple, nevertheless the added comment improves the code quality for me. I don't have to focus on the condition, I can read the inner parts knowing they are executed until we reach the root.&lt;/p&gt;

&lt;p&gt;In many cases, null checks are another good example. Null has so many semantics, while I write the code, I know the meaning of a variable being null, but when I read it again, it is not clear what the initial reason was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is it because null means the value has not been set?&lt;/li&gt;
&lt;li&gt;is it because null means the value was there, but has not been set?&lt;/li&gt;
&lt;li&gt;is it because null means the value is invalid?&lt;/li&gt;
&lt;li&gt;is null the expected value?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try to add a comment why you expect null. You don't have to add it each time - only in the cases where it is not clear from reading the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;: Best comments are written when you read the code - not when you write it.&lt;/p&gt;

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