<?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 Hendro Wibowo on Medium]]></title>
        <description><![CDATA[Stories by Hendro Wibowo on Medium]]></description>
        <link>https://medium.com/@henwib?source=rss-6681087b94a5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VBXXBIPEYSV2Qmmvnhxzlg.jpeg</url>
            <title>Stories by Hendro Wibowo on Medium</title>
            <link>https://medium.com/@henwib?source=rss-6681087b94a5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:34:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@henwib/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[Creating a Real-Time Agentic AI for My Daughter with Rust, LiveKit, and Whisper]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://henwib.medium.com/creating-a-real-time-agentic-ai-for-my-daughter-with-rust-livekit-and-whisper-0e3073ebab94?source=rss-6681087b94a5------2"><img src="https://cdn-images-1.medium.com/max/1536/1*ELsBi-jTY4GE2A5VEzNdLQ.png" width="1536"></a></p><p class="medium-feed-snippet">How my daughter&#x2019;s curiosity inspired a Rust-based, low-latency speech AI built for kids in Bahasa Indonesia.</p><p class="medium-feed-link"><a href="https://henwib.medium.com/creating-a-real-time-agentic-ai-for-my-daughter-with-rust-livekit-and-whisper-0e3073ebab94?source=rss-6681087b94a5------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://henwib.medium.com/creating-a-real-time-agentic-ai-for-my-daughter-with-rust-livekit-and-whisper-0e3073ebab94?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e3073ebab94</guid>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[voice-assistant]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent-development]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Fri, 16 May 2025 15:06:26 GMT</pubDate>
            <atom:updated>2025-06-05T12:07:34.132Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[ReactJS Penguin Game Born from a Family Walk]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://henwib.medium.com/reactjs-penguin-game-born-from-a-family-walk-0d4ae457364c?source=rss-6681087b94a5------2"><img src="https://cdn-images-1.medium.com/max/894/1*iVC5v7OAv2e9JlpzLZHhpg.jpeg" width="894"></a></p><p class="medium-feed-snippet">Penguin Ice Breaker is a puzzle game where you guide a penguin across icy hex tiles, breaking them as you go. The catch? Once a tile is&#x2026;</p><p class="medium-feed-link"><a href="https://henwib.medium.com/reactjs-penguin-game-born-from-a-family-walk-0d4ae457364c?source=rss-6681087b94a5------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://henwib.medium.com/reactjs-penguin-game-born-from-a-family-walk-0d4ae457364c?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d4ae457364c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[game-dev-story]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Thu, 15 May 2025 15:29:34 GMT</pubDate>
            <atom:updated>2025-06-14T14:26:44.688Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[RUST: Understanding “.” and "::” Operators]]></title>
            <link>https://henwib.medium.com/rust-understanding-and-operators-63e571632b6a?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/63e571632b6a</guid>
            <category><![CDATA[rustlang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[language-feature]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Mon, 12 May 2025 23:44:57 GMT</pubDate>
            <atom:updated>2025-05-12T23:49:52.007Z</atom:updated>
            <content:encoded><![CDATA[<h3>RUST: Understanding . and :: Operators</h3><blockquote>In Rust, the . (dot) and :: (double colon) operators serve distinct purposes, primarily differentiating between value-level access and namespace-level access.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IpevAMCClKxmOQDbEUC3yA.png" /><figcaption>Rust programming language</figcaption></figure><p>In this article, I will not talk about the ownership concept of Rust because there are plenty of articles, including its official documentation, that already discuss this topic. Well, I am not a Rust expert but here I am trying to share about what I know about Rust programming language.</p><p>So, I will share about . and :: operators in Rust. How they differ, their usage use case, etc. In Rust, the . (dot) and :: (double colon) operators serve distinct purposes, primarily differentiating between value-level access and namespace-level access.</p><h4>. (Dot) — Accessing Instance Members</h4><p>You will need to use the dot operator when you have an instance of a type and want to access its fields or methods.</p><p>Example:</p><ul><li><strong>Access instance fields</strong></li></ul><pre>let config = Config { url: &quot;https://whatsapbro&quot;, api_key: &quot;dontaskme&quot; };<br>println!(&quot;The base URL is: {}&quot;, config.url);</pre><ul><li><strong>Call the methods</strong></li></ul><pre>struct Player&lt;&#39;a&gt; {<br>  name: &amp;&#39;a str,<br>  dead: bool,<br>}<br><br>impl&lt;&#39;a&gt; Player&lt;&#39;a&gt; {<br>  fn is_dead(&amp;self) -&gt; bool {<br>    self.dead<br>  }<br>}<br><br>let player = Player { name: &quot;Hendru&quot;, dead: false };<br>let player_status = if player.is_dead() { &quot;dead&quot; } else { &quot;alive&quot; }<br>println!(&quot;Player {} is {}&quot;, player.name, player_status);</pre><p>Maybe you noticed the&lt;&#39;a&gt; annotation in the above code is a lifetime annotation. I will talk about this topic later in a separate article.</p><h3>:: (Double Colon) — Accessing Namespaces and Associated Items</h3><p>The :: or double colon operator is used when you need to navigate through namespaces, such as modules, structs, enums, and traits. So, it’s similar to how we call the static methods and constants in PHP.</p><p>Example:</p><ul><li><strong>Call associated functions<br></strong>One of the most common associated function is new(). Its to define struct constructor, sometimes with some parameters.</li></ul><pre>struct Player&lt;&#39;a&gt; {<br>  name: &amp;&#39;a str,<br>  dead: bool,<br>}<br><br>impl&lt;&#39;a&gt; Player&lt;&#39;a&gt; {<br>  // An example of associated function to initiate struct constructor.<br>  fn new(name: &amp;&#39;a str) -&gt; Self {<br>    Self { name, dead: false }<br>  }<br><br>  fn is_dead(&amp;self) -&gt; bool {<br>    self.dead<br>  }<br><br>  fn update_status(&amp;mut self, dead: bool) {<br>    self.dead = dead;<br>  }<br>}<br><br>// Here we create a Player instance by calling the constructor &quot;new()&quot; <br>// which is an associated function.<br>let mut player = Player::new(&quot;Hendru&quot;);<br>player.update_status(true);<br>let player_status = if player.is_dead() { &quot;dead&quot; } else { &quot;alive&quot; }<br>println!(&quot;Player {} is {}&quot;, player.name, player_status);</pre><ul><li><strong>Access the constants or types within modules</strong></li></ul><pre>/* We have a project with the structure like below: */<br><br>src/<br>├── main.rs<br>└── config.rs</pre><pre>// src/config.rs<br><br>pub const BASE_URL: &amp;str = &quot;https://blablabla.bla&quot;;<br>pub const API_RATE_LIMIT: u32 = 100; // Rate limit per minutes</pre><pre>// src/main.rs<br><br>mod config;<br><br>fn main() {<br>  println!(&quot;Base URL: {}&quot;, config::BASE_URL);<br>  println!(&quot;API rate limits (per minutes): {}&quot;, config::API_RATE_LIMIT);<br>}</pre><ul><li><strong>Accessing Constants from Other Modules<br></strong>By extending the example above, we can also call constants from other modules by wrap it with a function.</li></ul><pre>// src/config.rs<br>use crate::env_vars;<br><br>pub const BASE_URL: &amp;str = &quot;https://blablabla.bla&quot;;<br>pub const API_RATE_LIMIT: u32 = 100; // Rate limit per minutes<br><br>pub fn print_env_vars() {<br>  println!(&quot;API Key: {}&quot;, env_vars::API_KEY);<br>}</pre><pre>// src/main.rs<br><br>mod config;<br><br>fn main() {<br>  println!(&quot;Base URL: {}&quot;, config::BASE_URL);<br>  println!(&quot;API rate limits (per minutes): {}&quot;, config::API_RATE_LIMIT);<br><br>  config::print_env_vars();<br>}</pre><h3>Summary</h3><ul><li><strong>. (Dot) operator:</strong> used when working with an instance to access its fields or methods.</li><li><strong>:: (Double Colon):</strong> used to access items at the namespace level, such as associated functions, constants, or types within modules.</li></ul><p>It’s crucial to understand the differences between these operators for navigating Rust’s module system and utilizing its features effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63e571632b6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Group Expenses: Introducing the Split Billing WhatsApp Bot]]></title>
            <link>https://henwib.medium.com/simplifying-group-expenses-introducing-the-split-billing-whatsapp-bot-70b57b340496?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/70b57b340496</guid>
            <category><![CDATA[chatbot-development]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[whatsapp]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Sun, 04 May 2025 02:26:06 GMT</pubDate>
            <atom:updated>2025-05-04T10:45:16.748Z</atom:updated>
            <content:encoded><![CDATA[<p>Managing shared expenses among friends or colleagues can often be a hassle, tracking who owes what, ensuring timely payments, and maintaining transparency. To address these challenges, I’ve developed the Split Billing WhatsApp Bot, a tool designed to streamline the process of splitting bills directly by sending a chat message to the bot. If you wanna try the bot, you can try to send the <strong><em>/help</em></strong> command to this WhatsApp number <strong><em>6287778039565</em></strong>. You can also watch the demo at the end of this article.</p><blockquote>I do not store any data, including the phone number!</blockquote><figure><img alt="Split Billing Bot For Whatsapp" src="https://cdn-images-1.medium.com/max/1024/1*Yt9HT_2uYgxLBmGEmgV9yg.jpeg" /><figcaption>Split Billing Bot For Whatsapp</figcaption></figure><h3>Inspiration Behind the Project</h3><p>The concept for this bot originated during a WhatsApp discussion last week with my friend, <a href="https://medium.com/u/33e478999def">Affandy Fahrizain</a>. We were brainstorming ways to simplify the often cumbersome process of managing shared expenses. Affandy proposed the idea of integrating a bill-splitting feature directly into WhatsApp, leveraging its widespread use and real-time communication capabilities. This conversation laid the foundation for the development of the Split Billing WhatsApp Bot.</p><h3>Why a WhatsApp Bot for Splitting Bills?</h3><p>While numerous apps exist for expense sharing, integrating this functionality into WhatsApp offers distinct advantages:</p><ul><li><strong>Ubiquity</strong>: WhatsApp is widely used globally, reducing the need for users to download and familiarize themselves with a new app.</li><li><strong>Real-Time Communication</strong>: Managing expenses within the same platform where group discussions occur enhances convenience.</li><li><strong>Seamless Experience</strong>: Users can handle all aspects of bill splitting — from creation to settlement — without leaving the chat.</li></ul><h3>Key Features of the Split Billing WhatsApp Bot</h3><ul><li><strong>Bill Creation &amp; Management</strong>: Initiate and oversee bills directly within WhatsApp groups.</li><li><strong>Participant &amp; Item Addition</strong>: Easily add members and list items to the bill.</li><li><strong>Image-Based Bill Parsing</strong>: Upload a photo of a bill to automatically extract items and amounts using the OpenAI API.</li><li><strong>Automated Calculations</strong>: Determine each participant’s share effortlessly.</li><li><strong>Private Notifications</strong>: Upon bill closure, send individualized messages detailing payment amounts and instructions.</li><li><strong>Multi-language Support</strong>: Operates in both English and Indonesian, with a translation system for easy localization. It is still in progress, so probably there are still some copies in English even though you change the language to Indonesian.</li></ul><h3>Technical Overview</h3><ul><li><strong>Programming Language</strong>: The bot is developed in Go (Golang), known for its efficiency and concurrency support.</li><li><strong>Database:</strong> The initial version of the bot uses SQLite. A file-based database management system. I am planning to move to Postgres or MySQL.</li><li><strong>WhatsApp Integration</strong>: Utilizes the WhatsMeow library to interface with WhatsApp, enabling message handling and group interactions.</li><li><strong>AI Integration</strong>: Employs the OpenAI API for Optical Character Recognition (OCR) to parse bill images, extracting relevant data for processing.</li><li><strong>Modular Design</strong>: Features a translation system to support multiple languages and facilitate easy scalability.</li></ul><h3>Getting Started</h3><p>To set up and run the Split Billing WhatsApp Bot:</p><ol><li><strong>Prerequisites</strong>: Ensure Go 1.16+ is installed on your system.</li><li><strong>Clone the Repository</strong>:</li></ol><pre>git clone git@github.com:w33ladalah/split-billing-whatsapp.git</pre><p><strong>3. Install Dependencies</strong>:</p><pre>go mod tidy</pre><p><strong>4. Run the Application</strong>:</p><pre>go run main.go</pre><p><strong>5. Configure Environment Variables</strong>: Set up the necessary configurations as specified in the .env.example file.</p><p><strong>6. Run the Bot</strong>: Execute the built application and integrate it with your WhatsApp account as per the repository’s instructions.</p><p><strong>7. Production Mode:</strong> You need to build the app before deploying it to the production server.</p><pre>go build -ldflags &quot;-X &#39;split-billing-whatsapp/internal/config.OpenaiAPIKey=your_api_key&#39; -X &#39;split-billing-whatsapp/internal/config.OpenaiModel=GPT-4o-mini&#39; -X &#39;split-billing-whatsapp/internal/config.GptBillPrompt=your_prompt&#39;</pre><h3>Future Enhancements</h3><p>Looking ahead, potential features to enhance the bot’s functionality include:</p><ul><li><strong>Payment Gateway Integration</strong>: Allowing users to settle their shares directly through the bot.</li><li><strong>Enhanced AI Capabilities</strong>: Improving the accuracy of bill parsing and data extraction.</li><li><strong>Expanded Language Support</strong>: Incorporating additional languages to cater to a broader user base.</li><li><strong>User Interface Improvements</strong>: Developing a more intuitive interface for better user interaction.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FlOjThE_JlnY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fshorts%2FlOjThE_JlnY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FlOjThE_JlnY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd4017c76baaeab31eb44c96771c7349/href">https://medium.com/media/bd4017c76baaeab31eb44c96771c7349/href</a></iframe><h3>Conclusion</h3><p>The Split Billing WhatsApp Bot aims to simplify the often cumbersome process of managing shared expenses. By integrating this functionality into a platform as ubiquitous as WhatsApp, users can enjoy a seamless and efficient experience. I invite you to try out the bot and contribute to its ongoing development.</p><p>Currently, I have released the source code as open source on GitHub. You can access and/or contribute to the source code <a href="https://github.com/w33ladalah/split-billing-whatsapp">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70b57b340496" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Myth or Fact: Do Chatting Apps Make Android Devices Slow?]]></title>
            <link>https://henwib.medium.com/myth-or-fact-do-chatting-apps-make-android-devices-slow-cab1db0aa613?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cab1db0aa613</guid>
            <category><![CDATA[whatsapp]]></category>
            <category><![CDATA[instant-messaging]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Thu, 01 May 2025 02:57:43 GMT</pubDate>
            <atom:updated>2025-05-01T02:57:43.903Z</atom:updated>
            <content:encoded><![CDATA[<p>This an English version of my article in bahasa Indonesia <a href="https://henwib.medium.com/mitos-atau-fakta-aplikasi-chatting-bikin-android-jadi-lambat-b59dfcda1d3d">here</a></p><p>Recently, I’ve come across forums and social media posts where people complain about their Android phones becoming sluggish. They often blame background-running apps like WhatsApp, Telegram, and others. However, this is a misconception. I felt compelled to write this article to educate Android users, especially those not well-versed in IT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BHXhcPWuf9W4HkGKe7FTw.jpeg" /><figcaption>Source: <a href="https://www.freepik.com/free-vector/gradient-phone-text-bubble-collection_29432451.htm#fromView=keyword&amp;page=1&amp;position=1&amp;uuid=0cacaa83-9510-47c1-922c-c7d7c6d38422&amp;query=Chat+App">https://www.freepik.com</a></figcaption></figure><h3>How Does Android’s Memory Management Work?</h3><p>The Android operating system manages memory differently from traditional computers. Here are some key points to understand:</p><h4>RAM Doesn’t Need to Be Empty</h4><p>Many believe that a full RAM is detrimental. In reality, Android intentionally keeps RAM occupied to allow apps to reopen quickly. An empty RAM indicates that the system isn’t efficiently utilizing the device’s resources.</p><h4>Low Memory Killer (LMK)</h4><p>Android employs a mechanism called Low Memory Killer to automatically and intelligently terminate less important apps when memory is nearly full, ensuring that critical applications remain unaffected.</p><h4>Process Management Based on Priority</h4><p>Android categorizes app processes based on priority:</p><ul><li><strong>Foreground</strong>: The app currently in use.</li><li><strong>Visible</strong>: Apps partially visible, such as when using popup or overlay modes.</li><li><strong>Service</strong>: Processes running continuously in the background, like notifications or synchronization.</li><li><strong>Cached</strong>: Apps not in use but retained in memory for quicker access.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*PeP31dVedi50YKK-wQUBNg.jpeg" /><figcaption>Whatsapp in overlay mode on top of Chrome.</figcaption></figure><p>If memory is nearly full, Android will first remove “cached” processes, not essential apps like WhatsApp that actively provide notifications.</p><h3>Why Chatting Apps Don’t Slow Down Your Android Device</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*5dXYfhKYqp2kSIypkArQGw.jpeg" /><figcaption>Whatsapp memory consumption</figcaption></figure><h4>Efficient Background Resource Usage</h4><p>Chatting apps like WhatsApp utilize background services for notifications and message reception. They often employ Firebase Cloud Messaging (FCM), ensuring the app is only activated upon receiving a message, thus conserving power and memory.</p><h4>Minimal CPU Consumption</h4><p>Developers of chatting apps design them to operate efficiently, consuming minimal CPU resources when not actively in use. They become active primarily when you open chats, send media, or perform backups.</p><h4>Effective Media and Cache Management</h4><p>While apps like WhatsApp store media files (photos, videos, documents), this affects storage space, not RAM. As long as your storage isn’t full, it doesn’t impact your device’s performance.</p><h4>Compliance with Google’s Regulations</h4><p>Starting from Android 8 (Oreo), Google imposed strict limitations on background-running apps. Chatting apps adhere to these rules, preventing them from running unchecked in the background and causing device slowdowns.</p><p>In conclusion, it’s a myth that chatting apps inherently slow down Android devices. Android’s sophisticated memory management ensures efficient operation, and responsible app development further mitigates performance issues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cab1db0aa613" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mitos atau Fakta: Aplikasi Chatting Bikin Android Jadi Lambat?]]></title>
            <link>https://henwib.medium.com/mitos-atau-fakta-aplikasi-chatting-bikin-android-jadi-lambat-b59dfcda1d3d?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b59dfcda1d3d</guid>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[instant-messaging]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[whatsapp]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Thu, 01 May 2025 02:42:46 GMT</pubDate>
            <atom:updated>2025-05-01T02:50:53.824Z</atom:updated>
            <content:encoded><![CDATA[<p>Beberapa waktu lalu saya sempat baca di forum atau social media tentang orang-orang yang mengeluhkan ponsel Android mereka menjadi lambat. Lantas mereka langsung menyalahkan aplikasi-aplikasi yang berjalan secara background seperti Whatsapp, Telegram, dan yang lainnya. Padahal ini salah kaprah atau tidak benar. Oleh karena itu, saya termotivasi untuk menulis artikel ini untuk memberikan edukasi kepada para pengguna ponsel Android tersebut dari kalangan yang awam IT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BHXhcPWuf9W4HkGKe7FTw.jpeg" /><figcaption>Ilustrasi (sumber: <a href="https://www.freepik.com/free-vector/gradient-phone-text-bubble-collection_29432451.htm#fromView=keyword&amp;page=1&amp;position=1&amp;uuid=0cacaa83-9510-47c1-922c-c7d7c6d38422&amp;query=Chat+App">https://www.freepik.com</a>)</figcaption></figure><p>Banyak pengguna Android khawatir bahwa aplikasi seperti WhatsApp yang terus berjalan di latar belakang akan membuat ponsel mereka lemot. Kekhawatiran ini wajar, tetapi sebenarnya tidak sepenuhnya benar. Android memiliki sistem manajemen memori yang canggih dan dirancang agar aplikasi seperti WhatsApp dan aplikasi yang berjalan secara <em>background</em> lainnya tetap berjalan dengan efisien tanpa mengganggu performa perangkat.</p><p>Untuk membahas lebih jauh tentang bagaimana aplikasi-aplikasi <em>background</em> itu bisa tetap running tanpa menganggu kinerja ponsel kamu secara keseluruhan, ayo kita pahami dulu bagaimana sistem manajemen memori di Android.</p><h3>Bagaimana Sistem Manajemen Memori Bekerja di Android?</h3><p>Sistem operasi Android memiliki cara yang berbeda dalam mengelola memori dibandingkan komputer biasa. Berikut beberapa poin penting yang perlu kamu kethaui:</p><h4><strong>RAM Tidak Harus Kosong</strong></h4><p>RAM yang penuh adalah hal yang buruk! Mungkin itu yang banyak orang kira. Padahal, Android sengaja RAM tetap terisi agar aplikasi bisa dibuka lagi lebih cepat. RAM yang kosong justru menandakan bahwa sistem tidak efisien dalam mengelola sumber daya ponsel.</p><h4><strong>Low Memory Killer (LMK)</strong></h4><p>Low Memory Killer atau LMK adalah sebuah mekanisme untuk menghapus aplikasi-aplikasi yang dianggap tidak terlalu penting saat memori hampir penuh. LMK akan melakukannya secara otomatis dan pintar, sehingga aplikasi-aplikasi lainnya yang lebih penting tidak terganggu.</p><h4>Manajemen Proses Berdasarkan Prioritas</h4><p>Android mengelompokkan proses aplikasi berdasarkan prioritas:</p><ul><li><strong>Foreground</strong>: Aplikasi yang sedang digunakan.</li><li><strong>Visible</strong>: Aplikasi yang terlihat sebagian seperti saat kita mengaktifkan mode <em>popup</em> atau <em>overlay</em> pada suatu aplikasi tertentu. Nah, yang dimaksud adalah aplikasi yang tertutup sebagian oleh <em>overlay apps</em> tersebut. Misalnya <em>video player</em> atau juga aplikasi chatting seperti Whatsapp atau Telegram.</li><li><strong>Service</strong>: Proses yang berjalan secara terus secara <em>background</em> atau latar belakang. Sebagai contoh adalah notifikasi atau sinkronisasi.</li><li><strong>Cached</strong>: Aplikasi yang sudah tidak digunakan tetapi masih tetap disimpan di dalam memori agar bisa dibuka lagi dengan cepat.</li></ul><figure><img alt="Tangkapan layar yang meperlihatkan aplikasi Whatsapp berjalan secara overlay di atas Chrome." src="https://cdn-images-1.medium.com/max/540/1*PeP31dVedi50YKK-wQUBNg.jpeg" /><figcaption>Whatsapp dengan overlay-mode di atas Chrome.</figcaption></figure><p>Jika memori hampir penuh, proses yang dikategorikan sebagai <strong>“cached”</strong> akan dihapus terlebih dahulu, bukan aplikasi seperti Whatsapp yang aktif memberikan notifikasi.</p><h3>Mengapa Aplikasi Chatting Tidak Membuat HP Android Lemot</h3><h4>Konsumsi Sumber Daya Background Yang Ringan</h4><p>Aplikasi chatting seperti Whatsapp secara aktif menggunakan <em>background service</em> (layanan latar belakang) secara terus-menerus seperti notifikasi dan untuk menerima pesan, tetapi ini sangat hemat daya dan memori. Mereka (aplikasi <em>chatting</em>) juga biasanya menggunakan <strong>Firebase Cloud Messaging (FCM)</strong>, sehingga aplikasi hanya “dibangunkan” saat ada pesan masuk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*5dXYfhKYqp2kSIypkArQGw.jpeg" /><figcaption>Whatsapp hanya menggunakan sebagian kecil sumber daya RAM pada ponsel dibandingkan dengan total kapasitas RAM.</figcaption></figure><h4>Hemat CPU</h4><p>Para pembuat aplikasi-aplikasi chatting seperti WhatsApp adalah orang-orang yang memiliki skill yang hebat yang mampu membuat aplikasi ponsel Android bekerja secara efisien dan hemat sumber daya. Aplikasi-aplikasi ini pada umumnya tidak banyak menggunakan banyak sumber daya prosesor saat tidak digunakan. Ia hanya aktif ketika kamu membuka chat, mengirim media, atau melakukan backup.</p><h4>Manajemen Media dan Cache yang Baik</h4><p>Aplikasi seperti Whatsapp memang menyimpan media (foto, video, dokumen), tapi ini hanya berpengaruh pada media penyimpanan bukan memori (RAM). Selama ruang penyimpanan tidak penuh, hal ini tidak mempengaruhi kinerja ponsel kamu.</p><h4>Patuh Terhadap Aturan Google</h4><p>Google selaku pembuat sistem operasi Android, memberlakukan batasan ketat untuk aplikasi yang berjalan di latar belakang. Hal ini diberlakukan mulai Android versi 8 (Oreo). Whatsapp dan aplikasi chatting lainnya patuh terhadap aturan ini, sehingga tidak akan “berlari liar” di latar belakang dan membuat ponsel jadi lemot.</p><h3>Bagaimana Aplikasi Chatting Bekerja di Latar Belakang?</h3><p>Aplikasi pesan instan atau chatting umumnya menggunakan <em>background service</em> untuk menerima pesan dan notifikasi. Sebagian besar aplikasi modern menggunakan layanan dari <strong>Firebase Cloud Messaging (FCM)</strong>, yang memungkinkan aplikasi tetap terkoneksi dengan server tanpa harus menjaga koneksi tersebut secara kontinyu. <strong>FCM</strong> mengirimkan pesan ke aplikasi hanya ketika ada pesan baru, sehingga aplikasi tidak aktif sepanjang waktu di latar belakang.</p><figure><img alt="Gambaran besar cara kerja aplikasi pesan singkat" src="https://cdn-images-1.medium.com/max/920/1*ptzJWSb-bhHKBk4uha75Gw.png" /><figcaption>Gambaran besar cara kerja aplikasi pesan singkat</figcaption></figure><p>Android juga memiliki mekanisme untuk mengelola aplikasi latar belakang secara efisien. Sistem akan memberikan sinyal kepada aplikasi untuk mengurangi penggunaan memori (RAM) melalui metode seperti <a href="https://developer.android.com/games/optimize/memory-allocation"><strong><em>onTrimMemory()</em></strong></a>, yang meminta aplikasi untuk melepaskan sumber daya yang tidak dibutuhkan.</p><p>Berikut saya sertakan perbandingan manajemen sumber daya pada berbagai aplikasi pesan singkat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*BYqeiSdNjCAwIn6dbAfugg.png" /></figure><h3>Lalu, Apa Yang Membuat Ponsel Kita Lemot?</h3><p>Ada banyak faktor sebetulnya akan tetapi disini saya akan tarik beberapa faktor yang paling umum yang sering menjadi penyebab Ponsel Android lemot, antara lain:</p><h4>Ruang Penyimpanan Penuh</h4><p>Ketika ruang penyimpanan hampir penuh, sistem akan kekurangan ruang yang memadai untuk menjalankan proses dengan lancar. Hal ini dapat menyebabkan penurunan kinerja ponsel. Foto, video, aplikasi, dan file cache yang menumpuk tentu akan menyebabkan ruang penyimpanan ponsel kita penuh.</p><h4>RAM Terbatas dan Terlalu Banyak Aplikasi Yang Berjalan</h4><p>Kapasitas RAM yang terbatas disertai terlalu banyak aplikasi yang berjalan juga berpotensi menyebabkan ponsel kita terbebani.</p><h4>File Cache Yang Menumpuk</h4><p>Cache adalah data sementara yang disimpan oleh aplikasi untuk mempercepat proses seperti loading aplikasi, penampilan data, meminimalisir koneksi ke server untuk permintaan data baru, dan sebagainya. Namun, kita perlu membersihkan file-file ini secara berkala agar kinerja ponsel selalu optimal. Karena dapat menyita ruang penyimpanan dan berakibat membebani sistem.</p><h4>Sistem Operasi dan Aplikasi Tidak Diperbarui</h4><p>Hal ini penting karena setiap ada perbaruan pada sistem operasi dan/atau aplikasi dilakukan untuk memperbaiki bug atau masalah yang ada pada versi sebelumnya. Serta untuk menerapkan fitur-fitur baru yang mungkin akan menambah kinerja dari sistem operasi atau aplikasi.</p><h4>Serangan Virus atau Malware</h4><p>Adalah tindakan berbahaya apabila kita memasang aplikasi dari sumber yang tidak terpercaya karena berpotensi mengandung malware atau virus. Jika ponsel terkena malware atau virus, sudah pasti akan mempengaruhi kinerja ponsel kita.</p><h4>Terlalu Banyak Aplikasi Terinstal</h4><p>Banyak aplikasi yang diinstal akan berpengaruh pada penggunaan ruang penyimpanan dan berakibat membebani kinerja ponsel.</p><h4>Penggunaan Wallpaper Animasi (Live Wallpaper)</h4><p>Live wallpaper disukai oleh pengguna ponsel Android karena dapat mempercantik tampilan. Akan tetapi, live wallpaper juga akan mengonsumsi lebih banyak sumber daya. Misalnya prosesor akan secara terus-menerus melakukan <em>processing</em> agar animasi pada wallpaper terus berjalan.</p><h4>Sinkronisasi Otomatis Yang Aktif</h4><p>Fitur sinkronisasi otomatis yang aktif untuk berbagai aplikasi dapat membebani sistem dan mempengaruhi kinerja ponsel. ​</p><p>Beberapa Tips Mengatasi Ponsel Lemot</p><ul><li>Hapus file yang tidak diperlukan atau jika perlu pindahkan media penyimpanan eksternal atau <em>cloud</em>.</li><li>Uninstall aplikasi-aplikasi yang tidak dibutuhkan sehingga ruang penyimpanan menjadi lebih lega.</li><li>Bersihkan cache aplikasi secara berkala melalui pengaturan perangkat atau menggunakan aplikasi khusus seperti CCleaner.</li><li>Selalu perbarui sistem operasi dan aplikasi yang terinstal.</li><li>Hindari menggunakan live wallpaper.</li><li>Nonaktifkan sinkronisasi otomatis.</li><li>Gunakan aplikasi versi lite jika ada karena lebih hemat ruang penyimpanan dan sumber daya.</li></ul><h3>Kesimpulan</h3><p>Pada umumnya, aplikasi-aplikasi yang dapat berjalan secara latar belakang (background) seperti aplikasi chatting atau pesan singkat modern didesain untuk berjalan secara efisien di latar belakang, memanfaatkan teknologi seperti FCM dan mekanisme manajemen sumber daya RAM Android. Namun, perbedaan desain dan <em>policy </em>manajemen sumber daya dapat berpengaruh pada penggunaan CPU (prosesor) dan memori. Jika ponsel kamu terasa lambat, kemungkinan besar ada faktor lain yang mempengaruhinya, seperti aplikasi lainnya atau masalah perangkat keras.</p><p><strong>Jadi, jawabannya adalah mitos bahwa aplikasi chatting atau pesan singkat dapat membuat ponsel kita lemot.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b59dfcda1d3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Docker Compose Like a Pro (Part 2) : Steps To Setup & Run Your Services]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://henwib.medium.com/building-blocks-of-docker-compose-steps-to-setup-run-your-services-part-2-04ed30fe52fb?source=rss-6681087b94a5------2"><img src="https://cdn-images-1.medium.com/max/2600/1*A-9BBb3wy4VrdcIuWKAWvg.jpeg" width="3000"></a></p><p class="medium-feed-snippet">This article is part 2 of a total 3 articles in a series about &#x201C;Building Blocks of Docker Compose&#x201D;. Now, I will show the step-by-step&#x2026;</p><p class="medium-feed-link"><a href="https://henwib.medium.com/building-blocks-of-docker-compose-steps-to-setup-run-your-services-part-2-04ed30fe52fb?source=rss-6681087b94a5------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://henwib.medium.com/building-blocks-of-docker-compose-steps-to-setup-run-your-services-part-2-04ed30fe52fb?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/04ed30fe52fb</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitsubmodule]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker-compose]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 14:01:03 GMT</pubDate>
            <atom:updated>2025-05-26T22:25:54.521Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Running Docker Compose Like a Pro (Part 1) : Organizing Services with Git Submodules]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://henwib.medium.com/building-blocks-of-docker-compose-organizing-services-with-git-submodules-part-1-6535b2dbf8d1?source=rss-6681087b94a5------2"><img src="https://cdn-images-1.medium.com/max/1280/1*JlWIz4sSlnyDYcGixpkYsA.jpeg" width="1280"></a></p><p class="medium-feed-snippet">In this article, I&#x2019;ll share a fun and practical way to manage your Docker Compose project using Git submodules&#x2026;</p><p class="medium-feed-link"><a href="https://henwib.medium.com/building-blocks-of-docker-compose-organizing-services-with-git-submodules-part-1-6535b2dbf8d1?source=rss-6681087b94a5------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://henwib.medium.com/building-blocks-of-docker-compose-organizing-services-with-git-submodules-part-1-6535b2dbf8d1?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6535b2dbf8d1</guid>
            <category><![CDATA[gitsubmodule]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-compose]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 08:41:52 GMT</pubDate>
            <atom:updated>2025-05-26T22:25:33.010Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Secrets in Code: Why Your API Keys Deserve a Cozy .env Hideaway]]></title>
            <link>https://henwib.medium.com/secrets-in-code-why-your-api-keys-deserve-a-cozy-env-hideaway-69076081eb09?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/69076081eb09</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[dotenv]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Fri, 17 Jan 2025 23:38:28 GMT</pubDate>
            <atom:updated>2025-01-21T03:35:59.183Z</atom:updated>
            <content:encoded><![CDATA[<h3>Secrets in Code: Why Your API Keys Deserve a Cozy “<em>.env”</em> Hideaway</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UA5nmJ4cEcehPJIGgKyKKA.jpeg" /><figcaption>Securing sensitive information and secrets using .env files (Photo by <a href="https://www.pexels.com/photo/brass-colored-metal-padlock-with-chain-4291/">Life Of Pix</a>)</figcaption></figure><p>At some point, every coder has to deal with sensitive data: API keys, database passwords, secret tokens — the works. You don’t want this stuff floating around in your codebase where anyone can grab it. Enter the .env file: a trusty sidekick for developers looking to keep their secrets safe. Let’s dive into why .env files are a good idea, how they stack up against databases, and what to do if you want to use a database for storing sensitive info.</p><h3>Why .env Files Are Secure</h3><h4>1. Keep Your Secrets Separate</h4><p>Imagine having all your secret keys lying around in plain sight in your codebase. .env files stash those secrets away in a separate file, so they don’t end up exposed when sharing or publishing your code. Plus, by adding .env to .gitignore, you’re saying, “Stay out of this!” to your version control system. It’s up to you but you should do it.</p><h4>2. Update Without Breaking a Sweat</h4><p>Changing an API key? No problem! Just tweak the .env file, and your app picks up the new value without needing a code update. It’s like switching the batteries in your remote—quick and painless.</p><h4>3. Fewer Oops Moments</h4><p>Accidentally pushing sensitive data to a public repo is a nightmare. Properly handled .env files stay out of your repository, reducing the risk of “oops” moments that could expose your secrets. That’s why you should always add .env to .gitignore.</p><h4>4. Stay Local, Stay Safe</h4><p>Since .env files live in your local environment, they’re not flying around on the network, making them much harder to intercept.</p><h4>5. It Values Managed By the Operating System</h4><p>Looking at how the .env files works, it values will be loaded to the environment variables in the operating system. This process is securely done by the tools and frameworks. This reduces the attack surface compared to database storage.</p><h4>6. Minimize Attack Surface</h4><p>Related to the previous point. Unlike databases, .env files are not network-accessible, meaning they can’t directly attacked or retrieved by someone.</p><h4>7. Only the Essentials</h4><p>.env files keep sensitive data visible only to the app and the system running it. Other processes or users? They’re out of luck.</p><h4>8. Compatibility with Secret Management Tools</h4><p>.env files are compatible with tools and frameworks that load environment variables securely, such as dotenv libraries in various programming languages.</p><h3>Drawbacks of Using .env Files</h3><p>While .env files are a solid choice for managing secrets, they’re not perfect. Here are some potential pitfalls:</p><h4>1. Limited Scalability</h4><p>.env files are great for small to medium projects but can become unwieldy as your app grows or scales across multiple environments. Managing secrets across many servers or services can quickly turn into a logistical headache.</p><h4>2. No Built-In Security Features</h4><p>.env files rely on file system permissions for security, which can be risky if improperly configured. Unlike databases, they don’t have built-in features like encryption, access logging, or monitoring.</p><h4>3. Harder to Audit</h4><p>.env files don’t have any audit trails. If someone changes or accesses the file, there’s no way to track who did what or when.</p><h4>4. Manual Secret Rotation</h4><p>Rotating secrets stored in .env files can be time-consuming, especially in environments with multiple servers. Automating this process often requires additional tools or scripts.</p><h4>5. Risk of Accidental Exposure</h4><p>Improperly configured .gitignore files or human error can lead to .env files being accidentally committed to version control, exposing sensitive information.</p><h3>Storing Sensitive Information in a Database</h3><p>However, it’s not fair to only talk about .env without compare it with the database.</p><h4>Why It’s Great</h4><ol><li><strong>One-Stop Shop</strong> Databases let you store all your sensitive info in one place, making it easier to manage and update secrets across multiple apps or environments.</li><li><strong>Big Brother Is Watching</strong> Modern databases have logging and monitoring tools. You’ll know who accessed what, when, and how — great for keeping everyone accountable.</li><li><strong>Room to Grow</strong> For apps with lots of secrets, databases are like having a walk-in closet: they can handle more stuff without breaking a sweat.</li><li><strong>Built-in Shields</strong> With encryption at rest and in transit, your sensitive data stays locked up tight, even if someone breaches the database or intercepts transmissions.</li></ol><h4>But… There’s a Catch</h4><ol><li><strong>Always Online</strong> Databases need a network connection. If the database goes down, your app might be left hanging.</li><li><strong>Setup Overhead</strong> Using a database for secrets adds extra work — encryption, permissions, logs — it’s like assembling IKEA furniture, but with higher stakes.</li><li><strong>Bigger Bullseye</strong> Databases are juicy targets for attackers. If they get in, they get everything.</li><li><strong>Speed Bumps</strong> Accessing a database adds a bit of latency, which might be an issue if your app needs lightning-fast responses.</li></ol><h3>Making Databases Secure for Sensitive Data</h3><p>Of course the choice is yours. If you’re going the database route, here’s how to keep things locked down:</p><h4>1. Encrypt, Encrypt, Encrypt!</h4><ul><li>Use encryption for data both at rest and in transit.</li><li>Leverage built-in database encryption tools like <a href="https://en.wikipedia.org/wiki/Transparent_data_encryption">Transparent Data Encryption (TDE)</a>.</li></ul><h4>2. Tighten the Reins with RBAC (Role Based Access Control)</h4><ul><li>Similar to IAM (Identity Access Management) in AWS or GCP.</li><li>Give users and apps the minimum permissions they need.</li><li>Regularly review and update access rights.</li></ul><h4>3. Go Beyond Passwords</h4><ul><li>Enable multi-factor authentication (MFA).</li><li>Use strong, unique passwords, and ditch the default ones.</li></ul><h4>4. Keep an Eye on Things</h4><ul><li>Enable logging to track database activity.</li><li>Set up alerts for anything suspicious, like multiple failed login attempts.</li></ul><h4>5. Rotate Secrets Regularly</h4><ul><li>Change passwords, API keys, and tokens often.</li><li>Automate rotations to make life easier.</li></ul><h4>6. Control the Traffic</h4><ul><li>Use firewalls to limit database access to trusted IPs.</li><li>Avoid public access — stick to private networks or VPNs.</li></ul><h4>7. Secure Your Backups</h4><ul><li>Encrypt your database backups.</li><li>Store them in safe, restricted locations.</li></ul><h4>8. Bring in the Pros</h4><ul><li>Use tools like HashiCorp Vault or AWS Secrets Manager for extra security features like automated rotation and access auditing.</li></ul><h3>Face-Off: .env Files vs Databases</h3><h4>Advantages of .env Files:</h4><ul><li><strong>Ease of Use</strong>: Super simple, great for small apps.</li><li><strong>Fast, Local Access</strong>: Minimal latency as everything is local.</li><li><strong>Works Offline</strong>: No network dependency.</li></ul><h4>Disadvantages of .env Files:</h4><ul><li><strong>Limited Scalability</strong>: Not ideal for large systems.</li><li><strong>No Built-In Security</strong>: Relies on file permissions alone.</li><li><strong>Manual Management</strong>: Backup and rotation can be cumbersome.</li></ul><h4>Advantages of Databases:</h4><ul><li><strong>Centralized Management</strong>: Handles secrets across multiple apps.</li><li><strong>Granular Security</strong>: Access control, encryption, and monitoring are built-in.</li><li><strong>Scalable</strong>: Perfect for large-scale systems with complex needs.</li><li><strong>Automated Backups</strong>: Easy and secure to maintain.</li></ul><h4>Disadvantages of Databases:</h4><ul><li><strong>Setup Complexity</strong>: Needs more effort and maintenance.</li><li><strong>Network Dependency</strong>: Requires an online connection.</li><li><strong>Potential Latency</strong>: Slight delays compared to local access.</li><li><strong>High-Value Target</strong>: More attractive to attackers.</li></ul><h3>When to Use Each</h3><p>We have learned and comparing both methods. Now you need to know when to use each.</p><h4>Choose .env Files If:</h4><ul><li>You’re building a small-to-medium app.</li><li>You want something lightweight and easy.</li><li>You’re working locally or in a simple environment.</li></ul><h3>Go with Databases If:</h3><ul><li>You’re managing secrets for a big, complex system.</li><li>You need centralized control and detailed monitoring.</li><li>You want advanced security features for distributed environments.</li></ul><h3>Best Practices for Secure .env Files</h3><h4><strong>File Permissions</strong></h4><p>Restrict access to the .env file by setting file permissions (chmod 600) so only the application process and authorized users can read it.</p><h4><strong>Do Not Commit to Version Control</strong></h4><p>Add .env to .gitignore to prevent accidental commits. If a .env file is committed, assume the keys are compromised and rotate them immediately.</p><h4><strong>Encryption and Backup</strong></h4><p>If backups are created, ensure that .env files are encrypted during storage and transfer.</p><h4><strong>Use Containerized Secrets Management</strong></h4><p>In containerized environments (e.g., Docker, Kubernetes), use secret management tools or environment variable injection securely instead of hardcoding .env files. We can inject these environment variables via the Docker Compose YAML file.</p><h4><strong>Monitor Access</strong></h4><p>Ensure logs and audit systems track who has accessed the .env file to detect unauthorized access.</p><h4><strong>Limit Scope</strong></h4><p>Keep the .env file small and include only essential secrets. For more complex setups, use dedicated secret management solutions.</p><h4><strong>Environment-Specific Files</strong></h4><p>Use separate .env files for different environments (e.g., .env.dev, .env.prod) and ensure production files are only accessible in the production environment.</p><h3>Bringing It All Together</h3><p>.env files and databases both have their place in the world of secret management. .env files are great for quick, simple setups, while databases shine in larger, more complex systems. Whichever you choose, always follow best practices to keep your secrets safe. And hey, sometimes the best answer is a combo—pairing .env files or databases with tools like AWS Secrets Manager or HashiCorp Vault for the ultimate secret-keeping strategy.</p><p>Happy coding, and may your secrets stay secret!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69076081eb09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Try-Catch When You Can Do Better?]]></title>
            <link>https://henwib.medium.com/why-try-catch-when-you-can-do-better-575fb7a85f10?source=rss-6681087b94a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/575fb7a85f10</guid>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[error-handling-in-js]]></category>
            <dc:creator><![CDATA[Hendro Wibowo]]></dc:creator>
            <pubDate>Fri, 17 Jan 2025 12:22:14 GMT</pubDate>
            <atom:updated>2025-01-17T23:46:17.861Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qFPBt9QVejs1MfX4BVi30Q.png" /><figcaption>Illustration</figcaption></figure><p>Have you ever heard about try-catch block in Javascript? I am pretty sure that most will say yes and even actually use it in your code. It’s been the default way to handle errors in JavaScript forever. But let’s be real—sometimes it feels like using duct tape to fix a leaky pipe and feels hacky. It gets the job done, but it’s bulky, hard to manage (especially you use multiple try-catch blocks in a deeply nested way), and not the most elegant solution. Lucky for us, JavaScript has grown up, and now we have way cooler options for error handling. Let’s explore them!</p><h3>1. Promises: Sleek and Simple</h3><p>Promises are like the stylish upgrade to try-catch, especially for handling asynchronous code. Instead of wrapping everything in a giant block, you can use .catch() to handle errors gracefully.</p><h4>Example:</h4><pre>fetch(&#39;https://api.example.com/data&#39;)<br>  .then(response =&gt; response.json())<br>  .then(data =&gt; console.log(data))<br>  .catch(error =&gt; console.error(&#39;Oops! Something went wrong:&#39;, error));</pre><p>No extra clutter, no unnecessary noise — just clean, easy-to-read code. Promises make your life easier.</p><p>You can combine it with async/await to write reusable function. See the example below.</p><h4>Example:</h4><pre>async function fetchData() {<br>  const response = await fetch(&#39;https://api.example.com/data&#39;);<br>  return response.json();<br>}<br><br>fetchData()<br>  .then(data =&gt; console.log(data))<br>  .catch(error =&gt; console.error(&#39;Uh-oh! Error:&#39;, error));</pre><p>This keeps your main logic focused and lets you handle errors without breaking the flow.</p><h3>2. Higher-Order Functions: Error-Proofing Your Code</h3><p>Higher-order functions are like your code’s personal bodyguards. They wrap your functions and handle errors automatically, so you don’t have to keep rewriting the same logic.</p><h4>Example:</h4><pre>function handleError(fn) {<br>  return function(...args) {<br>    try {<br>      return fn(...args);<br>    } catch (error) {<br>      console.error(&#39;Oh no! Error:&#39;, error);<br>    }<br>  };<br>}<br><br>const safeFunction = handleError((x, y) =&gt; x / y);<br>console.log(safeFunction(10, 2)); // 5<br>console.log(safeFunction(10, 0)); // Oh no! Error: Division by zero</pre><p>Now you’ve got error handling baked right into your functions. Simple and effective!</p><h3>3. React Error Boundaries: Catch Errors Like a Pro</h3><p>If you’re using React, error boundaries are your secret weapon. They catch errors in your components so your app doesn’t crash.</p><h4>Example:</h4><pre>class ErrorBoundary extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = { hasError: false };<br>  }<br><br>  static getDerivedStateFromError(error) {<br>    return { hasError: true };<br>  }<br>  <br>  componentDidCatch(error, info) {<br>    console.error(&#39;Caught an error:&#39;, error, info);<br>  }<br><br>  render() {<br>    if (this.state.hasError) {<br>      return &lt;h1&gt;Oops! Something went wrong.&lt;/h1&gt;;<br>    }<br>    return this.props.children;<br>  }<br>}<br><br>// Usage<br>&lt;ErrorBoundary&gt;<br>  &lt;MyComponent /&gt;<br>&lt;/ErrorBoundary&gt;</pre><p>With error boundaries, you can focus on building your app without worrying about unexpected crashes.</p><h3>4. Utility Libraries: Fancy and Functional</h3><p>Libraries like fp-ts, Ramda, and lodash bring functional programming into the mix, making error handling more structured and reusable.</p><h4>Example:</h4><pre>import { tryCatch } from &#39;fp-ts/TaskEither&#39;;<br><br>const fetchData = tryCatch(<br>  () =&gt; fetch(&#39;https://api.example.com/data&#39;).then(res =&gt; res.json()),<br>  reason =&gt; new Error(String(reason))<br>);<br><br>fetchData().then(result =&gt; {<br>  if (result._tag === &#39;Left&#39;) {<br>    console.error(&#39;Yikes! Error:&#39;, result.left);<br>  } else {<br>    console.log(&#39;Hooray! Data:&#39;, result.right);<br>  }<br>});</pre><p>These tools let you handle errors in a consistent and powerful way, perfect for larger projects.</p><h3>5. The ?= Operator</h3><p>This is the new way to handle errors in Javascript and it still in DRAFT status (see <a href="https://github.com/arthurfiorette/proposal-safe-assignment-operator">here</a>). But once its approved, it will be a good additional on how we are handle the errors better.</p><p>The ?= operator — or you can call it <em>Safe Assigment </em>operator — eliminates the way you write a nested try-catch block by handling errors inline. It will returns a tuple [error, result] . The first value represents the error (if any) and the second value represents the succesfull result.</p><p>If you are keen to see how its works on our code. See the example below.</p><h4>Example:</h4><p>You have a code with a nested try-catch below.</p><pre>const getUserData = async () =&gt; {<br>  try {<br>    const response = await fetch(&quot;https://api.example.com/users&quot;);<br><br>    try {<br>      const data = await response.json();<br>      return data;<br>    } catch (error) {<br>      console.log(&#39;Failed to parse data: &#39;, error);<br>    }<br>  } catch (reqError) {<br>    console.log(&#39;Request failed:&#39;, reqError);<br>  }<br>}; </pre><p>And this is how ?= operator come to the rescue.</p><pre>const getUserData = async () =&gt; {<br>  const [error, userData] ?= await fetch(&quot;https://api.example.com/users&quot;).json();<br>  <br>  if (error) {<br>    console.error(&#39;Error occurred:&#39;, error);<br>    return error;<br>  } else {<br>    console.log(&#39;Data fetched successfully:&#39;, userData);<br>    return userData;<br>  }<br>};</pre><p>As you can see, the code become more readable, cleaner, and straightforward.</p><h3>Wrapping It Up</h3><p>So, try-catch, it’s been fun, but it’s time to move on. Of course you can use it sometimes but keep it simple. JavaScript has so many better ways to handle errors now. Promises, higher-order functions, React error boundaries, utility libraries, and ?= operator can all make your code cleaner, easier to read, and just plain better. Next time you feel the urge to write try { ... } catch { ... }, stop and ask yourself: is there a better way?</p><p>Spoiler alert: there is!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=575fb7a85f10" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>