<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gavin on Medium]]></title>
        <description><![CDATA[Stories by Gavin on Medium]]></description>
        <link>https://medium.com/@ktchan825?source=rss-f9a80b70f70d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Jl8tAP0_5IJYsssf-IFCNQ@2x.jpeg</url>
            <title>Stories by Gavin on Medium</title>
            <link>https://medium.com/@ktchan825?source=rss-f9a80b70f70d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:57:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ktchan825/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[5 Baby Steps to Write “Better Code”]]></title>
            <link>https://medium.com/@ktchan825/5-baby-steps-to-write-better-code-9ee22f1e11b1?source=rss-f9a80b70f70d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ee22f1e11b1</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[code-review]]></category>
            <dc:creator><![CDATA[Gavin]]></dc:creator>
            <pubDate>Mon, 27 Oct 2025 01:31:59 GMT</pubDate>
            <atom:updated>2025-10-27T01:31:59.191Z</atom:updated>
            <content:encoded><![CDATA[<p>Your code works, let’s make it better! Here are some simple baby steps to help you write better code and make your codebase more maintainable over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kI0NORlPT6nr0zsq" /><figcaption>Photo by <a href="https://unsplash.com/@ttepavac?utm_source=medium&amp;utm_medium=referral">Tanja Tepavac</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>0. Before You Start Coding</h3><p>Don’t reinvent the wheel. Pick a popular framework in whatever domain you’re building in — they’ll save you hundreds of hours with ready-made solutions and community support.</p><p>For web development: React, Next.js, or Vue<br>For backend APIs: Express, Django, or FastAPI<br>For data processing: pandas or NumPy<br>For mobile: React Native or Flutter</p><p>The key is: pick one and start. Don’t spend weeks deciding — just commit to something with good community support and documentation. If you feel pain about the framework one day, you will know how to choose next.</p><h3>1. Version Control</h3><p>Code always changes, and changes can introduce bugs. Using a version control tool helps you track every change and makes it easy to revert if needed. Always commit your code before making major changes.</p><p>The most common approach is to create a Git repository. Free options like <a href="https://github.com/">GitHub</a>, <a href="https://gitlab.com/">GitLab</a>, and <a href="https://bitbucket.org/">Bitbucket</a> are all equally good choices for beginners.</p><p>Getting started with Git:</p><pre>cd yourrepo<br>git add .<br>git commit -m &quot;init&quot;<br>git push<br>#That&#39;s it, your repo is commited<br>#With new code change, commit with clear commit msg</pre><p>Pick any of them — GitHub, GitLab, or Bitbucket. They all do the same job. GitHub has the biggest community if you’re building a portfolio, but honestly, just pick one and start. You can always migrate later.</p><blockquote>Learn more:<br>- <a href="https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control">Git Tutorial for Beginners</a><br>- <a href="https://docs.github.com/en/get-started/using-git/about-git">GitHub Official Guide</a></blockquote><h3>2. Formatting and Linting</h3><p>Different developers have different coding styles — naming conventions, indentation, spacing. This inconsistency makes maintaining code harder and results in many trivial changes polluting your version history.</p><p>Don’t waste time formatting manually. Set up a formatter with any default template. Popular frameworks often come with formatting and linting tools out of the box — consult their documentation.</p><p>Popular Linting and Formatting Tools</p><p>For JavaScript/TypeScript:<br>- <a href="https://eslint.org/">ESLint</a>: Industry-standard linter for JavaScript<br>- <a href="https://prettier.io/">Prettier</a>: Opinionated code formatter<br>- <a href="https://biomejs.dev/">Biome</a>: All-in-one fast linter and formatter</p><p>For Python:<br>- <a href="https://github.com/astral-sh/ruff">Ruff</a>: Extremely fast Python linter and formatter<br>- <a href="https://black.readthedocs.io/">Black</a>: Uncompromising Python code formatter<br>- <a href="https://pylint.org/">Pylint</a>: Comprehensive Python linter</p><blockquote><strong>Pro tip</strong>: Configure your editor to apply formatting on save, and if you care about code quality, integrate linting into your build process.</blockquote><blockquote>Learn more:<br>- <a href="https://eslint.org/docs/latest/use/getting-started">ESLint Setup Guide</a><br>- <a href="https://prettier.io/docs/en/install.html">Prettier Documentation</a></blockquote><h3>3. Avoid Repeating Code</h3><p>Following the DRY (Don’t Repeat Yourself) principle: if multiple parts of your code share the same behavior or logic, put that logic in a single function. This eliminates maintenance headaches down the road.</p><p>However, be aware of incidental duplication — code that looks similar but serves distinct purposes. For example, validating firstName and lastName inputs may involve the same string-check logic, but these validations should remain separate. When you add other validation rules for firstName in the future (like minimum length), you won’t want to accidentally change lastName validation too.</p><pre>// Example<br>function validateFirstName(x: unknown) {<br> return typeof x === &quot;string&quot;;<br>}<br>function validateLastName(x: unknown) {<br> return typeof x === &quot;string&quot;;<br>}</pre><p>These functions look identical now, but they serve different purposes. If requirements change and you need to add length validation only for firstName, keeping them separate saves you from breaking lastName.</p><blockquote>Learn more about DRY:<br>- <a href="https://en.wikipedia.org/wiki/Don&#39;t_repeat_yourself">DRY Principle Explained</a><br>- <a href="https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/">The Pragmatic Programmer Book</a></blockquote><h3>4. Document Your Setup</h3><h4>Configuration-as-Code</h4><p>No more “it works on my own machine but not anywhere else”. Once your code works locally, document your environment. There is nothing fancy to start with, depending on the syntax of service chosen, you mark down your current OS, installed package (e.g. npm version), the application environment (e.g.nodejs version, environment variable). Personally, if you haven’t used any of these yet, I recommend you to checkout Docker and K8S. They should also support well when you have to deploy the application afterward.</p><p>Use version managers to keep your environment consistent:<br>- <a href="https://github.com/nvm-sh/nvm">nvm</a> (Node Version Manager): Manage multiple Node.js versions<br>- <a href="https://github.com/pyenv/pyenv">pyenv</a>: Manage Python versions<br>- <a href="https://www.docker.com/">Docker</a>: Containerize your entire application environment</p><h4>Hot Commands as Scripts</h4><p>If your application builds or starts with a few lines of commands, create a bash script for it. Don’t waste your memory on repetitive tasks.</p><pre>#!/bin/bash<br>#Example start.sh for node application.<br>export VAR_A=&quot;123&quot;<br>npm install<br>npm run build<br>npm start</pre><p>Mark any advanced configuration in your README.md. Believe me, you will thank yourself later when you have a new computer.</p><h3>5. Write Tests</h3><p>We don’t always have the resources to write comprehensive tests, but establishing a basic test environment early on can keep your work phone quiet. Start by selecting one page or endpoint — perhaps a login form or a data processing function — and write a few simple tests for it.</p><p>Remember, your goal isn’t perfection. You don’t need to cover every case right away. The practice alone help you understand better how your application is organized.</p><p>If you found it difficult to test a component, you should probably consider revamping your component. In practice, you may need to separate feature into smaller functions, removing global variable, decouple features.</p><p>While writing test, you would uncover hidden assumption and extreme input for your function. Say you are processing some numeric input, from the test prospective, you should ensure the function handle extreme case like 0, negative, big number, with decimal place. Most importantly, you would ensure you are calling the function with a number but not anything else.</p><blockquote>Learn more about testing:<br>- <a href="https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices">Unit Testing Best Practices</a><br>- <a href="https://www.testdevlab.com/blog/the-ultimate-guide-to-unit-testing">The Ultimate Guide to Unit Testing</a><br>- <a href="https://medium.com/onfido-tech/how-to-write-unit-testable-code-and-how-it-improves-code-quality-8c2e26bed55a">How to write unit testable code and how it improves code quality</a> — <a href="https://medium.com/@cemtuver?source=post_page---byline--8c2e26bed55a---------------------------------------">Cem Tüver</a></blockquote><h3>Conclusion</h3><p>There’s a lot of debate about code quality, testing strategies, and the “right” way to code. Don’t get paralyzed by it.</p><p>Pick any practices that solve your immediate pain, like “it works yesterday🫨” or “how should i run this application in new computer🤨”, and improve continuously. The goal of every practice is always to solve your problem, don’t let it be your problem instead.</p><h3>Additional Resources</h3><p>- <a href="https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/">The Pragmatic Programmer</a> — Classic book on software development best practices<br>- <a href="https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882">Clean Code by Robert C. Martin </a>— Essential reading for writing maintainable code<br>- <a href="https://www.freecodecamp.org/">freeCodeCamp </a>— Free coding tutorials and courses</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ee22f1e11b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>