<?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 Eduardus Tjitrahardja on Medium]]></title>
        <description><![CDATA[Stories by Eduardus Tjitrahardja on Medium]]></description>
        <link>https://medium.com/@edutjie?source=rss-3560f7e86cef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Cuoy8SaY3R9dvsRR</url>
            <title>Stories by Eduardus Tjitrahardja on Medium</title>
            <link>https://medium.com/@edutjie?source=rss-3560f7e86cef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:20:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@edutjie/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[️ Monitoring Your Go Gin App with New Relic One ]]></title>
            <link>https://edutjie.medium.com/%EF%B8%8F-monitoring-your-go-gin-app-with-new-relic-one-d8214cd83161?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8214cd83161</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[monitoring-software]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Thu, 05 Dec 2024 15:53:25 GMT</pubDate>
            <atom:updated>2024-12-05T15:54:01.807Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*PcDpTP8ey7GuhBWf" /></figure><p>If your app’s performance matters to you (hint: it should! 🧐), then <strong>New Relic One</strong> is your best friend. It gives you <strong>real-time application monitoring</strong> to pinpoint bottlenecks, errors, and improve user experience. Today, we’ll integrate <strong>New Relic One</strong> into a Go application built using the <strong>Gin framework</strong>.</p><p>Let’s dive in! 🌊</p><h3>📦 What is New Relic One?</h3><p><strong>New Relic One</strong> is a performance monitoring tool that tracks your application’s behavior in real time. From request timings to database queries, it provides deep insights into your app’s health. It integrates with a wide range of languages, and with Go, it’s a breeze! 🌬️</p><h3>🔧 Setting Up New Relic One in a Gin App</h3><p>Here’s how to integrate New Relic One with your Go app using the <strong>Gin framework</strong>.</p><h4>Step 1: Install the New Relic Go Agent</h4><p>First, add the New Relic Go agent to your project:</p><pre>go get github.com/newrelic/go-agent/v3/newrelic<br>go get github.com/newrelic/go-agent/v3/integrations/nrgin</pre><h4>Step 2: Configure New Relic in Your App</h4><p>The configuration process starts by creating a New Relic application instance. Ensure you securely manage the <strong>New Relic license key</strong> (use environment variables or a configuration file).</p><p>Here’s an example:</p><pre>package main<br><br>import (<br>	&quot;fmt&quot;<br>	&quot;os&quot;<br>	&quot;github.com/gin-gonic/gin&quot;<br>	&quot;github.com/newrelic/go-agent/v3/newrelic&quot;<br>	&quot;github.com/newrelic/go-agent/v3/integrations/nrgin&quot;<br>)<br><br>func main() {<br>  cfg := loadConfig() // Load configuration (e.g., using viper or environment variables)<br>  // Initialize New Relic application<br>  var nrApp *newrelic.Application<br>  if cfg.NewRelic.Enabled {<br>    app, err := newrelic.NewApplication(<br>      newrelic.ConfigAppName(cfg.NewRelic.ApplicationName),<br>      newrelic.ConfigLicense(cfg.NewRelic.LicenseKey),<br>      newrelic.ConfigDebugLogger(os.Stdout),<br>      newrelic.ConfigAppLogForwardingEnabled(true),<br>    )<br>    if err != nil {<br>      fmt.Printf(&quot;Error initializing New Relic: %v\n&quot;, err)<br>      return<br>    }<br>    nrApp = app<br>  }<br>  // Initialize Gin<br>  r := gin.Default()<br>  // Use New Relic middleware for Gin<br>  if nrApp != nil {<br>    r.Use(nrgin.Middleware(nrApp))<br>  }<br>  // Define routes<br>  r.GET(&quot;/ping&quot;, func(c *gin.Context) {<br>    c.JSON(200, gin.H{&quot;message&quot;: &quot;pong&quot;})<br>  })<br>  // Start server<br>  r.Run(&quot;:8080&quot;)<br>}</pre><h4>Step 3: Adding New Relic Middleware</h4><p>The nrgin package enables middleware that automatically tracks all Gin routes. When the middleware is applied, every request will be logged and tracked by New Relic.</p><pre>r.Use(nrgin.Middleware(nrApp))</pre><p>This middleware creates a <strong>New Relic transaction</strong> for each incoming HTTP request, capturing details like:</p><ul><li>Request timings ⏱️</li><li>Error rates ❌</li><li>Custom attributes (if you choose to add them)</li></ul><h3>🖼️ Exploring New Relic Dashboards</h3><p>Once your app is integrated, you can monitor it through the New Relic dashboard. Let’s walk through the key pages:</p><h4>1. Summary Page: Key Metrics at a Glance</h4><p>The <strong>Summary page</strong> provides an overview of your application’s health, including:</p><ul><li><strong>Throughput:</strong> How many requests your app handles per minute.</li><li><strong>Response Time:</strong> Average time your app takes to respond.</li><li><strong>Error Rate:</strong> Percentage of failed transactions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*escUaLZ4sCUJzAWdbc7-lQ.png" /><figcaption>📸 <em>Example Screenshot</em></figcaption></figure><h4>2. Transactions Page: Pinpoint Slow Endpoints</h4><p>On the <strong>Transactions page</strong>, you can identify:</p><ul><li>Which endpoints are taking the longest to respond.</li><li>How often specific routes are called.</li><li>Which transactions generate the most errors.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJPH3m17Y9JukZ4ymc9lDw.png" /><figcaption>📸 <em>Example Screenshot</em></figcaption></figure><h4>3. Distributed Tracing: Track Request Flow</h4><p>Ever wonder how a request travels through your app? The <strong>Distributed Tracing</strong> page shows:</p><ul><li><strong>End-to-end flow</strong> of requests across services.</li><li>Latency at each stage of the transaction.</li><li>Potential bottlenecks in third-party calls.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*isXK3qO_ibq5szsNGOheyA.png" /><figcaption>📸 <em>Example Screenshot</em></figcaption></figure><h4>4. Logs Page: Debugging Made Simple</h4><p>The <strong>Logs page</strong> aggregates your app’s logs and links them to specific transactions. Features include:</p><ul><li>Searching and filtering logs by attributes.</li><li>Linking logs to transactions for easier debugging.</li><li>Forwarding logs directly to New Relic using the Go agent’s log integration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZpIMybGSKZAwfxuxWbx9hw.png" /><figcaption>📸 <em>Example Screenshot</em></figcaption></figure><h3>🎯 Best Practices with New Relic One</h3><ol><li><strong>Secure Your License Key:</strong> Store the license key in environment variables or a secrets manager.</li><li><strong>Use Custom Attributes:</strong> Enrich your transactions with business-specific metadata.</li><li><strong>Set Alerts:</strong> Configure alerts to get notified about high response times or error rates.</li><li><strong>Analyze Distributed Traces:</strong> Regularly review the flow of requests to optimize service interactions.</li></ol><h3>🚀 Conclusion</h3><p>Integrating <strong>New Relic One</strong> with your Gin application transforms how you monitor and optimize performance. The <strong>Summary</strong>, <strong>Transactions</strong>, <strong>Distributed Tracing</strong>, and <strong>Logs</strong> pages empower you with actionable insights to make your app faster, more reliable, and bug-free.</p><p>So what are you waiting for? Give your Gin app the monitoring it deserves! 🖥️✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8214cd83161" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Secure Programming: Building Robust Applications That Withstand Attacks ️]]></title>
            <link>https://edutjie.medium.com/secure-programming-building-robust-applications-that-withstand-attacks-%EF%B8%8F-f3ce53379f1c?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3ce53379f1c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[secure-programming]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Wed, 04 Dec 2024 18:33:00 GMT</pubDate>
            <atom:updated>2024-12-04T18:33:00.345Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*aO_aeN3rielrNB8B.jpeg" /></figure><p>In today’s hyper-connected world, ensuring the security of your application isn’t optional — it’s essential. Hackers don’t take breaks, and neither should your defenses! 🕵️‍♂️💻</p><p>This blog dives into <strong>secure programming practices</strong> using a <strong>Go codebase</strong> as a case study. By the end, you’ll have actionable insights to protect your applications from common vulnerabilities while keeping your users and data safe. 🚀</p><h3>📜 1. Secure Configuration Management</h3><p>Sensitive information, such as API keys and database credentials, is like the treasure map to your app’s gold. 🪙 Don’t leave it lying around!</p><p>Here’s how to securely load and validate configurations in Go:</p><h4>Example: Configuration Loading &amp; Validation</h4><pre>package config<br><br>import (<br>    &quot;context&quot;<br>    &quot;encoding/json&quot;<br>    &quot;fmt&quot;<br>    &quot;os&quot;<br>    &quot;github.com/go-playground/validator/v10&quot;<br>    &quot;github.com/mitchellh/mapstructure&quot;<br>    &quot;github.com/tidwall/jsonc&quot;<br>)<br><br>const (<br>    localConfigFileName = &quot;config.jsonc&quot;<br>)<br><br>type configManager struct {<br>    goValidator   *validator.Validate<br>    decoderConfig mapstructure.DecoderConfig<br>}<br><br>func (c *configManager) Start(ctx context.Context, dest any) error {<br>    err := c.readLocal(ctx, dest)<br>    if err != nil {<br>        if !os.IsNotExist(err) {<br>            return fmt.Errorf(&quot;config: local: %w&quot;, err)<br>        }<br>        fmt.Printf(&quot;Warning: local config file doesn&#39;t exist: %s\n&quot;, localConfigFileName)<br>    }<br>    return nil<br>}<br><br>func (c *configManager) readLocal(ctx context.Context, dest any) error {<br>    localConfRaw, err := os.ReadFile(localConfigFileName)<br>    if err != nil {<br>        return err<br>    }<br>    var localMap map[string]any<br>    localConfRaw = jsonc.ToJSON(localConfRaw)<br>    if err := json.Unmarshal(localConfRaw, &amp;localMap); err != nil {<br>        return err<br>    }<br>    return mapstructure.Decode(localMap, dest)<br>}</pre><h3>Why it Matters:</h3><ul><li><strong>Avoid Hardcoding Secrets:</strong> Store sensitive data in secure environments like encrypted config files or secret management tools (e.g., AWS Secrets Manager).</li><li><strong>Validate Inputs:</strong> Use packages like go-playground/validator to ensure configurations meet expected formats.</li></ul><h3>🗄️ 2. Secure Database Connections</h3><p>Your database is the vault of your app, and an insecure connection is an open door for intruders. 🚪🔓</p><h4>Example: Establishing &amp; Closing Database Connections</h4><pre>func main() {<br>    cfg := config.Load()<br><br>    conn := dependency.NewPostgreSQL(cfg.Common.Postgres)<br>    defer func() {<br>        err := conn.Close()<br>        if err != nil {<br>            utils.Logger.Fatalf(&quot;failed to close db, err: %v&quot;, err)<br>        }<br>        _ = os.Stdout.Sync()<br>    }()<br>}</pre><h3>Best Practices:</h3><ul><li><strong>Use Secure Credentials:</strong> Load credentials from a secure source and avoid hardcoding them.</li><li><strong>Encrypt Connections:</strong> Always use TLS/SSL when connecting to your database.</li></ul><h3>☁️ 3. Secure AWS Integrations</h3><p>When integrating with AWS services, credentials are your lifeline — and mishandling them is asking for trouble. 🛑</p><h4>Example: Loading AWS Credentials Securely</h4><pre>func NewAWSConfig(cfg config.AWS) *aws.Config {<br>    awsCfg, err := awsconfig.LoadDefaultConfig(<br>        context.TODO(),<br>        awsconfig.WithRegion(cfg.Region),<br>        awsconfig.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(cfg.AccessKey, cfg.SecretAccessKey, &quot;&quot;)),<br>    )<br>    if err != nil {<br>        utils.Logger.Fatalf(&quot;unable to load SES configuration: %v&quot;, err)<br>    }<br>    return &amp;awsCfg<br>}</pre><h3>Pro Tips:</h3><ul><li>Use <strong>IAM Roles</strong> for resource-specific access control.</li><li>Leverage <strong>AWS SDK’s Secure Credential Providers</strong> to load credentials dynamically.</li></ul><h3>🔑 4. Middleware for Authentication</h3><p>Authentication is your first line of defense. Without it, your app is like a house with no locks. 🏠🔓</p><h4>Example: Authentication Middleware Using JWT</h4><pre>package middleware<br><br>import (<br>    &quot;github.com/gin-gonic/gin&quot;<br>    &quot;kg/procurement/internal/token&quot;<br>    &quot;net/http&quot;<br>    &quot;strings&quot;<br>)<br><br>const (<br>    AuthorizationHeader = &quot;Authorization&quot;<br>    BearerType          = &quot;Bearer&quot;<br>    ErrorAuthHeader     = &quot;authorization header not provided&quot;<br>    ErrorAuthInvalid    = &quot;authorization header not valid&quot;<br>    ErrorAuthType       = &quot;authorization type not valid&quot;<br>)<br><br>type AuthMiddleware struct {<br>    tokenManager token.TokenManager<br>}<br><br>func NewAuthMiddleware(manager token.TokenManager) *AuthMiddleware {<br>    return &amp;AuthMiddleware{<br>        tokenManager: manager,<br>    }<br>}<br><br>func (m *AuthMiddleware) MustAuthenticated() gin.HandlerFunc {<br>    return func(ctx *gin.Context) {<br>        authorizationHeader := ctx.GetHeader(AuthorizationHeader)<br>        if len(authorizationHeader) == 0 {<br>            ctx.JSON(http.StatusBadRequest, gin.H{<br>                &quot;error&quot;: ErrorAuthHeader,<br>            })<br>            return<br>        }<br><br>        fields := strings.Fields(authorizationHeader)<br>        if len(fields) &lt; 2 {<br>            ctx.JSON(http.StatusBadRequest, gin.H{<br>                &quot;error&quot;: ErrorAuthInvalid,<br>            })<br>            return<br>        }<br><br>        authorizationType := fields[0]<br>        if authorizationType != BearerType {<br>            ctx.JSON(http.StatusBadRequest, gin.H{<br>                &quot;error&quot;: ErrorAuthType,<br>            })<br>            return<br>        }<br><br>        tokenStr := fields[1]<br>        claims, err := m.tokenManager.ValidateToken(tokenStr)<br>        if err != nil {<br>            ctx.JSON(http.StatusInternalServerError, gin.H{<br>                &quot;error&quot;: err.Error(),<br>            })<br>            return<br>        }<br><br>        ctx.Set(&quot;auth_payload&quot;, token.ClaimSpec{<br>            UserID: claims.Subject,<br>        })<br>        ctx.Next()<br>    }<br>}</pre><h3>Why it’s Essential:</h3><ul><li><strong>Validate Tokens:</strong> Use libraries like jwt-go to decode and validate JWTs.</li><li><strong>Minimize Attack Surface:</strong> Implement token expiration and refresh mechanisms.</li></ul><h3>🚀 Conclusion: Code Like a Cybersecurity Pro!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*RAKjYV4mjj4dXEu8.jpg" /></figure><p>Secure programming isn’t just a checklist — it’s a mindset. By safeguarding your configurations, securing connections, properly handling credentials, and enforcing robust authentication, you can build applications that stand strong against threats.</p><p>Start small, but think big! Your app and users will thank you. 💙</p><p><strong>Remember:</strong> Secure code is happy code. 😃 🧑‍💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3ce53379f1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Redis: The Ultimate Time-Saving Genie for Your Applications! ⏳]]></title>
            <link>https://edutjie.medium.com/redis-the-ultimate-time-saving-genie-for-your-applications-af250800464e?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/af250800464e</guid>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Wed, 04 Dec 2024 17:48:38 GMT</pubDate>
            <atom:updated>2024-12-04T17:48:38.319Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*GY-IqAQEPzHY0g_y.png" /></figure><p>When it comes to building high-performance applications, every millisecond counts. Enter <strong>Redis</strong>, the genie in the bottle of modern development. With its lightning-fast in-memory data store capabilities, Redis not only boosts your app’s speed but also helps you handle advanced use cases like a pro. Whether you’re caching, messaging, or just trying to keep your server from blowing a fuse, Redis has your back. 🧞</p><p>But first, let’s set up Redis in your local environment so you can start experiencing its magic!</p><h3>🛠 Getting Started with Redis 🐳</h3><p>The easiest way to get Redis up and running locally is with <strong>Docker</strong>. With just a few lines of code, you can spin up a Redis server faster than you can say, “shesellsseashellsbytheseashore..” 🏃‍♂️💨</p><p>Here’s the magic spell:</p><p><strong>Docker Compose File (Save as </strong><strong>docker-compose.yml):</strong></p><pre>version: &quot;3.8&quot;<br>services:<br>  redis-local:<br>    container_name: &quot;redis-local&quot;<br>    image: &quot;redis:latest&quot;<br>    ports:<br>      - &quot;6379:6379&quot;<br>    command: redis-server --requirepass password<br>    environment:<br>      REDIS_HOST: localhost<br>      REDIS_PORT: 6379<br>      REDIS_PASSWORD: password</pre><p>Now, run:</p><pre>docker-compose up -d</pre><p>🎉 Boom! Your Redis server is live on <strong>localhost:6379</strong> with a password (password). Time to unleash its power!</p><h3>💾 Caching: Why Redis is Your App’s BFF 🥰</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*FOIDd-K0DtTQH3qh.jpg" /></figure><p>Picture this: Your app is being bombarded with requests to fetch product details from the database. With every call, the database grows more stressed — like a programmer trying to meet a deadline without coffee. ☕💻</p><p>Here’s where Redis comes in, waving a wand of <strong>caching</strong> magic:</p><ol><li><strong>Cache Hits:</strong> If the data is already stored in Redis, it’s fetched instantly. No database query = instant speed boost! ⚡</li><li><strong>Cache Misses:</strong> If the data isn’t in Redis, the app fetches it from the database, caches it for future use, and returns it.</li></ol><p>Let’s check out how this works in code (credit to <a href="https://medium.com/u/f3cc8bc98698">Ferry</a>):</p><pre>func (v *VendorService) GetById(ctx context.Context, id string) (*Vendor, error) {<br>    cacheKey := fmt.Sprintf(&quot;vendor:%s&quot;, id)<br>    <br>    // First, check Redis for the data.<br>    if cachedData, err := v.redisClient.Get(ctx, cacheKey); err == nil {<br>        var vendor Vendor<br>        if err := json.Unmarshal([]byte(cachedData), &amp;vendor); err == nil {<br>            return &amp;vendor, nil // Cache hit! 🚀<br>        }<br>    }<br><br>    // Cache miss. Fetch from DB and store in Redis.<br>    vendor, err := v.vendorDBAccessor.GetById(ctx, id)<br>    if err != nil {<br>        return nil, err<br>    }<br>    if vendorJSON, err := json.Marshal(vendor); err == nil {<br>        _ = v.redisClient.Set(ctx, cacheKey, vendorJSON, 10) // Cache for 10 seconds.<br>    }<br>    return vendor, nil<br>}</pre><p>With caching, your app feels like a Formula 1 car instead of a slow bicycle. 🏎️💨</p><h3>🧹 Keeping Things Fresh with Cache Invalidation 🚮</h3><p>Updating data? Don’t forget to clean up stale cache entries! Redis makes it easy to ensure your data stays fresh and relevant.</p><p>Here’s how we update vendor details and clear outdated cache:</p><pre>func (v *VendorService) UpdateDetail(ctx context.Context, vendor Vendor) (*Vendor, error) {<br>    updatedVendor, err := v.vendorDBAccessor.UpdateDetail(ctx, vendor)<br>    if err != nil {<br>        return nil, err<br>    }<br>    cacheKey := fmt.Sprintf(&quot;vendor:%s&quot;, updatedVendor.ID)<br>    v.redisClient.Delete(ctx, cacheKey) // Remove stale cache. 🧹<br>    return updatedVendor, nil<br>}</pre><p>Redis helps you strike the perfect balance between speed and accuracy. 🎯</p><h3>📣Advance Topic: Redis Pub/Sub, The Real-Time Awesomeness 🎤✨</h3><p>Caching is cool, but let’s turn things up a notch with <strong>Redis Pub/Sub</strong>! 🎸</p><p>Imagine a collaborative document editor where every user sees real-time changes. Here’s how Redis makes it happen:</p><ul><li><strong>Publish:</strong> When a user makes an update, it’s published to a Redis channel. 📤</li><li><strong>Subscribe:</strong> Other users subscribed to the channel instantly receive the update. 📥</li></ul><p>Example:</p><ul><li><strong>Publisher:</strong></li></ul><pre>err := redisClient.Publish(ctx, &quot;doc-updates&quot;, &quot;User A edited line 3&quot;).Err()<br>if err != nil {<br>    log.Println(&quot;Publish failed:&quot;, err)<br>}</pre><ul><li><strong>Subscriber:</strong></li></ul><pre>pubsub := redisClient.Subscribe(ctx, &quot;doc-updates&quot;)<br>for msg := range pubsub.Channel() {<br>    fmt.Println(&quot;Update received:&quot;, msg.Payload)<br>}</pre><p>This setup is perfect for live notifications, chat apps, or multiplayer gaming. 🎮 I have once implemented it along with Web-socket to track bus location data in real time! 🚌⏳</p><h3>🌟 Redis: More Than Just a Cache</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*TZWI6uTRC1Dvlh4M.jpeg" /></figure><p>Redis isn’t just a one-trick pony. 🐴 It’s a Swiss Army knife for developers:</p><ul><li><strong>Data Structures Galore:</strong> Strings, hashes, lists, sets, and more!</li><li><strong>Streams:</strong> Great for handling event-driven systems.</li><li><strong>Lua Scripting:</strong> Perform complex operations atomically.</li><li><strong>Clustering:</strong> Scale your app with ease.</li></ul><h3>🎈 Wrapping Up</h3><p>Redis transforms your app into a speed demon. Whether you’re caching data, broadcasting updates, or building the next real-time sensation, Redis delivers unmatched performance and simplicity.</p><p>So, what are you waiting for? Start your Redis adventure today, and let the genie out of the bottle! 🧞‍♂️</p><p>Happy coding! 💻✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af250800464e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ The Joy of UI/UX: Breaking Down Nielsen and Molich’s 10 Usability Heuristics ]]></title>
            <link>https://edutjie.medium.com/the-joy-of-ui-ux-breaking-down-nielsen-and-molichs-10-usability-heuristics-e62876207f30?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/e62876207f30</guid>
            <category><![CDATA[ui-ux-design]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Fri, 29 Nov 2024 09:03:06 GMT</pubDate>
            <atom:updated>2024-11-29T09:07:20.507Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/198/0*-a69EPmLWJb5ZhAW.jpg" /></figure><p>When it comes to crafting delightful digital experiences, Jakob Nielsen and Rolf Molich’s <strong>10 Usability Heuristics</strong> are like the secret recipe for design magic 🪄✨. These aren’t rigid rules — they’re flexible guidelines to make user interfaces intuitive, user-friendly, and downright awesome! In this article, I’ll break down these principles and share how my team applied them in a recent project. Buckle up, because UI/UX is about to get fun! 🎢</p><h3>1️⃣ Visibility of System Status 🚦</h3><p>🧐 <em>“What’s happening?!”</em> is the last thing your users should be wondering. This principle ensures that users are always kept in the loop. In our project, we tackled this by adding a <strong>loading spinner</strong> whenever data was being fetched. It’s like your app saying, <em>“Hang tight, I’m on it!”</em> 💫</p><p>💡 <strong>Pro Tip:</strong> Use animations (like spinners or progress bars) to visually signal activity without overwhelming users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7bpQN1frkJSbzy7OKxaU6w.png" /></figure><h3>2️⃣ Match Between the System and the Real World 🌍</h3><p>Your interface should feel as natural as flipping a light switch! This principle encourages using terms, icons, and workflows familiar to users. In our app, we relied on universal symbols like ✏️ for editing and 👁️ for toggling password visibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*fimOZstlD3RLUdc8jwVAow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*hlujFEpQsid8JYS6tiT8Xg.png" /></figure><h3>3️⃣ User Control and Freedom 🕹️</h3><p>We all make mistakes 🤷‍♀️, but users shouldn’t feel trapped by them. This principle gives users the power to undo or back out of actions. In our app, we added a <strong>Cancel</strong> button so users could rethink sending emails.</p><p>🔑 <strong>Key Insight:</strong> Give users an <em>“I want to cancel”</em> button whenever possible. Freedom builds confidence! 🙌</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*8VcV6P5OxtFcTGdPLFrC3A.png" /></figure><h3>4️⃣ Consistency and Standards 📏</h3><p>Picture visiting a fast-food chain where every outlet has a different menu layout. 🤯 Confusing, right? Consistency in typography, colors, layouts, and workflows is essential. For our app, we kept the same design language across all pages.</p><p>✅ <strong>Takeaway:</strong> Familiarity = Comfort. Consistency reduces confusion and makes your design feel like a trusted friend. 🤝</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LhiF0zrqsuIFRSZtQknOEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Qs6ZBnaiqKqZjwiSSZ2KQ.png" /></figure><h3>5️⃣ Error Prevention 🚫</h3><p>Why fix an error when you can prevent it altogether? 🛡️ In our app, we added <strong>confirmation dialogs</strong> before bulk-sending emails to vendors. It’s a polite way of saying, <em>“Are you sure you wanna do this?”</em></p><p>⚠️ <strong>Designer Tip:</strong> Small precautions like confirmation steps save users from big regrets!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*qzfMKdBJGkI8yzBp2Brwmw.png" /></figure><h3>6️⃣ Recognition Rather than Recall 🧠</h3><p>Human memory is a tricky thing, so why make users rely on it unnecessarily? This principle highlights the importance of showing information upfront and preserving context to save users from frustration. In our app, when users cancel sending bulk emails, the state of the selected vendors remains intact. This means if they cancel to make adjustments, they can easily pick up right where they left off — no need to start from scratch!</p><p>📚 Analogy: Think of it as leaving a bookmark in a good book — users can dive back in without losing their place. They’ll appreciate the thoughtful design! 🙌</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWkb-02ed2RuGMKS6vz01A.png" /></figure><h3>7️⃣ Flexibility and Efficiency of Use 🚀</h3><p>Whether your users are newbies 👶 or pros 🧙‍♂️, your system should cater to both. We added <strong>keyboard shortcuts</strong> like Ctrl+C for copy and Ctrl+V for paste to speed up repetitive tasks. For bulk email blasts, we even created <strong>default templates</strong> to save users time.</p><p>⚡ <strong>Efficiency Hack:</strong> Shortcuts and templates aren’t just time-savers — they’re user-savers! 💾</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*17dAGc2led_HAIkTBGfKfg.png" /></figure><h3>8️⃣ Aesthetic and Minimalist Design 🎨</h3><p>Clutter is chaos. 🌀 This principle is all about keeping designs clean and focusing on what’s essential. In our project, we stripped the vendor list page down to just the key information and actions.</p><p>🎯 <strong>Design Insight:</strong> Minimalism isn’t about removing <em>everything</em> — it’s about keeping the <em>right</em> things. Think Marie Kondo for interfaces! ✨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aLvyr3EVLDxhQFpUHQXrrQ.png" /></figure><h3>9️⃣ Help Users Recognize, Diagnose, and Recover from Errors 🛠️</h3><p>Nobody likes mysterious error messages. 🕵️‍♂️ This principle ensures errors are easy to spot and even easier to fix. We displayed <strong>clear, actionable error messages</strong> in a bold 🔴 red toast notification, complete with steps to resolve the issue.</p><p>💡 <strong>Pro Tip:</strong> Replace vague errors like <em>“Invalid input”</em> with friendly, helpful ones like <em>“Oops! Please enter a valid email address.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*Lw_ldElfnuax77DAb1ZRsQ.png" /></figure><h3>🔟 Help and Documentation 📖 (Bonus!)</h3><p>Even the smoothest designs occasionally need a bit of backup. If needed, you can make a <strong>searchable help section</strong> with FAQs and guides to assist users. It’s like having a lifeline just a click away! 🆘</p><p>📋 <strong>Reminder:</strong> Great help content is concise, visual, and easy to find.</p><h3>🎉 Closing Thoughts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/0*mivPXcpnq95KD6kA.jpg" /></figure><p>UI/UX isn’t just about aesthetics; it’s about crafting experiences that make users feel smart, confident, and happy. By applying <strong>Nielsen and Molich’s 10 heuristics</strong>, we built an app that’s not only functional but also delightful to use. 🌟</p><p>Remember: The best designs don’t just work — they spark joy. ✨</p><p><strong>Let’s keep designing magic together!</strong> 🪄</p><h3>Reference</h3><p><a href="https://aelaschool.com/en/interactiondesign/10-usability-heuristics-ui-design/">Nielsen’s Heuristics: 10 Usability Principles To Improve UI Design — Aela School</a></p><p><a href="https://bootcamp.uxdesign.cc/simplified-jakob-nielsens-10-usability-heuristics-36a860c2ac9c">Simplified: Jakob Nielsen’s 10 usability heuristics | by Meghna Basak | Bootcamp (uxdesign.cc)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e62876207f30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker to the Rescue: Simplifying Software Development and Deployment ✨]]></title>
            <link>https://edutjie.medium.com/docker-to-the-rescue-simplifying-software-development-and-deployment-bffdfe189e58?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/bffdfe189e58</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 09:17:13 GMT</pubDate>
            <atom:updated>2024-11-25T09:17:13.827Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/422/0*zrnRkgADnfuxidUX" /><figcaption>Now what’s left is the solution for “How to center a div?”</figcaption></figure><p>Let’s face it: software development can get messy — like, spaghetti-code-in-production messy. And don’t even get me started on setting up local environments. “Wait, it works on my machine!” isn’t exactly what your teammates want to hear when the app crashes for them. 🙃</p><p>But don’t worry — Docker is here to save the day! If you’ve ever wanted to make your development life smoother (and your deployments drama-free), this post is for you.</p><h3>What’s the Big Deal About Docker?</h3><p>Docker lets you package your applications into <em>containers</em>, making them portable and consistent across all environments. Think of it like packing everything you need (code, dependencies, configurations) into a neat little box. 📦 No more “it worked on my laptop but not on the server” moments!</p><p>And the best part? <strong>Docker Compose</strong> helps you manage multi-container applications effortlessly. So, whether you’re spinning up a database, a frontend, or your backend magic, Docker Compose gets everything up and running in one command. 🚀</p><h3>The Dream Team: PostgreSQL + pgAdmin in Docker Compose</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YxQTGBMWADCMCnfB.jpeg" /></figure><p>Imagine setting up a <strong>PostgreSQL database</strong> and <strong>pgAdmin</strong> with a single YAML file. Sounds dreamy, right? Well, pinch yourself, because it’s real! Here’s a peek at my docker-compose.yml file for local development:</p><pre>version: &quot;3.9&quot;<br>name: procurement-dev<br>services:<br>  postgres-local:<br>    container_name: postgres-local<br>    image: postgres:latest<br>    restart: always<br>    ports:<br>      - &quot;5432:5432&quot;<br>    expose:<br>      - &quot;5432&quot;<br>    environment:<br>      POSTGRES_PASSWORD: postgres<br>      POSTGRES_USER: postgres<br>      POSTGRES_DB: kg-procurement<br>    volumes:<br>      - postgres-local:/var/lib/postgresql/data<br>  pgadmin-local:<br>      container_name: pgadmin-local<br>      image: dpage/pgadmin4<br>      restart: always<br>      ports:<br>        - &quot;15432:80&quot;<br>      environment:<br>        PGADMIN_DEFAULT_EMAIL: admin@admin.com<br>        PGADMIN_DEFAULT_PASSWORD: admin<br>      volumes:<br>        - pgadmin-local:/var/lib/pgadmin<br>volumes:<br>  postgres-local:<br>  pgadmin-local:<br>    driver: local</pre><h3>What’s Happening Here?</h3><ol><li><strong>Postgres Container</strong></li></ol><ul><li>Need a visual tool to manage your database? Enter <strong>pgAdmin</strong>!</li><li>Accessible on port <strong>15432</strong> (visit localhost:15432), with credentials defined in the environment variables.</li></ul><p><strong>2. pgAdmin Container</strong></p><ul><li>A <strong>PostgreSQL</strong> database runs in its container (postgres-local).</li><li>Exposed on port <strong>5432</strong>, so it’s ready to connect.</li><li>Uses environment variables to set up the database, user, and password.</li></ul><p><strong>3. Volumes for Persistence</strong></p><ul><li>Both containers store their data in volumes (postgres-local and pgadmin-local), so your database and pgAdmin configurations survive restarts.</li></ul><p>Now, running docker-compose up -d spins up both services. You’re ready to build, query, and manage your database like a pro. 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*Xcsh57yMaHW78dvxHlx5Ng.png" /><figcaption>Containers running can bee seen on Docker Desktop</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWAkZzm_gzUjvFK4oX3EtA.png" /><figcaption>Containers’ logs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjVhxW4A46kiwTiIYfwrbw.png" /><figcaption>pgAdmin can be accessed in <a href="http://localhost:15432/login?next=/">http://localhost:15432/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovcQzTt6K3Ka41cCNtKeMw.png" /><figcaption>Inside pgAdmin</figcaption></figure><h3>The Deployment Secret Sauce: Dockerfile</h3><p>When it’s time to deploy your application, Docker’s got you covered again. Here’s a minimalist Dockerfile for your <strong>procurement system app</strong>:</p><pre>FROM alpine:latest<br>COPY bin .<br>RUN chmod +x ./kg-procurement<br>EXPOSE 8080<br>CMD [&quot;./kg-procurement&quot;]</pre><h3>Breaking It Down</h3><ol><li><strong>Base Image</strong></li></ol><ul><li>We’re starting with a lightweight <strong>Alpine Linux</strong> base image. It’s small but mighty, perfect for production.</li></ul><p><strong>2. Copy Your App</strong></p><ul><li>The COPY command brings your app’s binary (kg-procurement) into the container.</li></ul><p><strong>3. Make It Executable</strong></p><ul><li>A simple chmod +x ensures your binary is ready to run.</li></ul><p><strong>4. Expose the Port</strong></p><ul><li>Port <strong>8080</strong> is exposed for your app to accept incoming requests.</li></ul><p><strong>5. Define the Start Command</strong></p><ul><li>Finally, the CMD specifies how to start your app (./kg-procurement).</li></ul><p>When you build this image (docker build -t kg-procurement .) and run it (docker run -p 8080:8080 kg-procurement), your app will be live and ready to rock! 🎸</p><h3>Why Docker Makes Life Better</h3><ol><li><strong>Consistency Across Environments</strong><br>Say goodbye to “works on my machine” problems. Containers ensure your app behaves the same everywhere. 🙌</li><li><strong>Ease of Collaboration</strong><br>Team members can spin up the exact same environment with a single command. No more “but did you install dependency X?” conversations.</li><li><strong>Simplified Deployments</strong><br>Your app, packaged and ready to ship, works seamlessly on any Docker-supported platform. 🚢</li></ol><h3>Ready to Dive Into Docker?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*GT9wHvu0R3iTEAQT.jpg" /></figure><p>Docker isn’t just a tool; it’s a lifestyle upgrade for developers. Whether you’re managing databases, deploying apps, or just trying to keep your local environment sane, Docker has your back. 🐳💙</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bffdfe189e58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Development MVP? Teamwork]]></title>
            <link>https://edutjie.medium.com/software-development-mvp-teamwork-933324461271?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/933324461271</guid>
            <category><![CDATA[linear]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[teamwork]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 08:20:27 GMT</pubDate>
            <atom:updated>2024-11-25T08:46:43.510Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCK5gV5e4hS8bXQfcOUfPQ.png" /></figure><p>Software development can sometimes feel like an extreme sport ⚽. If you’re working solo, you’re juggling all the roles — designer, coder, tester, and the occasional overthinker. On the flip side, working in a team comes with its own chaos: coordinating tasks, aligning with everyone, and making sure your brilliant idea doesn’t accidentally crash into someone else’s 💥.</p><p>My team’s mission? Build a procurement system website for <strong>Kompas Gramedia</strong>, one of Indonesia’s largest media company. No pressure, right?</p><p>The project scope is <em>huge,</em> so managing it has been… let’s say, “exciting.” Not only do I need to sync with the server side maintainers, but I also have to coordinate with another client side maintainers. That means constant communication about feature separation, tech stacks, and API contracts.</p><p>We’ve had to hash out everything from feature separations to tech stacks and API contracts. Sprint planning is great, but let’s be honest — unexpected questions always pop up mid-sprint. It’s like whack-a-mole, but with meetings. 🤹‍♂️🛠️</p><h3>Linear: Our Project Management Tool</h3><p>Let’s be real: tracking tasks and project progress is a nightmare if you’re stuck with outdated tools like Excel. 😩 That’s why my team uses <strong>Linear</strong>, a modern project management tool that keeps our chaos organized.</p><h4>What is Linear?</h4><p>Linear is a project management tool designed to streamline your workflow, track progress, and keep everyone on the same page. It’s clean, intuitive, and just feels <em>right</em>. Think of it as your command center for conquering sprints and taming backlogs. 🚀</p><h4>Projects Page</h4><p>Each sprint gets its own dedicated space in Linear. Inside, you’ll find all the issues and backlogs neatly arranged. It’s like having a personal digital whiteboard that never gets messy. 🖊️📋</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtcQEGOJhXFvaSMo4YKZBg.png" /><figcaption>Projects Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-tjCK1M7rQ95PM9HypIcg.png" /><figcaption>Inside each projects</figcaption></figure><h4>Progress</h4><p>Linear’s progress charts are motivational gold. They show how much of the sprint has been completed, giving you and your team a clear sense of achievement (or a wake-up call). 📈✅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*VrBiHW8hJHT_p9BcpVVevg.png" /><figcaption>Progress Chart on the right side of the Project page</figcaption></figure><h4>Issues</h4><p>Linear categorizes issues to make task tracking effortless:</p><ul><li><strong>All Issues:</strong> A complete overview of every task — active, completed, or abandoned.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWsk6Z--oHtpg-8AliokHQ.png" /></figure><ul><li><strong>Active:</strong> Focuses on tasks in <strong>To Do</strong>, <strong>In Progress</strong>, or <strong>In Review.</strong> Perfect for staying in the loop.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U6iObM8JvTYKzT24I_BRlg.png" /></figure><ul><li><strong>Backlog:</strong> The holding pen for tasks waiting their turn.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YIiVbFbPGvY1CxpaAvL5Xg.png" /></figure><h3>GitHub: More Than Just Code Storage</h3><p>GitHub is more than a code repository — it’s also a fantastic tool for collaboration and documentation.</p><h4>Discussions for Collaboration</h4><p>GitHub Discussions allow team members to brainstorm ideas, troubleshoot problems, and resolve questions asynchronously. It’s a lifesaver when everyone’s not in the same timezone or working hours. 🌐⏰</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*sa6M3HBIyBEwQi03ABbKSQ.png" /><figcaption>PR Discussion</figcaption></figure><h4>Commit Messages with TDD Workflow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*pjuZuqY6UyJXj9RrNs7B2Q.png" /><figcaption>Commit messages in a PR</figcaption></figure><p>We follow the <strong>TDD RED, GREEN, REFACTOR</strong> workflow:</p><ul><li><strong>RED:</strong> Write a test that fails.</li><li><strong>GREEN:</strong> Write code to make the test pass.</li><li><strong>REFACTOR:</strong> Clean up the code while ensuring everything still works.</li></ul><p>Pair this with meaningful commit messages <strong>(no more “fix stuff”)</strong>, and your version history becomes a treasure trove of context instead of a confusing mess. 👨‍💻✨</p><p>To dive deeper about TDD, please visit my other <a href="https://medium.com/@edutjitrahardja/test-driven-development-tdd-in-go-a-practical-guide-c917ccc3fa92">blog</a>. 😉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7m5pIRR5y0OUe9JR.jpeg" /></figure><h3>LINE: The Double-Edged Sword of Communication</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/0*OGPpV8zzLUpa5ooe.jpg" /></figure><p>We also use <strong>LINE</strong> for asynchronous communication. It’s quick, accessible, and great for group discussions or updates. But like any tool, it has its downsides. Let’s talk about both the good and the not-so-good.</p><h3>The Upsides of LINE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*SrdK7815Z0i-oUUnHH6wHA.png" /></figure><ul><li><strong>Simplicity:</strong> LINE is straightforward and easy to use, even for non-tech-savvy team members.</li><li><strong>Convenience:</strong> It’s perfect for quick updates or informal chats — like when you need to share a funny stickers to lighten the mood. 🐸💬</li><li><strong>Instant Notifications:</strong> No more missing out on important discussions; LINE keeps you updated in real-time.</li></ul><h3>The Downsides of LINE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*_BZMuDUnxjAFDmDLxZLIhQ.png" /><figcaption>Glimpse of spamming GitHub links</figcaption></figure><p>While LINE is handy, it’s not without its flaws when used as the primary communication tool for software development teams:</p><ol><li><strong>Lack of Organized Channels or Threads</strong><br>Unlike Slack or Microsoft Teams, LINE doesn’t allow for organized discussion channels or threaded conversations. Everything gets dumped into one chat, and finding specific information later can feel like searching for a needle in a haystack. 🧵🔍</li><li><strong>Limited Integrations with Project Management Tools</strong><br>LINE doesn’t play nice with tools like Linear or GitHub. This means you can’t automate updates or link conversations directly to tasks, which adds extra manual effort. 🔗💼</li><li><strong>Difficulty Managing and Searching for Information</strong><br>Important messages quickly get buried in the flood of conversations. The search function is clunky and inefficient, making it hard to retrieve past discussions or decisions. 🕵️‍♀️📂</li><li><strong>No Rich Developer Features</strong><br>LINE lacks developer-friendly features like code snippets, inline commenting, or Markdown formatting, which can make technical discussions less efficient. 🤦‍♂️👨‍💻</li></ol><p>Despite these drawbacks, LINE works well as a supplementary tool for quick and casual communication. But for serious project-related discussions? You’re better off with something more robust.</p><h3>Synchronous Standup Meetings: The Daily Sync That Saves the Day</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qukFcfxNqMZKwUS1IDnIKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l8r6UYO94fA8DKPxTTC_-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OVcjbZl4UK9eeBNYjituAw.png" /></figure><p>No matter how many tools and asynchronous discussions you have in place, sometimes nothing beats a good old-fashioned face-to-face (or screen-to-screen) standup meeting. Here’s why we incorporate daily standups into our workflow:</p><h4>The Purpose of Standups</h4><p>Standup meetings are short, focused sessions where team members share:</p><ol><li>What they worked on yesterday.</li><li>What they plan to tackle today.</li><li>Any blockers or challenges they’re facing.</li></ol><p>This structure keeps everyone aligned, surfaces issues early, and ensures no one is stuck spinning their wheels in isolation. It’s like a team checkpoint before diving into the day. 🚦</p><h4>Benefits of Synchronous Standups</h4><ul><li><strong>Clarity and Alignment:</strong> Everyone leaves the meeting knowing exactly what the team’s priorities are. No mixed signals, no guessing games. 🎯</li><li><strong>Fostering Team Spirit:</strong> Hearing from teammates daily fosters a sense of connection, especially in remote or hybrid setups. 👥💬</li><li><strong>Immediate Problem-Solving:</strong> Blockers can be quickly addressed, whether it’s through assigning help or reshuffling priorities. 🛠️✨</li></ul><h4>Tips for Effective Standups</h4><ol><li><strong>Keep It Short:</strong> Aim for 15 minutes or less. Standups are meant to be efficient, not drag into hour-long marathons. ⏱️</li><li><strong>Follow the Agenda:</strong> Stick to the “yesterday, today, blockers” format to keep the discussion focused.</li><li><strong>Take Notes (Optional):</strong> A quick summary of key points can help those who couldn’t attend stay in the loop. 📋</li></ol><p>Standups are a staple of agile workflows for a reason — they keep the gears of communication turning smoothly and ensure everyone’s efforts are steering the project in the right direction. 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/0*3NSVqm6rExK29cvq" /></figure><p>Tools like Linear, GitHub, and even LINE are fantastic, but they’re only as good as the people using them. It’s the teamwork, adaptability, and shared commitment to success that truly make a project shine. ✨💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=933324461271" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Level Up Your Software Quality Game with SonarCloud ]]></title>
            <link>https://edutjie.medium.com/level-up-your-software-quality-game-with-sonarcloud-d420066dcabc?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/d420066dcabc</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Mon, 18 Nov 2024 13:54:52 GMT</pubDate>
            <atom:updated>2024-11-18T13:55:35.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*W6nw9XI2F9OpaEZSnZadlw.jpeg" /></figure><p>Creating software that’s top-notch and reliable is like trying to make the perfect cup of coffee — it takes the right ingredients, method, and a dash of magic. But here’s the deal: great software doesn’t just happen. It needs a whole process dedicated to quality, commonly known as <strong>Software Quality Assurance (SQA)</strong>.</p><p>In this article, we’ll dive into the world of SQA and explore how you can supercharge it with <strong>SonarCloud</strong>. By the end, you’ll not only understand what SQA is but also see how SonarCloud (and its buddy SonarLint) can transform your code into a masterpiece. Ready? Let’s go!</p><h3>What Is Software Quality Assurance (SQA)? 🤔</h3><p>SQA is a systematic approach to ensuring that your software meets or exceeds the quality standards you’ve set. Think of it as a proactive shield against bugs, ensuring your software is polished before hitting production.</p><p>It involves a mix of manual and automated activities to identify issues early. Here’s the breakdown:</p><h3>1. Manual Testing 🕵️</h3><p>This involves hands-on testing of specific app aspects. For instance:</p><ul><li>Testing functionality on different operating systems.</li><li>Verifying browser compatibility.</li><li>Ensuring responsiveness across devices.</li></ul><h3>2. Automated Testing 🤖</h3><p>This is where the magic happens — letting tools handle the repetitive stuff! Automated tests can perform tasks like:</p><ul><li>Regression testing.</li><li>Static code analysis using tools like <strong>SonarCloud</strong> integrated into your CI/CD pipeline.</li></ul><p>Both testing methods are like PB&amp;J — they work better together to produce high-quality software.</p><h3>Why Bother with Software Quality Assurance? 🏆</h3><p>Investing in SQA has a ton of benefits:</p><ol><li><strong>Bug-Free Zone</strong>: Catching and fixing bugs early is easier (and cheaper!) than doing damage control post-launch.</li><li><strong>Reliable Software</strong>: Users trust your software when it’s stable and dependable.</li><li><strong>Hassle-Free Maintenance</strong>: Clean code is easier to work with, update, and scale.</li><li><strong>Happy Users</strong>: Satisfied users = glowing reviews = great reputation!</li></ol><h3>Key Components of SQA 🔑</h3><p>To understand SQA, you need to know its building blocks:</p><ol><li><strong>Quality Planning</strong>: Define quality standards, processes, and metrics.</li><li><strong>Quality Control</strong>: Perform testing and code reviews to enforce those standards.</li><li><strong>Quality Assurance</strong>: Focus on improving processes to achieve better outcomes.</li><li><strong>Quality Management</strong>: Oversee risk, resources, and leadership to maintain quality.</li><li><strong>Metrics and Measurement</strong>: Track progress with numbers (e.g., code coverage, issue counts).</li><li><strong>Preventive &amp; Corrective Actions</strong>: Fix issues and prevent them from happening again.</li><li><strong>Continuous Improvement</strong>: Always strive for better processes and results.</li></ol><h3>Enter SonarCloud: Your Quality Wingman 🦸‍♂️</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6eZslfiEtxotmNSfVaguA.png" /></figure><p>Now, let’s talk about SonarCloud — a <strong>cloud-based static analysis tool</strong> that’s like having a virtual QA wizard in your toolkit. It scans your code, highlights issues, and helps you clean up your act before things get messy.</p><h3>Why SonarCloud Rocks:</h3><ol><li><strong>Static Code Analysis</strong>: Analyze your code for potential issues without even running it.</li><li><strong>Bug &amp; Vulnerability Detection</strong>: Catch bugs and security vulnerabilities early.</li><li><strong>Cleaner Code</strong>: Get real-time feedback to write cleaner, maintainable code.</li><li><strong>CI/CD Integration</strong>: Automate code checks in your pipeline, so nothing slips through the cracks.</li><li><strong>Multi-Language Support</strong>: Works with a variety of programming languages for multi-tech projects.</li><li><strong>Actionable Dashboards</strong>: See your project’s health at a glance and get detailed reports.</li><li><strong>Standards Compliance</strong>: Keep your code aligned with industry standards and best practices.</li></ol><h3>Dive into SonarCloud Features: A Guided Tour 🧭</h3><p>SonarCloud is packed with features that make monitoring, analyzing, and improving code quality a breeze. If you’re ready to unleash its potential, here’s a quick walkthrough of its main dashboard and tools. Let’s jump right in!</p><h4>1. Main Branch Summary: Your Code’s Health at a Glance 🌟</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4NTKIz2teh858aosiRDaJg.png" /></figure><p>The <strong>Main Branch Summary</strong> gives you a bird’s-eye view of your main branch’s code quality.</p><p><strong>Key Highlights:</strong></p><ul><li><strong>Security</strong>: Are there vulnerabilities lurking in your code?</li><li><strong>Reliability</strong>: How stable is your code?</li><li><strong>Maintainability</strong>: Will future developers thank you or curse you?</li><li><strong>Issue Count</strong>: See the number of issues categorized by severity (high, medium, or low).</li></ul><p>This overview helps you prioritize which fires to put out first.</p><h4>2. Issues: Where the Rubber Meets the Road 🔍</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqzSLyhlSOH3-_HYE8XaKg.png" /></figure><p>The <strong>Issues</strong> tab dives deeper into the specific problems in your code.</p><p><strong>Cool Features:</strong></p><ul><li><strong>Filters</strong>: Narrow down issues by type, severity, or location.</li><li><strong>Detailed Guidance</strong>: Get explanations for each issue, including how to fix it.</li></ul><p>Example: Found an issue in your DockerFile? SonarCloud not only points it out but also suggests solutions, saving you from adding to the dreaded <strong>technical debt</strong>.</p><h4>3. Security Hotspots: A Heads-Up for Risky Code 🔥</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cu6pyRn34H_R02tpL8oiLQ.png" /></figure><p>Unlike regular issues, <strong>Security Hotspots</strong> aren’t guaranteed problems but areas that need extra scrutiny.</p><p><strong>Why It’s Awesome:</strong></p><ul><li>Highlights parts of the code that <strong>might</strong> have security risks.</li><li>Encourages developers to double-check critical code sections.</li></ul><p>Think of it as your code’s personal bodyguard.</p><h4>4. Measures: Quantify Your Code’s Quality 📊</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTz0UeEWsS1MgpiWJlZm7Q.png" /></figure><p>The <strong>Measures</strong> page provides metrics for various aspects of your code.</p><p><strong>Metrics You’ll Love:</strong></p><ul><li><strong>Coverage</strong>: How well are your tests covering your code?</li><li><strong>Duplication</strong>: Are you guilty of copy-pasting? (We won’t tell.)</li><li><strong>Complexity</strong>: Is your code easy to follow or a labyrinth of logic?</li></ul><p>Data here helps you make informed decisions for improvement.</p><h4>5. Other Features: More Tools to Explore 🛠️</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1oJfhw4hWJuIjDkxRl9Jiw.png" /></figure><p>SonarCloud isn’t just about identifying issues — it also helps you stay organized:</p><ul><li><strong>Code</strong>: Inspect problems directly in specific folders.</li><li><strong>Pull Requests</strong>: Analyze quality on individual PRs.</li><li><strong>Branches</strong>: Compare metrics across different branches.</li></ul><p>These features ensure you never lose track of quality, no matter where the changes are happening.</p><h3>Elevate Your CI Game with SonarCloud and GitHub Actions 🚀</h3><p>Static code analysis is a must-have for maintaining high-quality code, and when paired with CI-based workflows, the magic happens. In this guide, we’ll walk you through setting up <strong>SonarCloud analysis</strong> with <strong>GitHub Actions</strong> to bring code coverage into the mix — a feature that automatic analysis just can’t provide yet. Let’s dive in!</p><h4>Step 1: Turn Off Automatic Analysis</h4><p>To fully embrace CI-based analysis, you need to disable <strong>automatic analysis</strong> for your SonarCloud project. This ensures you’re fully in control of what gets analyzed and when.</p><h4>Step 2: Configure Your GitHub Repository and Actions Workflow</h4><p>With automatic analysis out of the picture, it’s time to set up a custom workflow using <strong>GitHub Actions</strong>. Here’s how you do it:</p><p><strong>a) Add GitHub Secrets<br></strong>Ensure you’ve set up the required secrets in your repository, especially the <strong>SONAR_TOKEN</strong>, which is crucial for authenticating with SonarCloud.</p><p><strong>b) Define Your Workflow<br></strong>Create or update your .github/workflows/ci-workflow.yml file to include the following workflow configuration:</p><pre># .github/workflows/ci-workflow.yml<br><br>name: CI Workflow<br>on:<br>  push:<br>    branches:<br>      - main<br>  pull_request:<br>    types: [opened, synchronize, reopened]<br>jobs:<br>  build:<br>    uses: ./.github/workflows/build.yml<br>    secrets: inherit<br>  test:<br>      needs: build<br>      uses: ./.github/workflows/unit-tests.yml<br>      secrets: inherit<br>  sonarcloud:<br>      needs: test<br>      uses: ./.github/workflows/sonarcloud.yml<br>      secrets: inherit</pre><pre># .github/workflows/sonarcloud.yml<br><br>name: SonarCloud Analysis<br><br>on:<br>  workflow_call:<br><br>jobs:<br>  sonarcloud:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout Repository<br>        uses: actions/checkout@v4<br>        with:<br>          fetch-depth: 0<br>  <br>      - name: Set up Go<br>        uses: actions/setup-go@v4<br>        with:<br>          go-version: &#39;1.23.1&#39;<br><br>      - name: Install Dependencies<br>        run: go mod download<br><br>      - name: Run Tests with Coverage<br>        run: |<br>          go test -v -race -coverprofile=coverage.out -covermode=atomic ./...<br><br>      - name: Display Coverage Summary<br>        run: go tool cover -func=coverage.out<br><br>      - name: SonarCloud Scan<br>        uses: SonarSource/sonarcloud-github-action@v3.0.0<br>        with:<br>          args: &gt;<br>            -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}<br>            -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}<br>            -Dsonar.go.coverage.reportPaths=coverage.out<br>            -Dsonar.sources=.<br>            -Dsonar.tests=.<br>            -Dsonar.test.inclusions=**/*_test.go<br>            -Dsonar.exclusions=**/migrations/**,**/fixtures/**,**/scripts/**,**/vendor/**,**/*_mock.go,internal/common/database/**<br>            -Dsonar.coverage.exclusions=**/router/**,**/vendor/**,**/*_mock.go,**/*_test.go,**/cmd/**/*.*<br>            -Dsonar.cpd.exclusions=**/accessor.go,**/*.sql<br>            -Dsonar.language=go<br>            -Dsonar.sourceEncoding=UTF-8<br>        env:<br>          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}<br>          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}</pre><p><strong>How It Works:</strong></p><ol><li><strong>Build Job</strong>: Ensures your code can be built and dependencies are installed.</li><li><strong>Test Job: </strong>Run unit tests to make sure code written run successfully.</li><li><strong>SonarCloud Job</strong>: Runs <strong>static code analysis</strong> and captures <strong>code coverage</strong>.</li></ol><h4>Step 3: Push Your Changes and Trigger the Workflow</h4><p>Once your workflow is defined, commit and push your changes to the repository. GitHub Actions will kick off the workflow automatically.</p><h4><strong>Workflow in Action</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iimALdGiZEUpWXvcCno_xw.png" /></figure><p>Here’s what you’ll see:</p><ul><li><strong>GitHub Actions Workflow</strong>: A visual breakdown of each job’s status (build, sonarcloud, and deployment).</li><li><strong>Updated SonarCloud Summary</strong>:</li><li><strong>Code Quality Insights</strong>: See new metrics like code coverage and resolved issues.</li><li><strong>Coverage Stats</strong>: Check if your code has improved (or not).</li></ul><h4>Example Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4NTKIz2teh858aosiRDaJg.png" /></figure><p>In our test project, the code coverage is 100%. The idea is to iterate on these results, fix issues, and improve the metrics over time.</p><h4>Why CI-Based Analysis?</h4><ol><li><strong>Code Coverage Visibility</strong>: Unlike automatic analysis, CI-based workflows integrate test coverage metrics into SonarCloud.</li><li><strong>Granular Control</strong>: Customize when and how analysis runs.</li><li><strong>Quality Gatekeeper</strong>: Ensure only high-quality, reviewed code makes it to production.</li></ol><h3>Wrapping Up 🎉</h3><p>Quality isn’t just a checkbox — it’s a commitment to excellence. By combining solid SQA practices with powerful tools like SonarCloud and SonarLint, you can ensure your software is not just functional but exceptional.</p><p>So, what are you waiting for? Dive in, analyze your code, and let SonarCloud help you build software you can be proud of!</p><h3>References</h3><ol><li><a href="https://docs.sonarsource.com/sonarcloud/">https://docs.sonarsource.com/sonarcloud/</a></li><li><a href="https://medium.com/bonapasogitmengajar/a-guide-for-beginner-about-software-quality-assurance-a85e43066ad1">https://medium.com/bonapasogitmengajar/a-guide-for-beginner-about-software-quality-assurance-a85e43066ad1</a></li><li><a href="https://www.softwaretestinghelp.com/software-quality-assurance/">https://www.softwaretestinghelp.com/software-quality-assurance/</a></li><li><a href="https://docs.sonarsource.com/sonarlint/vs-code/">https://docs.sonarsource.com/sonarlint/vs-code/</a></li><li><a href="https://www.sonarsource.com/products/sonarcloud/">https://www.sonarsource.com/products/sonarcloud/</a></li><li><a href="https://medium.com/@makersinstitute/mengenal-lebih-jauh-tentang-software-quality-assurance-844361cd50db">https://medium.com/@makersinstitute/mengenal-lebih-jauh-tentang-software-quality-assurance-844361cd50db</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d420066dcabc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Like a Pro: A Guide to Version Control!]]></title>
            <link>https://edutjie.medium.com/git-like-a-pro-a-guide-to-version-control-5224dcc35fc1?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/5224dcc35fc1</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 14:59:06 GMT</pubDate>
            <atom:updated>2024-10-24T14:57:28.843Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*TmEC8ghit5UHw8Y0Y2KcFA.jpeg" /></figure><p>Have you ever messed up your project and thought, <em>“If only there was a way to undo this disaster?”</em> Enter <strong>Git</strong> — your code’s superhero, here to save the day with version control powers! 🚀</p><p>Git is like a time machine for your code, and in today’s adventure, we’re going to have a blast learning the ropes so you can get good.</p><h3>So, What Exactly Is Git? 🤔</h3><p>Imagine you’re working on a project, and suddenly things go <em>very</em> wrong. Maybe you deleted some critical files or merged the wrong branch. 😱 Normally, you’d panic. But with Git, you can travel back in time, fix your mistakes, and look like a genius.</p><p>Git is a <strong>version control system</strong>, meaning it tracks changes in your code so you can:</p><ul><li><strong>Rewind</strong> when you make mistakes.</li><li><strong>Collaborate</strong> with others without stepping on each other’s toes.</li><li><strong>Branch out</strong> into different ideas without breaking things.</li></ul><p>And the best part? It’s easy to use once you get the hang of it!</p><h3>Setting the Stage: git init 🎬</h3><p>Every journey begins with a single command: <strong>git init</strong>. This creates a Git repository—a fancy term for saying, &quot;Hey, Git, start tracking changes here!&quot;</p><pre>git init</pre><p>Boom! Now Git is watching every move you make like a sneaky spy (but in a good way).</p><h3>Making Your First Commit: Snapshots of Awesomeness 📸</h3><p>Commits are like saving checkpoints in a video game. Made some progress? Save it. Need to experiment? Save first, and then go wild. Every commit tells Git, <em>“Hey, remember this version of the code!”</em></p><p>Step 1: <strong>Add</strong> your files to the stage.</p><pre>git add .</pre><p>Step 2: <strong>Commit</strong> those changes with a message.</p><pre>git commit -m &quot;[RED] created unit test for filter vendor by product name service&quot;</pre><p>Now Git’s got a snapshot of your code at this exact moment in time. If you screw up later, just travel back to this commit!</p><h3>Branching Out: The Power of Git Branches 🌲</h3><p>You’re working on an app, and you want to add a new feature. But hold up! What if things go wrong? That’s where <strong>branches</strong> come in. It’s like creating a parallel universe where you can break things without affecting the main timeline.</p><p>To create a branch:</p><pre>git branch PBI-32-41-FilterVendorProductByName</pre><p>To switch to it:</p><pre>git checkout PBI-32-41-FilterVendorProductByName</pre><p>Or if you want to create new branch and switch to it immediately:</p><pre>git checkout -b PBI-32-41-FilterVendorProductByName</pre><p>Now you’re free to hack away, while the main branch (master or main) stays pristine. If your feature works out, you can <strong>merge</strong> it back. If not, you can delete the branch like it never happened. 🧹</p><h3>Collaboration Station: Git and GitHub 🚂</h3><p>Working with a team? You’ll need <strong>GitHub</strong> (or GitLab, Bitbucket, or any other remote repository). GitHub is like the cloud backup for your Git repo. You push your local changes to GitHub, and your team can pull them down to their machines. Teamwork makes the dream work! 💪</p><p>To link your project to GitHub:</p><ol><li>Create a repo on GitHub.</li><li>Add the remote link to your local Git repo.</li></ol><pre>git remote add origin https://github.com/kg-procurement/kg-procurement.git</pre><ol><li>Push your code to the cloud!</li></ol><pre>git push -u origin main</pre><p>Now your code is out there for the world (or just your team) to see!</p><h3>The Epic Merge Battle: git pull with merge🥊</h3><p>Pulling using merging is like combining two timelines into one. Say you’ve been working on a feature in a branch, and it’s time to merge it back to the main branch. Git will try to combine everything seamlessly.</p><pre>git checkout PBI-32-41-FilterVendorProductByName<br>git pull origin main</pre><p>Sometimes Git gets confused and screams, “Conflict!” This happens when you and someone else edited the same part of a file. Don’t freak out. You just need to manually fix the code and tell Git everything’s cool.</p><pre># After fixing conflicts<br>git add .<br>git commit -m &quot;Resolved merge conflicts&quot;</pre><p>Crisis averted. You’re a hero once again. 🦸‍♂️</p><p>Example: I want to update my current branch with main</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*J04zUzElQ7VMhQ2vVhZlJQ.png" /></figure><p>Ups! There are some conflicts. We should resolve all the conflicts in order to finish the merge. 💪</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rDmwCTkyUx4sM7lCOEtNSQ.png" /></figure><p>You can choose either Accept Incoming, Accept Combination (Incoming First/Current First), ignore. After solving the file, you can press Complete Merge button to finish solving that file. Finally, after you have solved all the conflicts, you can push it! 👏 Your commits will look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlbhhZLdS3MESemQZu3WkQ.png" /></figure><h3>Pulling with Power: git pull --rebase ⚡</h3><p>Okay, let’s talk about <strong>git pull --rebase</strong>, the secret sauce for keeping your commits clean and in order. When you&#39;re working with others, you&#39;ll likely need to pull changes from the remote repository before pushing your own. Normally, you&#39;d just use:</p><pre>git pull &lt;branch_name&gt;</pre><p>Like in the previous section, but what happens? Your commits get all tangled with merge commits, and your commit history starts to look like a bowl of spaghetti. 🍝</p><p>Enter <strong>git pull --rebase</strong>, which says, “Hey, let’s avoid unnecessary merge commits.” It takes your local changes, temporarily stashes them, updates your branch with the latest code from the remote, and then replays your changes on top. It&#39;s like putting your work on pause, updating the game, and resuming from exactly where you left off!</p><pre>git pull --rebase origin main</pre><p>Now your history looks neat and linear, like a well-organized to-do list. No more messy merge commits clogging up the works. It’s what I use while developing my projects in a team.🎉</p><p>Pro tip: You can make <strong>git pull --rebase</strong> your default behavior by setting this in your config:</p><pre>git config --global pull.rebase true</pre><p>Now you’re pulling like a pro and keeping your repo tidy!</p><p>Example: Let’s use the same example as the regular git pull, but use — rebase instead this time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*7CCvu4-Uj3aMTfJ1udVE-w.png" /></figure><p>It shows similar response with the regular git pull, with many conflict logs. However, in rebase, git will go through all of your commits that are in front of the main branch one by one to check if there is any conflict. You should solve it in similar way as in merge ! 💪</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dg3duRqAm_gT99QrHdW1RQ.png" /></figure><p>After you are done solving this current commit, you can git add the changed file and run git rebase --continue to move on to the next commit and git will ask you to recommit the changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*ADa3_XjpIDfrp752fVDdnA.png" /></figure><p>Do it until all the commits has been gone through and resolved! How ever, because you changed the remote commits, you have to force the push (git push -f) in order to replace the remote commits with the rebased one. And you commit will look cleaner like nothing has happened.</p><h3>Undo Like a Pro: git reset &amp; git revert 🔄</h3><p>Oops! Did something wrong? Don’t worry, Git’s got your back. With <strong>git reset</strong>, you can un-commit changes like they never happened.</p><pre>git reset --hard &lt;commit-hash&gt;</pre><p>Boom — back to a previous commit like magic. But be careful, reset rewrites history, so use it wisely! For a more <em>gentle</em> approach, try <strong>git revert</strong>. It creates a new commit that undoes the changes from a previous one, without deleting history.</p><pre>git revert &lt;commit-hash&gt;</pre><p>No one needs to know you messed up (except maybe your cat).</p><h3>Git Stash: Hide Your Work 🕵️‍♂️</h3><p>Imagine you’re halfway through building a feature and suddenly need to switch branches, but you don’t want to commit yet. Enter <strong>git stash</strong>, where you can temporarily hide your work.</p><pre>git stash</pre><p>When you’re ready to come back to it:</p><pre>git stash pop</pre><p>Your unfinished code reappears, and you’re back in business. 🧙‍♂️</p><h3>Wrapping Up: Git Is Your Superpower 🦸‍♀️</h3><p>So there you have it! Git is like a trusty sidekick — always there to catch you when you fall and help you collaborate like a pro. With commands like commit, branch, merge, rebase, and stash in your toolkit, you can handle any version control shenanigans that come your way.</p><blockquote>Happy coding! 😀</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5224dcc35fc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering SOLID Principles in Go: A Dive into Clean Code!]]></title>
            <link>https://edutjie.medium.com/mastering-solid-principles-in-go-a-dive-into-clean-code-694dfa0970fc?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/694dfa0970fc</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 14:43:04 GMT</pubDate>
            <atom:updated>2024-10-13T14:43:04.608Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bB-Om6LuA08llDr5Ou0SJQ.png" /></figure><h3>What’s SOLID Anyway?</h3><p>Before we dive into how these principles work in Go, let’s get to know them. <strong>SOLID</strong> is an acronym, standing for:</p><p>1. <strong>S</strong>ingle Responsibility Principle (SRP)<br>2. <strong>O</strong>pen/Closed Principle (OCP)<br>3. <strong>L</strong>iskov Substitution Principle (LSP)<br>4. <strong>I</strong>nterface Segregation Principle (ISP)<br>5. <strong>D</strong>ependency Inversion Principle (DIP)</p><p>Sounds intimidating, right? Fear not! We’re going to see how Golang, with its love for simplicity, can rock these principles.</p><h4>1. Single Responsibility Principle (SRP) 🎯</h4><blockquote>Every module or class should have only one reason to change.</blockquote><p><strong>Don’t make your functions multitask!</strong> It’s like giving your microwave the job of making coffee 😂 — it’s just going to blow up (don’t try this at home). Every part of your code should focus on doing one thing and doing it well.</p><p><strong>Go Example:<br></strong>Let’s say you’ve got a Vendor struct and you need to handle both database interactions and vendor-related operations like getting a vendor by ID. 🤔 Instead of dumping all responsibilities into one struct, break it down!</p><pre>// vendor.go<br>type Vendor struct {<br> ID            string    `db:&quot;id&quot; json:&quot;id&quot;`<br> Name          string    `db:&quot;name&quot; json:&quot;name&quot;`<br> Description   string    `db:&quot;description&quot; json:&quot;description&quot;`<br> BpID          string    `db:&quot;bp_id&quot; json:&quot;bp_id&quot;`<br> BpName        string    `db:&quot;bp_name&quot; json:&quot;bp_name&quot;`<br> Rating        int       `db:&quot;rating&quot; json:&quot;rating&quot;`<br> AreaGroupID   string    `db:&quot;area_group_id&quot; json:&quot;area_group_id&quot;`<br> AreaGroupName string    `db:&quot;area_group_name&quot; json:&quot;area_group_name&quot;`<br> SapCode       string    `db:&quot;sap_code&quot; json:&quot;sap_code&quot;`<br> ModifiedDate  time.Time `db:&quot;modified_date&quot; json:&quot;modified_date&quot;`<br> ModifiedBy    string    `db:&quot;modified_by&quot; json:&quot;modified_by&quot;`<br> Date          time.Time `db:&quot;dt&quot; json:&quot;dt&quot;`<br>}<br><br>// service.go<br>type VendorService struct {<br>    vendorDBAccessor // -&gt; referering to accessor.go<br>}<br><br>func (v *VendorService) GetById(ctx context.Context, id string) (*Vendor, error) {<br>    return v.vendorDBAccessor.GetById(ctx, id)<br>}</pre><p>Now, if something breaks, you know exactly where to look. Plus, refactoring is a breeze! The VendorService class adheres to SRP by focusing solely on vendor-related operations. It delegates database operations to the vendorDBAccessor interface.</p><h4>2. Open/Closed Principle (OCP) 🚪</h4><blockquote>Software entities should be open for extension, but closed for modification.</blockquote><p><strong>You shouldn’t have to rewrite old code just to add new features.</strong> It’s like building a house where you can add rooms without tearing down walls. Sounds dreamy, right?</p><p>In Go, you can apply this by focusing on extensibility — using <strong>interfaces</strong>!</p><pre>type vendorDBAccessor interface {<br>    GetById(ctx context.Context, id string) (*Vendor, error)<br>    // other methods...<br>}<br><br>func NewVendorService(conn database.DBConnector, clock clock.Clock) *VendorService {<br>    return &amp;VendorService{<br>        vendorDBAccessor: newPostgresVendorAccessor(conn, clock),<br>    }<br>}</pre><p>Now, the vendorDBAccessor interface allows the VendorService to be extended with different database access implementations without modifying the VendorService itself. Voilà! Your code is future-proof. 💪</p><h4>3. Liskov Substitution Principle (LSP) 🔄</h4><blockquote>Objects of a superclass should be replaceable with objects of a subclass without affecting correctness.</blockquote><p>In other words, <strong>if it walks like a duck and quacks like a duck, it should behave like a duck</strong> — even if it’s a robotic duck. 🤖🦆</p><p>In Go, this principle is pretty straightforward with <strong>interfaces</strong>. If something implements an interface, it better stick to its contract.</p><pre>type MockvendorDBAccessor struct {<br>  // mock methods…<br>}<br><br>func TestVendorService_GetById(t *testing.T) {<br>  ctrl := gomock.NewController(t)<br>  defer ctrl.Finish()<br><br>  mockAccessor := NewMockvendorDBAccessor(ctrl)<br>  service := VendorService{vendorDBAccessor: mockAccessor}<br>  // test cases…<br>}</pre><p>The MockvendorDBAccessor can be used in place of the actual vendorDBAccessor in tests, adhering to LSP.</p><h4>4. Interface Segregation Principle (ISP) 🧩</h4><blockquote>Many client-specific interfaces are better than one general-purpose interface.</blockquote><p>Clients should not be forced to depend on interfaces they do not use. Ever been to a buffet where they serve sushi, pizza, burgers, and ice cream all on one plate? 🤢 That’s what happens when you force clients to implement bloated interfaces they don’t need.</p><p>In Go, keep your interfaces <strong>lean</strong> and <strong>mean</strong>.</p><pre>type vendorDBAccessor interface {<br>    GetById(ctx context.Context, id string) (*Vendor, error)<br>    // other methods...<br>}</pre><p>The vendorDBAccessor interface is specific to vendor-related database operations, ensuring that VendorService only depends on relevant methods. Everybody’s happy — especially your code. 🎉</p><h4>5. Dependency Inversion Principle (DIP) 🔄🔗</h4><blockquote>Depend on abstractions, not on concretions.</blockquote><p>This one sounds fancy, but it basically means that <strong>high-level modules should not depend on low-level modules.</strong> Both should depend on abstractions.</p><p>In Go, you can achieve this with — you guessed it — <strong>interfaces</strong>! (Are you sensing a trend here?)</p><pre>type VendorService struct {<br>    vendorDBAccessor<br>}<br><br>func NewVendorService(conn database.DBConnector, clock clock.Clock) *VendorService {<br>    return &amp;VendorService{<br>        vendorDBAccessor: newPostgresVendorAccessor(conn, clock),<br>    }<br>}</pre><p>The VendorService depends on the vendorDBAccessor interface rather than a concrete implementation, adhering to DIP. Want to switch to new database operation accessor? No sweat. Just implement the interface.</p><h3>Wrapping Up 🎁</h3><p>And there you have it — <strong>SOLID principles</strong> in the magical world of <strong>Golang</strong>! While these principles originated in OOP-heavy languages like Java and C#, Golang proves that they are universal guidelines that make any codebase more readable, maintainable, and fun to work with.</p><p>The next time you’re writing Go code, channel your inner SOLID guru, break up those bloated structs, and keep things simple! Remember, writing clean code is like being a chef: it’s all about using the right ingredients (principles) to cook up a gourmet app.</p><blockquote>Happy coding, and stay SOLID! ✌️</blockquote><h3>Reference</h3><p><a href="https://www.digitalocean.com/community/conceptual-articles/s-o-l-i-d-the-first-five-principles-of-object-oriented-design">SOLID: The First 5 Principles of Object Oriented Design | Digital Ocean</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=694dfa0970fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test-Driven Development (TDD) in Go: A Practical Guide]]></title>
            <link>https://edutjie.medium.com/test-driven-development-tdd-in-go-a-practical-guide-c917ccc3fa92?source=rss-3560f7e86cef------2</link>
            <guid isPermaLink="false">https://medium.com/p/c917ccc3fa92</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[gomega]]></category>
            <category><![CDATA[test-driven-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Eduardus Tjitrahardja]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 11:33:58 GMT</pubDate>
            <atom:updated>2024-09-30T07:18:31.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m-Zupc2xblMcTLtNxUTadQ.png" /></figure><h3>Introduction</h3><p><strong>Test-Driven Development (TDD)</strong> is a software development process where tests are written before the actual code. This approach ensures that the codebase is thoroughly tested and helps in maintaining high code quality. In this blog post, we’ll explore TDD in the context of a <strong>Go project</strong>, using examples from a real-world implementation.</p><h3>What is TDD?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*Kje1dGajMKDWBTNviP6sEg.png" /><figcaption>Source: <a href="https://testdriven.io/test-">What is Test-Driven Development?</a></figcaption></figure><p><strong>TDD</strong> is a development technique where you write a test before you write just enough production code to fulfill that test and then refactor the code to pass the test. The cycle is often summarized as follows:</p><p>1. <strong>Red</strong>: Write a failing test.<br>2. <strong>Green</strong>: Write the minimum amount of code to make the test pass.<br>3. <strong>Refactor</strong>: Improve the code while keeping the tests green.</p><p>This approach helps in building <strong>confidence</strong> in the code and ensures that the code is always <strong>working as expected</strong>.</p><h3>Benefits of TDD</h3><ol><li><strong>Improved Code Quality</strong>: Writing tests first force you to think about the requirements and design before writing the code.</li><li><strong>Bug Prevention</strong>: Defining the expected results upfront helps prevent unexpected bugs from appearing.</li><li><strong>Refactoring with Confidence</strong>: With a comprehensive suite of tests, you can refactor your code without fear of breaking existing functionality.</li><li><strong>Documentation</strong>: Tests act as documentation for the code, clarifying its intended behavior and improving overall team collaboration.</li></ol><h3><strong>TDD in Action: A Go Project Example</strong></h3><p>Let’s dive into a Go project I implemented in a Software Engineering course to see how TDD is implemented. We’ll use a simple example of a VendorService that retrieves vendor information from a database.</p><h4>Step 1: Write a Failing Test (Red)</h4><p>First, we write a test for the GetByLocation method, which retrieves vendors based on a product description. Here I use <a href="https://github.com/onsi/gomega">GoMega</a> as the testing framework, feel free to use another. You can learn about it more in this article post:</p><p><a href="https://diptochakrabarty.medium.com/gomega-matcher-a-guide-to-developing-your-custom-tests-in-golang-42c70f330d88">Gomega Matcher : A guide to developing your custom tests in Golang</a></p><p>Let’s start writing the unit test code!</p><ul><li>The Accessor Unit Test (accessor_test.go)</li></ul><pre>func TestVendorAccessor_GetByLocation(t *testing.T) {<br> t.Parallel()<br><br> var (<br>  accessor *postgresVendorAccessor<br>  mock     sqlmock.Sqlmock<br> )<br><br> setup := func(t *testing.T) (*gomega.GomegaWithT, *sql.DB) {<br>  g := gomega.NewWithT(t)<br>  db, sqlMock, err := sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual))<br>  if err != nil {<br>   log.Fatal(&quot;error initializing mock:&quot;, err)<br>  }<br><br>  accessor = newPostgresVendorAccessor(db)<br>  mock = sqlMock<br><br>  return g, db<br> }<br><br> sampleData := []string{<br>  &quot;id&quot;,<br>  &quot;name&quot;,<br>  &quot;description&quot;,<br>  &quot;bp_id&quot;,<br>  &quot;bp_name&quot;,<br>  &quot;rating&quot;,<br>  &quot;area_group_id&quot;,<br>  &quot;area_group_name&quot;,<br>  &quot;sap_code&quot;,<br>  &quot;modified_date&quot;,<br>  &quot;modified_by&quot;,<br>  &quot;dt&quot;,<br> }<br><br> query := `SELECT <br>   &quot;id&quot;,<br>   &quot;name&quot;,<br>   &quot;description&quot;,<br>   &quot;bp_id&quot;,<br>   &quot;bp_name&quot;,<br>   &quot;rating&quot;,<br>   &quot;area_group_id&quot;,<br>   &quot;area_group_name&quot;,<br>   &quot;sap_code&quot;,<br>   &quot;modified_date&quot;,<br>   &quot;modified_by&quot;,<br>   &quot;dt&quot; <br>   FROM vendor<br>   WHERE area_group_name = $1`<br><br> fixedTime := time.Date(2024, time.September, 27, 12, 30, 0, 0, time.UTC)<br><br> location := &quot;Indonesia&quot;<br><br> t.Run(&quot;success&quot;, func(t *testing.T) {<br>  g, db := setup(t)<br>  defer db.Close()<br><br>  rows := sqlmock.NewRows(sampleData).<br>   AddRow(<br>    &quot;1&quot;,<br>    &quot;name&quot;,<br>    &quot;description&quot;,<br>    &quot;1&quot;,<br>    &quot;bp_name&quot;,<br>    1,<br>    &quot;1&quot;,<br>    location,<br>    &quot;sap_code&quot;,<br>    fixedTime,<br>    1,<br>    fixedTime,<br>   )<br><br>  mock.ExpectQuery(query).<br>   WithArgs(location).<br>   WillReturnRows(rows)<br><br>  ctx := context.Background()<br>  res, err := accessor.GetByLocation(ctx, location)<br><br>  expectation := []Vendor{{<br>   ID:            &quot;1&quot;,<br>   Name:          &quot;name&quot;,<br>   Description:   &quot;description&quot;,<br>   BpID:          &quot;1&quot;,<br>   BpName:        &quot;bp_name&quot;,<br>   Rating:        1,<br>   AreaGroupID:   &quot;1&quot;,<br>   AreaGroupName: location,<br>   SapCode:       &quot;sap_code&quot;,<br>   ModifiedDate:  fixedTime,<br>   ModifiedBy:    1,<br>   Date:          fixedTime,<br>  }}<br><br>  g.Expect(err).To(gomega.BeNil())<br>  g.Expect(res).To(gomega.Equal(expectation))<br> })<br><br> t.Run(&quot;success on empty result&quot;, func(t *testing.T) {<br>  g, db := setup(t)<br>  defer db.Close()<br><br>  rows := sqlmock.NewRows(sampleData)<br><br>  mock.ExpectQuery(query).<br>   WithArgs(location).<br>   WillReturnRows(rows)<br><br>  ctx := context.Background()<br>  res, err := accessor.GetByLocation(ctx, location)<br>  g.Expect(err).To(gomega.BeNil())<br>  g.Expect(res).To(gomega.Equal([]Vendor{}))<br> })<br><br> t.Run(&quot;error on scanning row&quot;, func(t *testing.T) {<br>  g, db := setup(t)<br>  defer db.Close()<br><br>  rows := sqlmock.NewRows(sampleData).AddRow(<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>   nil,<br>  )<br><br>  mock.ExpectQuery(query).<br>   WithArgs(location).<br>   WillReturnRows(rows)<br><br>  ctx := context.Background()<br>  res, err := accessor.GetByLocation(ctx, location)<br><br>  g.Expect(err).ToNot(gomega.BeNil())<br>  g.Expect(res).To(gomega.BeNil())<br> })<br><br> t.Run(&quot;error on executing query&quot;, func(t *testing.T) {<br>  g, db := setup(t)<br>  defer db.Close()<br><br>  mock.ExpectQuery(query).<br>   WithArgs(location).<br>   WillReturnError(errors.New(&quot;some error&quot;))<br><br>  ctx := context.Background()<br>  res, err := accessor.GetByLocation(ctx, location)<br><br>  g.Expect(err).ToNot(gomega.BeNil())<br>  g.Expect(res).To(gomega.BeNil())<br> })<br><br> t.Run(&quot;error while iterating rows&quot;, func(t *testing.T) {<br>  g, db := setup(t)<br>  defer db.Close()<br><br>  rows := sqlmock.NewRows(sampleData).<br>   AddRow(<br>    &quot;1&quot;,<br>    &quot;name&quot;,<br>    &quot;description&quot;,<br>    &quot;1&quot;,<br>    &quot;bp_name&quot;,<br>    1,<br>    &quot;1&quot;,<br>    location,<br>    &quot;sap_code&quot;,<br>    fixedTime,<br>    1,<br>    fixedTime,<br>   ).RowError(0, fmt.Errorf(&quot;row error&quot;))<br><br>  mock.ExpectQuery(query).<br>   WithArgs(location).<br>   WillReturnRows(rows)<br><br>  ctx := context.Background()<br>  res, err := accessor.GetByLocation(ctx, location)<br><br>  g.Expect(err).ToNot(gomega.BeNil())<br>  g.Expect(res).To(gomega.BeNil())<br> })<br>}</pre><ul><li>The Service Unit Test (service_test.go)</li></ul><pre>func TestVendorService_GetByLocation(t *testing.T) {<br> location := &quot;Indonesia&quot;<br> sampleData := []Vendor{<br>  {<br>   ID:            &quot;1&quot;,<br>   Name:          &quot;name&quot;,<br>   Description:   &quot;description&quot;,<br>   BpID:          &quot;1&quot;,<br>   BpName:        &quot;bp_name&quot;,<br>   Rating:        1,<br>   AreaGroupID:   &quot;1&quot;,<br>   AreaGroupName: location,<br>   SapCode:       &quot;sap_code&quot;,<br>   ModifiedDate:  time.Now(),<br>   ModifiedBy:    1,<br>   Date:          time.Now(),<br>  },<br> }<br> ctrl := gomock.NewController(t)<br> defer ctrl.Finish()<br> type fields struct {<br>  mockVendorDBAccessor *MockvendorDBAccessor<br> }<br> type args struct {<br>  ctx context.Context<br> }<br> tests := []struct {<br>  name    string<br>  fields  fields<br>  args    args<br>  want    []Vendor<br>  wantErr bool<br> }{<br>  {<br>   name: &quot;success&quot;,<br>   fields: fields{<br>    mockVendorDBAccessor: NewMockvendorDBAccessor(ctrl),<br>   },<br>   args:    args{ctx: context.Background()},<br>   want:    sampleData,<br>   wantErr: false,<br>  },<br>  {<br>   name: &quot;failure&quot;,<br>   fields: fields{<br>    mockVendorDBAccessor: NewMockvendorDBAccessor(ctrl),<br>   },<br>   args:    args{ctx: context.Background()},<br>   want:    nil,<br>   wantErr: true,<br>  },<br> }<br> for _, tt := range tests {<br>  t.Run(tt.name, func(t *testing.T) {<br>   g := gomega.NewWithT(t)<br>   v := &amp;VendorService{<br>    vendorDBAccessor: tt.fields.mockVendorDBAccessor,<br>   }<br><br>   if tt.wantErr {<br>    tt.fields.mockVendorDBAccessor.EXPECT().<br>     GetByLocation(tt.args.ctx, location).<br>     Return(nil, fmt.Errorf(&quot;some error&quot;))<br>   } else {<br>    tt.fields.mockVendorDBAccessor.EXPECT().<br>     GetByLocation(tt.args.ctx, location).<br>     Return(tt.want, nil)<br>   }<br><br>   res, err := v.GetByLocation(tt.args.ctx, location)<br><br>   if tt.wantErr {<br>    g.Expect(err).ToNot(gomega.BeNil())<br>    g.Expect(res).To(gomega.BeNil())<br>   } else {<br>    g.Expect(err).To(gomega.BeNil())<br>    g.Expect(res).To(gomega.Equal(tt.want))<br>   }<br>  })<br> }<br>}</pre><h4>Step 2: Write the Minimum Code to Pass the Test (Green)</h4><p>Next, we implement the<em> </em>GetByLocation<em>’</em>s accessor and service method in the VendorService.</p><ul><li>The Accessor Implementation (accessor.go)</li></ul><pre>func (p *postgresVendorAccessor) GetByLocation(ctx context.Context, location string) ([]Vendor, error) {<br> query := `SELECT <br>  &quot;id&quot;,<br>  &quot;name&quot;,<br>  &quot;description&quot;,<br>  &quot;bp_id&quot;,<br>  &quot;bp_name&quot;,<br>  &quot;rating&quot;,<br>  &quot;area_group_id&quot;,<br>  &quot;area_group_name&quot;,<br>  &quot;sap_code&quot;,<br>  &quot;modified_date&quot;,<br>  &quot;modified_by&quot;,<br>  &quot;dt&quot; <br>  FROM vendor<br>  WHERE area_group_name = $1`<br><br> rows, err := p.db.Query(query, location)<br> if err != nil {<br>  return nil, err<br> }<br><br> defer rows.Close()<br><br> vendors := []Vendor{}<br><br> for rows.Next() {<br>  var vendor Vendor<br>  err := rows.Scan(<br>   &amp;vendor.ID,<br>   &amp;vendor.Name,<br>   &amp;vendor.Description,<br>   &amp;vendor.BpID,<br>   &amp;vendor.BpName,<br>   &amp;vendor.Rating,<br>   &amp;vendor.AreaGroupID,<br>   &amp;vendor.AreaGroupName,<br>   &amp;vendor.SapCode,<br>   &amp;vendor.ModifiedDate,<br>   &amp;vendor.ModifiedBy,<br>   &amp;vendor.Date,<br>  )<br>  if err != nil {<br>   return nil, fmt.Errorf(&quot;Failed while scanning row: %w&quot;, err)<br>  }<br>  vendors = append(vendors, vendor)<br> }<br><br> if err := rows.Err(); err != nil {<br>  return nil, err<br> }<br><br> return vendors, nil<br>}</pre><ul><li>The Service Implementation (service.go)</li></ul><pre>func (v *VendorService) GetByLocation(ctx context.Context, location string) ([]Vendor, error) {<br> return v.vendorDBAccessor.GetByLocation(ctx, location)<br>}</pre><h4>Step 3: Refactor the code if needed (Refactor)</h4><p>Finally, we refactor the code to ensure it is clean and maintainable. In this case, the code is already simple, so minimal refactoring is needed.</p><h3>Using GoMock for Unit Testing</h3><p>In addition to the steps above, we also use <a href="https://github.com/golang/mock">GoMock</a> to generate the services’ mocks to be able to create the unit test. GoMock is a tool that automatically generates mock implementations of interfaces, which can be used in tests to simulate the behavior of real objects.</p><p>To generate mocks for our vendorDBAccessor interface, we use the following command:</p><pre>go:generate mockgen -typed -source=service.go -destination=service_mock.go -package=vendors</pre><p>This command generates a mock implementation of the service interface in the service_mock.go file, which we can then use in our tests.</p><h3>Integrating TDD with CI/CD</h3><p>In our project, we use GitHub Actions to automate the testing and code quality checks. Here’s an example from our CI/CD files created by <a href="https://medium.com/u/c04aad412a39">Valerian Salim</a>:</p><ul><li>build.yml</li></ul><pre>name: Go Build CI<br><br>on:<br>  workflow_call:<br><br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br><br>      - name: Set up Go<br>        uses: actions/setup-go@v4<br>        with:<br>          go-version: &#39;1.23.1&#39;<br><br>      - name: Install Dependencies<br>        run: go mod download<br><br>      - name: Build Application<br>        run: make build-ci<br><br>      - name: Upload Binary Artifact<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: kg-procurement-binary<br>          path: ./bin/kg-procurement</pre><ul><li>unit-tests.yml</li></ul><pre>name: Unit Tests with Coverage<br><br>on:<br>  workflow_call:<br><br>jobs:<br>  test:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br><br>      - name: Set up Go<br>        uses: actions/setup-go@v4<br>        with:<br>          go-version: &#39;1.23.1&#39;<br><br>      - name: Install dependencies<br>        run: go mod download<br><br>      - name: Run Tests with Coverage<br>        run: go test -v -race -coverprofile=coverage.out ./...<br><br>      - name: Upload Coverage Report<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: coverage-report<br>          path: coverage.out</pre><ul><li>sonarcloud.yml</li></ul><pre>name: SonarCloud Analysis<br><br>on:<br>  workflow_call:<br><br>jobs:<br>  sonarcloud:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout Repository<br>        uses: actions/checkout@v4<br>        with:<br>          fetch-depth: 0<br><br>      - name: Set up Go<br>        uses: actions/setup-go@v4<br>        with:<br>          go-version: &#39;1.23.1&#39;<br><br>      - name: Install Dependencies<br>        run: go mod download<br><br>      - name: Run Tests with Coverage<br>        run: |<br>          go test -v -race -coverprofile=coverage.out -covermode=atomic ./...<br><br>      - name: Display Coverage Summary<br>        run: go tool cover -func=coverage.out<br><br>      - name: SonarCloud Scan<br>        uses: SonarSource/sonarcloud-github-action@v3.0.0<br>        with:<br>          args: &gt;<br>            -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}<br>            -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}<br>            -Dsonar.go.coverage.reportPaths=coverage.out<br>            -Dsonar.sources=.<br>            -Dsonar.tests=.<br>            -Dsonar.test.inclusions=**/*_test.go<br>            -Dsonar.exclusions=**/vendor/**,**/*_mock.go,internal/common/database/**<br>            -Dsonar.coverage.exclusions=**/router/**,**/accessor.go,**/vendor/**,**/*_mock.go,**/*_test.go,**/cmd/**/*.*<br>            -Dsonar.cpd.exclusions=**/accessor.go,**/*.sql<br>            -Dsonar.language=go<br>            -Dsonar.sourceEncoding=UTF-8<br>        env:<br>          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}<br>          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}</pre><ul><li>ci-workflow.yml (combining all pipelines together)</li></ul><pre>name: CI Workflow<br><br>on:<br>  push:<br>    branches:<br>      - main<br>  pull_request:<br>    types: [opened, synchronize, reopened]<br><br>jobs:<br>  build:<br>    uses: ./.github/workflows/build.yml<br>    secrets: inherit<br><br>  test:<br>    needs: build<br>    uses: ./.github/workflows/unit-tests.yml<br>    secrets: inherit<br><br>  sonarcloud:<br>    needs: test<br>    uses: ./.github/workflows/sonarcloud.yml<br>    secrets: inherit</pre><p>This configuration ensures that our tests are run and code coverage is reported every time we push changes to main or create a pull request.</p><h3>Conclusion</h3><p>In the end, your commits will look like something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*voIGqBKsqQiQFGErtczS1Q.png" /><figcaption>TDD style Github commits</figcaption></figure><p>TDD is a powerful technique that can significantly improve the quality and maintainability of your code. By writing tests first, you ensure that your code meets the requirements and is thoroughly tested. Integrating TDD with CI/CD pipelines, as shown in our example, further enhances the development process by automating tests and code quality checks.</p><blockquote>Happy coding!</blockquote><h3>Reference</h3><p><a href="https://testdriven.io/test-driven-development/">What is Test-Driven Development? | TestDriven.io</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c917ccc3fa92" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>