<?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 Dvir Segal on Medium]]></title>
        <description><![CDATA[Stories by Dvir Segal on Medium]]></description>
        <link>https://medium.com/@dvirsegal?source=rss-c9904a464f9b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*8o_AAJBhaMjwCa18vuScqw.png</url>
            <title>Stories by Dvir Segal on Medium</title>
            <link>https://medium.com/@dvirsegal?source=rss-c9904a464f9b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 06 May 2026 15:34:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dvirsegal/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[Connecting LLMs to my debugging flow to fix a memory crash]]></title>
            <link>https://dvirsegal.medium.com/connecting-llms-to-my-debugging-flow-to-fix-a-memory-crash-eb42bbb2d174?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb42bbb2d174</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Sat, 10 Jan 2026 20:31:30 GMT</pubDate>
            <atom:updated>2026-01-10T20:31:30.725Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWChIDNHi2cn7kKJxt3Oxw.png" /></figure><p>Every engineer has a “Mystery Case” story. 🔍</p><p>For a long time, mine was a service that would run perfectly for weeks, and then, always at the most unexpected times, would violently consume memory and die.</p><p>I didn’t just ignore it. <strong>I fought it.</strong></p><p>I analyzed logs, optimized code to reduce allocation pressure, and even claimed a “False Victory” once, deploying a fix I <em>swore</em> was the root cause. The crash stopped for a week, then came back.</p><p>We kept restarting the system by hand to keep it running, but we didn’t know what was really causing the problem. We tried hard to find out why, but checking things manually wasn’t enough. There was just too much data to look through, which hid the important facts. Trying to piece it together ourselves took way too much time and effort. Because we didn’t have a better tool to help us, we got stuck.</p><p>Recently, I finally solved the case. Not by traditional debugging. I did it by using AI to connect a conversation between my varios “disconnected” tools.</p><p>Here is the breakdown of the investigation.</p><h4>Phase 1: Evidence Gathering (Finding the Needle in the Telemetry Haystack)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNDFjdvojP3uxDt7XWZpgQ.jpeg" /></figure><p>I exported the raw metric data and treated the AI as a <strong>Pattern Matcher</strong>.</p><ul><li><strong>My Prompt:</strong> <em>“Analyze this dataset. Find the exact timestamps where memory allocation spikes &gt; 20% in under 60 seconds.”</em></li><li><strong>The Result:</strong> It identified two specific seconds in time.</li></ul><p>I took those timestamps and asked the AI to generate a targeted query for my log aggregator (which have its own agent). The logs lit up. Every single memory spike aligned perfectly with a specific <strong>“System Refresh Event.”</strong></p><p>In hindsight, this looks obvious. But in a codebase with millions of lines, “obvious” is a luxury you only get <em>after</em> you know exactly where to look.</p><h4>Phase 2: The Interrogation (The “Chat-to-Profiler” Bridge)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yvyqs3J5dchonwcjGKYHkg.jpeg" /></figure><p>Knowing <em>when</em> it happened was half the battle. I needed to know <em>what</em> was exploding.</p><p>The crash was happening deep in our core infrastructure. This wasn’t “bad code”; it was battle-tested bedrock logic that has scaled with us for years, making any modification a high-stakes operation requiring surgical precision.</p><p>In previous attempts, analyzing a production dump meant a deep, manual dive into a memory profiler. While modern profilers are powerful, they still require you to do all the heavy lifting. This time, I used a <a href="https://svnscha.de/posts/ai-meets-windbg/"><strong>Model Context Protocol (MCP)</strong></a> to turn my profiler into a conversational partner. Instead of hunting through heap snapshots myself, I had a dialogue:</p><blockquote><strong><em>AI:</em></strong><em> “I detect a high volume of duplicate objects on the heap.”</em></blockquote><blockquote><strong><em>Me:</em></strong><em> “That’s impossible, those should be cached and reused.”</em></blockquote><blockquote><strong><em>AI:</em></strong><em> “The cache references are unique. They are not being reused.”</em></blockquote><p>It wasn’t magic. I had to guide the AI, filtering out hallucinations and refining the context, but it handled the syntax while I focused on the semantics. It pointed me to a race condition I had looked at a dozen times but never truly <em>saw</em>.</p><h4>Phase 3: The Implementation (Architecting the Cure)</h4><p>The root cause was a classic “Stampede”: clearing old data before the new data was ready.</p><p>I knew the concept of the fix (a “Relay Race” pattern), but implementing high-concurrency caching logic in a critical subsystem is risky.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9lBBxo3ZHU9rFSf8po2F8A.jpeg" /></figure><p>I used the AI to <strong>implement the solution</strong>:</p><ul><li><strong>The Prompt:</strong> <em>“Refactor this cache logic to support a ‘Versioned Handoff’. Ensure thread safety during the swap between Version 1 and Version 2.”</em></li><li><strong>The Result:</strong> The AI generated the boilerplate for the atomic swapping mechanism.</li></ul><p>But I didn’t just copy-paste. I established an <strong>“AI Tribunal”</strong> (Github Copilot ,running cluade, for logic, Gemini for architecture) and performed a rigorous human code review to ensure the locking mechanism was sound before it ever touched the staging enviroment.</p><h4>The Takeaway</h4><ul><li><strong>Don’t replace yourself; multiply yourself.</strong> I used AI to handle the “grunt work” of parsing data and generating boilerplate.</li><li><strong>Orchestrate, don’t just chat.</strong> Connect your tools. Let the metrics talk to the logs, and let the profiler talk to the code.</li><li><strong>Respect the “Boring” Solution.</strong> The fix wasn’t a fancy new framework; it was a simple, boring Relay Race pattern.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gbZWeq2l1QSqKsLmJjS9w.jpeg" /></figure><p>The case is finally closed. The fires are out, and production is quiet again, exactly how a well-engineered system should feel</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb42bbb2d174" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Joy of Negative Code Lines]]></title>
            <link>https://dvirsegal.medium.com/the-joy-of-negative-code-lines-5440ae1f26a6?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5440ae1f26a6</guid>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 14:49:52 GMT</pubDate>
            <atom:updated>2025-11-28T14:49:52.612Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tnZPulvE-RoIW5lUBWdXxA.jpeg" /></figure><h4>There is a common bias in our industry: the instinct to add.</h4><p>As developers, when we face a problem, our default reaction is to write a new function or add a new library. It feels like progress. But while code drives value, it also carries a <strong>continuous maintenance cost.</strong></p><p>Every line you write is a line that must be read by teammates, covered by tests, and secured against vulnerabilities. The most efficient system is the one that delivers maximum value with minimum code.</p><h4>The “Just In Case” Hoarder</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g80s7TslHzoVHaPHh7pNJw.jpeg" /></figure><p>It is easy to spot the “Fear of Deletion” in a Code Review.</p><p>You see a method that isn’t referenced anymore, but it’s still there. Or maybe it’s commented out. The mindset is: <em>“Better keep it. You know, just in case we need to revert.”</em></p><p>This turns your codebase into a digital junk drawer.</p><p>“Zombie Code” — logic that is dead but still present, adds noise. It pollutes “Find Usages” results and confuses the next engineer trying to understand the domain. They waste time analyzing functions that provide no value to the user.</p><h4>How to verify usages</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPgNy_NJqRtHmqb308TQzQ.jpeg" /></figure><p>The hardest part of deleting code is the fear of breaking something hidden. “Find All References” isn’t enough. Here is how to verify usage safely:</p><ol><li><strong>The Static Check:</strong> Start with the IDE. If a method is private, the compiler is usually right. If it’s public, be suspicious. Tools like <a href="https://www.ndepend.com/">NDepend</a> or <a href="https://www.sonarsource.com/products/sonarqube/">SonarQube</a> can often spot &quot;dead branches&quot; that visual inspection misses.</li><li><strong>The External Audit:</strong> Check the edges. Are frontend analytics still firing events for that feature? Are HTTP logs showing hits on the old API endpoint? Are cloud metrics showing activity on that specific storage? If the edges are silent, the core is likely dead.</li><li><strong>The Database Audit:</strong> Sometimes the code looks valid, but the <em>data</em> is stale. Check your database statistics. If a table hasn’t had an INSERT or UPDATE in two years, the code managing that table is likely ghost-logic.</li><li><strong>The “Scream” Test (Use Metrics):</strong> If you are unsure about a specific internal method, emit a custom metric: Metrics.Increment(&quot;deprecated_feature_x_usage&quot;). If the counter stays at zero for a full business cycle, you have your answer.</li></ol><p><strong>Data beats intuition.</strong> If you can prove nobody calls it, you can delete it without sweating.</p><h4>The AI Assistant (Your Cleanup Partner)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WCor_34dyYDlXHsqTtdJg.jpeg" /></figure><p>We are in the age of LLMs, and ignoring them would be a mistake. While you should never let an AI autonomously delete code in production, it is an incredible force multiplier for the verification and cleanup phases.</p><ul><li><strong>The “Explain This” Test:</strong> Paste suspicious legacy code into an AI and ask: <em>“Identify potential side effects if this were removed.”</em> It often finds hidden dependencies.</li><li><strong>The “Safety Net” Tests:</strong> Before deleting complex logic, ask the AI to <em>“Write comprehensive unit tests for this function.”</em> Having tests that fail <em>after</em> you delete the code confirms you understand its impact.</li><li><strong>Generate the “Red PR”:</strong> Once you identify dead code, ask the AI to do the grunt work: <em>“Refactor this file to remove the unused LegacyProcessor class and all references.”</em></li></ul><p><strong>Remember: AI is a tool for acceleration, not abdication.</strong> You are still the one clicking “Merge.”</p><h4>The Sunset Strategy (Rollout Plan)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GcB8oCWkLAZOMOa6Ug6mgw.jpeg" /></figure><p>Verifying is one thing; deleting is another. You need a safety net.</p><ul><li><strong>Phase 1: The Warning:</strong> Don’t rely on quiet runtime logs. Mark code @Obsolete to warn other developers in their IDE, and clearly communicate removal dates in your changelog and team channels.</li><li><strong>Phase 2: The “Soft Delete” (Feature Flag):</strong> Wrap the entry point in a Feature Flag and <strong>turn it off</strong>. This is your instant rollback mechanism if a critical user complains.</li><li><strong>Phase 3: The Observation:</strong> Keep the flag off for a safe period (e.g., 2 sprints). Ensure you have alerting on that disabled path. Silence is golden.</li><li><strong>Phase 4: The Code Delete</strong> Once the observation period has passed with zero alerts and no customer complaints, it is safe to delete the code, the flag, and the tests.</li><li><strong>Phase 5: The Data Cleanup:</strong> Deleting code often leaves behind orphaned data. Wait a few extra sprints to be absolutely sure, then archive the data to cold storage before finally dropping unused tables or columns. Your schema should reflect reality, not history.</li></ul><h4>The Bottom Line</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWMY4XDDN4HlXwYIYh6q-Q.jpeg" /></figure><p>There is a unique satisfaction in opening a Pull Request where the <strong>Lines Removed</strong> count is higher than the <strong>Lines Added</strong> — it means you have simplified the mental model without sacrificing functionality. If code isn’t running in production, it is just noise; trust your git history, verify with data, and hit delete.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5440ae1f26a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Write boring code]]></title>
            <link>https://dvirsegal.medium.com/write-boring-code-e6a80c8311bb?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6a80c8311bb</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Sun, 19 May 2024 11:57:14 GMT</pubDate>
            <atom:updated>2024-05-19T11:57:14.223Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fsa40ezPVX_z0he0" /></figure><h4><strong>Debuggability is highly underrated</strong></h4><p>In the words of Brian Kernighan, the famous computer scientist and author of the book “The C Programming Language”:</p><blockquote>Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.</blockquote><p>This quote reflects a common experience many developers face while trying to write &quot;smart&quot; code. They often end up with complex solutions that are hard to maintain and debug. This is a common mistake, driven by the desire to demonstrate skills (and maybe to appear clever).</p><p>So…<strong> just write boring and straightforward code.</strong> Organize it into small, independent modules with clear interfaces and low coupling. This makes it easier to isolate and debug issues within specific components without being affected by the rest of the system.</p><p><a href="https://dvirsegal.medium.com/how-to-organize-a-drawer-the-right-way-4db782c07976">How to organize a drawer the right way</a></p><blockquote>Code is written once but read many times</blockquote><p>Make your code readable and self-documented. This means code that follows good naming conventions, uses descriptive variables and function names, and includes clear comments (if needed).</p><p>When implementing your solution, you must think about how it will be executed. You probably focus on the happy trail, but you should also consider how it will fail and how you will debug it <strong>in production</strong>. Not doing so results in a mistake that can waste a lot of time and effort looking through complicated code to figure out and fix the problem.</p><p>To address this challenge, one must shift her mindset and prioritize <strong>debuggability</strong> from the start of the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/0*Y_bqT2jpu6GGD2HW.png" /><figcaption><a href="https://peter.bourgon.org/blog/2017/02/21/metrics-tracing-and-logging.html">Peter Bourgon — Metrics, tracing, and logging</a></figcaption></figure><p>This means leaving breadcrumbs, also known as <strong>logs</strong>, storing data in machine-readable format to enable efficient parsing and analysis, capturing valuable information about the application’s state, execution flow, and any errors or exceptions. There are several error-handling mechanisms that catch and report issues as early as possible, making it easier to identify and fix bugs. The logs from the different components and services will be collected into a centralized system for easier aggregation and querying.</p><p>In some cases, logs alone don&#39;t give us the complete picture of how a system is doing. It&#39;s a good idea to use <strong>metrics</strong>, which help us understand the system&#39;s health, performance, and behavior more completely. I’m a big fan of metrics because they give us a clearer view. You can detect anomalies and track quantities over time. Based on the collected data, you will build monitoring dashboards that provide real-time visibility (and alerting system).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/0*0DvQ08NqpfI1M8-s.jpg" /></figure><p>Another tool in the debugability arsenal is <strong>tracing</strong>, which tracks the flow of “requests” across different services and components, enabling us to visualize and analyze the end-to-end journey of a request and pinpoint bottlenecks or failures.</p><p>Furthermore, investing in administrative tooling that reflects the system&#39;s state by exposing APIs or CLIs can greatly enhance debuggability by allowing developers and administrators to interact with the system, query its state, and perform various tasks such as triggering debug modes, capturing snapshots, or executing diagnostic commands.</p><p>Lastly, live debugging tools like <a href="https://www.rookout.com/">Rookout</a>, <a href="https://www.datadoghq.com/blog/dynamic-instrumentation-application-logging/">Datadog</a>, and <a href="https://lightrun.com/">Lightrun</a> allow you to debug code in production without any code changes. This is quite amazing and it is done by incorporating their agent into your code that does dynamic instrumentation. This agent is a bridge between your code and their environment. It monitors the code’s execution and identifies points in the flow (such as function calls or variable assignments), and it does some optimization not to instrument everything based on the learned history of “hot” paths to minimize the performance hit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*jSjE4gU84WiVR3DE" /><figcaption><a href="https://www.reddit.com/r/ProgrammerHumor/comments/y7y6iz/simple_code_works_better_than_complicated_code/?rdt=44272">Simple code works better than complicated code.</a></figcaption></figure><p>To conclude, writing boring and straightforward code, combined with various observability techniques, which should be included as early as in the design stage, can significantly enhance your system&#39;s debuggability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6a80c8311bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building LEGO without instructions]]></title>
            <link>https://dvirsegal.medium.com/building-lego-without-instructions-c5aacfcc696f?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5aacfcc696f</guid>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[career-growth]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Wed, 20 Mar 2024 11:34:54 GMT</pubDate>
            <atom:updated>2024-03-20T11:34:54.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h0GgifAlWUClQskH" /><figcaption>Photo by <a href="https://unsplash.com/@lalunecreative?utm_source=medium&amp;utm_medium=referral">Matt Hudson</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A few months ago, we had a hackathon at my work. <br>At the opening event, one of my colleagues said to me:</p><blockquote>Hackathons are similar to building LEGO model without instructions.</blockquote><p>It stuck with me. I pondered about it.</p><p>What crossed my mind is that hackathons are playgrounds for software engineers, where creativity is key. Imagine being handed a box of LEGO bricks, and the instructions are taken away; what would you build? Probably, whatever comes to your mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zsaS5_zuZy8vzFO_hdTm1Q.png" /></figure><p>That’s the magic of hackathons — they push you to think beyond boundaries, innovate, and craft something extraordinary from seemingly random pieces. Just as LEGO bricks offer endless possibilities, hackathons provide a platform for boundless innovation.</p><p>There are no rules; your imagination is the only limit. Without a set path to follow, hackathons encourage participants to explore new territories, experiment with fresh ideas, devise effective and unique solutions, and, along the way, have FUN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XDiER1FiIiUaCe3A.jpg" /></figure><p>You start with an array of tools — technologies, APIs, datasets — and the goal is to create something innovative and functional. This process fosters creative problem-solving and rapid prototyping, crucial skills in the dynamic software development landscape.</p><p>To sum up, hackathons serve as platforms for software engineers to push boundaries, explore new ideas, and work together in diverse teams to create groundbreaking solutions. Ultimately, they encourage a culture of continuous learning and experimentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5aacfcc696f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TIFU at work: Learn and move on!]]></title>
            <link>https://dvirsegal.medium.com/tifu-at-work-learn-and-move-on-cf357f50e674?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf357f50e674</guid>
            <category><![CDATA[software-engineer-life]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[fuckup-nights]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Thu, 25 Jan 2024 22:03:28 GMT</pubDate>
            <atom:updated>2024-01-25T22:03:28.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tq7SUSVacA7WBNhC" /><figcaption>Photo by <a href="https://unsplash.com/@barbaris778?utm_source=medium&amp;utm_medium=referral">Santa Barbara</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Everyone makes mistakes. If someone says otherwise, they’re probably not being straight with you. It’s bound to happen whether you’re new to a job or have been there for a while. You can find plenty of horror stories on Reddit and HackerNews. Take, for example, this post with a collection of those stories:</p><p><a href="https://news.ycombinator.com/item?id=7144934">Ask HN: What&#39;s the worst you&#39;ve ever screwed up at work? | Hacker News</a></p><p>I felt that gut-wrenching moment when you realize a mistake has been made. The sinking feeling in your stomach, the twinge of shame, or the self-critical thoughts might flood in.</p><p>But here’s the thing: mistakes are a natural part of the journey, and what matters most is how we navigate and<strong> learn from them</strong>. In this post, I’ll try to explain why.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Kx7_DnQ8zKk5FaFicxEyFA.png" /></figure><h3>Acknowledge and Own Up</h3><p>The first step is crucial — acknowledge the mistake. It’s tempting to sweep it under the rug or pass the blame, but trust me, that only makes things worse. Take responsibility and be brutally honest about what went wrong. Embrace the uncomfortable truth; it’s the only way forward.</p><p>Show that you’re proactive and committed to resolving the issue. Follow up and keep your team updated on your progress. Communicate clearly and frequently until the problem is solved.</p><p>Moreover, in my experience, there’s a hidden gem amid chaos — a chance to observe how people react. It’s like a crash course in understanding your company’s DNA. The way individuals handle mistakes reveals volumes about the organization’s culture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*7KBOMNWrHE5vun58FJXQ2w.png" /></figure><h3>Uncover the Why</h3><p>Once you’ve owned up to the mistake, dive into detective mode to understand why it happened. Was it a knowledge gap, lack of training, or a hurried decision? This isn’t about pointing fingers but gaining insights.</p><p>Think of it as peeling an onion — layer by layer, get to the core of the issue. Was there a miscommunication or a systemic flaw? I can suggest using the 5 Whys technique. This is how it works:</p><ol><li>Start with the problem statement and ask why it happened</li><li>For each answer, ask why again until you reach the root cause</li><li>Repeat the process for different aspects of the problem until you have a comprehensive picture of the situation.</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFJ0eWm5PxkU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFJ0eWm5PxkU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFJ0eWm5PxkU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/74cf6aef322fc58ec71b0efb0c3fe29d/href">https://medium.com/media/74cf6aef322fc58ec71b0efb0c3fe29d/href</a></iframe><p>Understanding the why isn’t just for personal growth; it’s about making your team and organization more resilient.</p><p>By figuring out the root cause, you not only learn from your own slip-ups but also contribute to a shared knowledge base. Keep it simple, grab your metaphorical magnifying glass, and unravel the mysteries behind your mistakes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*fnW7rCbWR84R7gE1VMGyUQ.jpeg" /></figure><h3>Fix It, Learn from It</h3><p>Fixing the mistake is an obvious step, but don’t just gloss over it.</p><p>Don’t just patch the error; analyze it like a Git blame gone rogue. What went wrong? Was it a logic gap, a memory leak, or maybe a sneaky exception lurking in the shadows? Understanding the root cause is the key to unlocking points for future levels.</p><p>If you need a guide on how to start when it you against the issue, I once wrote a post about it:</p><p><a href="https://dvirsegal.medium.com/a-letter-to-the-lonely-developer-bd0ac22ba714">A letter to the lonely developer</a></p><p>Provide a high-level overview of what you did to resolve the issue, and accompany it with your key takeaways. Turning the page without reflecting on the lesson learned is a missed opportunity for personal and professional growth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*20N2v7DI1vg4lfY5.gif" /></figure><h3>Prevent Future Slip-Ups</h3><p>Now armed with insights, take proactive steps to prevent a repeat performance.</p><p>Knowledge is the ultimate firewall. Invest in training, devour documentation like it’s your favorite Stack Overflow thread, and consider adding unit tests like shields against future regressions, allocating more time for tasks, implementing new processes, or adding logs and metrics for better visibility.</p><p><a href="https://dvirsegal.medium.com/the-power-of-the-unit-tests-73badc0fbf28">The power of the unit tests</a></p><p>Remember, prevention is the ultimate hack to keep bugs at bay.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*kmBrqtHw6UU6QV0kIWNVDw.png" /></figure><h3>Reflect and Share</h3><p>Don’t let your hard-earned lessons be solo commits. Take a moment to reflect on the entire experience. Consider what could have been done differently and how you can improve professionally. Conduct a retrospective meeting with your team to discuss the mistake and the lessons learned. Use a structured format, such as the Start-Stop-Continue model, to identify what worked well, what didn’t work well, and what can be improved. Encourage everyone to participate and share their perspectives and suggestions.</p><p><a href="https://dvirsegal.medium.com/look-into-the-past-improve-the-future-a21fa1fc97d">Look into the past, improve the future</a></p><p>Document your reflections and share them internally as part of a post-mortem. Transform your learning into collective wisdom, turning it into “stronger” code (and fewer regressions).</p><p>Below is a collection of some examples from very respectful companies:</p><p><a href="https://github.com/danluu/post-mortems">GitHub - danluu/post-mortems: A collection of postmortems. Sorry for the delay in merging PRs!</a></p><p>Lastly, embrace the “fail fast, iterate faster” mentality. Treat mistakes as experiments gone sideways, valuable data points in the grand algorithm of your career.</p><h3>In Conclusion</h3><p>Mistakes are an inevitable part of the developer’s journey, but they are also invaluable learning experiences. Acknowledge, understand, fix, prevent, and reflect — these steps can turn a negative situation into a positive opportunity for growth. Remember, it’s not about avoiding mistakes altogether; it’s about handling them with resilience and turning them into stepping stones on your path to success. After all, everyone makes mistakes — it’s the journey of learning from them that truly matters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf357f50e674" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The power of the unit tests]]></title>
            <link>https://dvirsegal.medium.com/the-power-of-the-unit-tests-73badc0fbf28?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/73badc0fbf28</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[humor]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Wed, 14 Jun 2023 05:52:27 GMT</pubDate>
            <atom:updated>2023-06-14T05:52:27.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mn1PJtkGmmOS8bQO1dS65A.png" /></figure><h4>A humoristic post generated with the help of ChatGPT</h4><h4>Do you wanna see me test? U wanna see me unit test?</h4><p>In the world of software development, unit testing is an essential process that ensures our code behaves precisely as we expect. But let’s be honest; unit testing is not the most glamorous part of coding. It’s the backstage crew, the hidden orchestrators behind a great performance. And just like the Eurovision Song Contest, our unit tests must be pitch-perfect to score the highest points in reliability and robustness.</p><p>Now, imagine unit tests as a song in the Eurovision contest, specifically, the 2023 Israeli entry, “Unicorn” by Noa Kirel. Why? Well, stick around, and you’ll see how unicorns and unit tests have more in common than you think!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*IbzGS9De9iWOTDaP80t8bw.png" /><figcaption>Uni Tess — The personification of unit tests, a meticulously organized individual by stable diffusion</figcaption></figure><h3>Unit Tests: The Unsung Heroes</h3><p>Think of your software as a competitor in the contest. The software, like the singer, is the face of the performance, taking center stage and getting the applause. But behind that successful performance, there’s a lot of practice and fine-tuning. That’s where our unit tests come in. These tests, the unsung heroes, ensure that each piece of the code (the lyrics, the melody, the rhythm) works correctly. If the tests pass, it’s time for our code to hit the stage!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*WiDU9NdY4QgZIrXqzlagWg.png" /><figcaption>The power of the unicorn by stable diffusion</figcaption></figure><h3>Embracing the Power of the Unicorn</h3><p>In “Unicorn,” Noa Kirel sings about harnessing the “power of a unicorn,” symbolizing strength and uniqueness. This can be seen as a metaphor for our unit tests. Each test is unique and powerful in its own way, checking a specific part of our code. Combined, they provide the strength and assurance that our software functions correctly.</p><p>Much like Noa Kirel found her “horn” to embrace and used her experience as a young artist to promote strength and togetherness, we too, as developers, must embrace our unit tests. They may face criticism (usually from developers who think they’re not worth the time), but we know their true value. They promote “coexistence and togetherness” in our code, ensuring that each piece works together harmoniously.</p><h3>Hitting the High Notes with Unit Tests</h3><p>“Unicorn” made it to a 3rd-place, showing that a strong performance and a unique message can indeed score high points. The same applies to unit testing. High-quality, well-thought-out unit tests can help your software reach its highest potential and avoid any sour notes (bugs) during the performance (runtime).</p><p>A well-tested software is like a chart-topping hit; it’s reliable, it’s loved by users, and it’s less likely to crash in the middle of the performance. It may not be a unicorn, but in the software world, it’s pretty close!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*7U_5t6ojoL-hOfKQ" /></figure><h3>The Encore</h3><p>So, the next time you write unit tests, think of yourself as a Eurovision contestant preparing for a big performance. Each test you write is a line in your song, a step in your dance routine, or a note in your melody. Embrace its power, harness the strength of your tests, and get ready to take the stage.</p><p>And remember, in the grand Eurovision of software development, your unit tests could be the difference between a standing ovation and a silent auditorium. So, let’s hit those high notes, and may the best code win!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73badc0fbf28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating through the job search]]></title>
            <link>https://dvirsegal.medium.com/navigating-through-the-job-search-599b1bc4221f?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/599b1bc4221f</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[job-offer]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[job-hunting]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 19:19:04 GMT</pubDate>
            <atom:updated>2023-04-10T19:19:04.577Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NAAn4CBG-IJAwq4L" /><figcaption>Photo by <a href="https://unsplash.com/@bjarkerosenbeck?utm_source=medium&amp;utm_medium=referral">Bjarke Rosenbeck</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Essential tips and resources for a successful job hunt</h4><p>I was laid off from my previous job. It came out of nowhere; I decided to take this change as an opportunity and make the best of it. Luckily, I received incredible support from my connections, and I want to give back by sharing some valuable lessons and resources I’ve gathered along my job search journey.</p><p>This blog post is based on a Twitter (Hebrew) thread I created, detailing my experience and offering practical advice to fellow software engineers (and not only) facing a similar situation.</p><h3>Dvir Segal on Twitter: &quot;בניסיון לעשות לימונדה מהלימון. אז שרשור #דבירמחפשעבודה יוצא לדרך עם דברים שלמדתי along the way , אם מישהו אשכרה יתעניין בזה.טוב, אז קודם כל לעדכן קורות חיים. לשבת לכתוב ולהיעזר במדריך ששתפה @ShaharAvigezer בשרשור חיפוש עבודה שלה שנכתב על ידי @esapir:https://t.co/oo94ZtHPXY / Twitter&quot;</h3><p>בניסיון לעשות לימונדה מהלימון. אז שרשור #דבירמחפשעבודה יוצא לדרך עם דברים שלמדתי along the way , אם מישהו אשכרה יתעניין בזה.טוב, אז קודם כל לעדכן קורות חיים. לשבת לכתוב ולהיעזר במדריך ששתפה @ShaharAvigezer בשרשור חיפוש עבודה שלה שנכתב על ידי @esapir:https://t.co/oo94ZtHPXY</p><h3>Updating Your Resume</h3><p>First and foremost, updating your resume is crucial. Use guides and resources like the <a href="https://twitter.com/esapir/status/1578276325235855361">one</a> shared by <a href="https://medium.com/u/88a502b20409">Shahar Avigezer</a> (written by <a href="https://medium.com/u/8dfbcd08c755">Erik Sapir</a>) and the <a href="https://twitter.com/rinaarts/status/1445809699056615424">one</a> by <a href="https://medium.com/u/f540d518c481">Rina Artstain</a> to help you craft a professional and polished resume showcasing your skills and experience. When you finish your resume, the optimal way to submit it is with a referral. But if it is not an option, just run your CV through the <a href="https://medium.com/u/6ee31f7dd897">CV Compiler</a> to see how it scores with applicant tracking systems and what needs to be improved (ATS robot)</p><h3>Leveraging Your Online Presence</h3><p>Consolidate your online activity into a “business card” with links to your LinkedIn, Twitter, and others. This way, you can showcase additional accomplishments and interests that may not fit your resume. It also demonstrates your professionalism and personal brand. A few years ago, I read a post written by <a href="https://medium.com/u/8b9503902484">Kshitij Singh</a> on how he created such a landing page, and I followed his guidelines in his repo below:</p><p><a href="https://github.com/singhkshitij/My-Landing-Page">GitHub - singhkshitij/My-Landing-Page: Minimal Portfolio Page Built with React</a></p><p>The result:</p><figure><a href="https://dvirsegal.github.io/dvir-segal/"><img alt="" src="https://cdn-images-1.medium.com/max/655/1*dZXqH1AC4YwFm7NIw272cg.gif" /></a></figure><h3>Preparing Your Pitch</h3><p>Before applying for job positions, write a “tell me about yourself” document, as described in the book “<a href="https://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/0984782850">Cracking the Coding Interview</a>”. It should cover your current role and academic background (if applicable) and delves into the role’s details. Finally, hobbies — especially those related to the tech world or “unique”- could serve as conversation starters or perhaps break the ice.</p><p>Furthermore, the book suggested focusing on 2–3 challenging projects you’ve worked on. Write down a list of mistakes you’ve made (we all do them), what you had fun doing, and which conflicts you took part in. Eventually, it will assist you in writing phrases in the SAR (Situation, Action, Result) framework to tell a compelling story about your achievements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*yp2CdD_22mGgr0Qd" /><figcaption><a href="https://www.reddit.com/r/ProgrammerHumor/comments/6zkanu/someone_asks_for_cracking_the_coding_interview/">src</a></figcaption></figure><h3>Organizing Your Job Search</h3><p>Use tools like <a href="https://medium.com/u/efd97a1c507b">Notion</a> to keep track of your job applications and interviews. This will help you stay organized and focused during your search, ensuring you’re on top of each opportunity. I’ve used the following templates:</p><ul><li>Track down the list of job applications:</li></ul><p><a href="https://www.notion.so/templates/job-applications">Notion Template Gallery - Job applications</a></p><ul><li>A personal CRM to keep all your leads:</li></ul><p><a href="https://www.notioneverything.com/templates/simple-crm">Simple CRM | Notion Everything</a></p><h3>Researching Potential Employers</h3><p>Before applying for a job, research the company by checking its location, reading investment analysis, and searching for articles on sites like <a href="https://www.geektime.co.il/">Geektime</a> and <a href="https://medium.com/u/7cce2f5ab5c4">Crunchbase</a>. Search review-based websites like <a href="https://medium.com/u/a39c61f8b573">Glassdoor</a> to get an idea of what it’s like to work there. Prepare a list of questions (🙏 <a href="https://medium.com/u/88a502b20409">Shahar Avigezer</a>) to ask the recruiter to refine your job search better:</p><ul><li>What will my day-to-day look like?</li><li>How will I receive tasks? What percentage of meetings will I have per week?</li><li>What is the percentage split between front-end and back-end work? And from whom?</li></ul><p>Also, do some work with yourself to understand better what you’re looking for by asking the following:</p><ul><li>What does Work-Life Balance (WLB) mean for me?</li><li>What hybrid work model works best for me, and how?</li><li>What next role do I aspire to take on in the coming years?</li><li>Which programming language or framework do I prefer for front-end and back-end development?</li></ul><p>Being well-informed will help you make better decisions and impress potential employers.</p><h3>Preparing for Interviews</h3><p>I recommend the following two websites to help you study for code interviews:</p><ul><li>The interview school by <a href="https://medium.com/u/ecef467f0f28">Adilet Zhaxybay</a>:</li></ul><p><a href="https://interviews.school/">Home</a></p><ul><li><a href="https://twitter.com/techinterviewhb">The tech interview handbook</a>:</li></ul><p><a href="https://www.techinterviewhandbook.org/">Technical Interview Guide for Busy Engineers | Tech Interview Handbook</a></p><p>They offer guides, practice <a href="https://medium.com/u/33f6b9a1a861">LeetCode</a> questions, and tips on various aspects of the interview process. Preparation is key to standing out and performing well during interviews.</p><h3>System Design Interviews</h3><p>Brush up on key topics and watch the system design interviews video series by Sheeran:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLT3bGNUOvbdKThX9LDJQll4TdkVvw8IT6&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fplaylist%3Flist%3DPLT3bGNUOvbdKThX9LDJQll4TdkVvw8IT6&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-m5cMzm9R-s%2Fhqdefault.jpg%3Fsqp%3D-oaymwEWCKgBEF5IWvKriqkDCQgBFQAAiEIYAQ%3D%3D%26rs%3DAOn4CLDE-b7J0sZWG4OjP24exMoUsvPepg%26days_since_epoch%3D19443&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="853" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/37a53e95e3ccdfdd33be7849f31e10b7/href">https://medium.com/media/37a53e95e3ccdfdd33be7849f31e10b7/href</a></iframe><p>Followed by the introductory video on the importance of this type of interview, what they’re looking for in a candidate, breaking down the problem into details, and how to improve in this area by <a href="https://medium.com/u/939f988143af">Jackson Gabbard (Synthace)</a>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZgdS0EUmn70%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZgdS0EUmn70&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZgdS0EUmn70%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/61efb246abfdb01ac7a94e71170dfe5f/href">https://medium.com/media/61efb246abfdb01ac7a94e71170dfe5f/href</a></iframe><p>Practice solving problems using resources like the Grokking Modern System Design course by <a href="https://medium.com/u/163aa84775f6">The Educative Team</a> and tools like <a href="https://excalidraw.com/">excalidraw</a>. The more practice you get, the more confident you’ll showcase your skills.</p><p><a href="https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers">Grokking Modern System Design Interview for Engineers &amp; Managers - AI-Powered Learning for Developers</a></p><p>Note someone uploaded an old version of the course to <a href="https://medium.com/u/8df3bf3c40ae">GitHub</a>, which is enough for practicing, though some recent concepts are probably missing:</p><p><a href="https://github.com/Ducvoccer/Ducvoccer.github.io/tree/main/system-design/docs/grokking-system-design">Ducvoccer.github.io/system-design/docs/grokking-system-design at main · Ducvoccer/Ducvoccer.github.io</a></p><h3>Negotiating Your Offer</h3><p>If you receive a job offer, use resources like the <a href="https://docs.google.com/document/d/1ypLmqKALva4KO8qKX0HfESzHEkinjm7edrFw1jAylYU/edit?usp=sharing">document</a> by <a href="https://medium.com/u/1e0658cca392">Aviad Herman</a>, The Salary and Offer Negotiation Preparation section in the <a href="www.techinterviewhandbook.org">Tech Interview Handbook</a>, and <a href="https://twitter.com/barnashon">Iftach </a>Bar’s lecture on salary expectations to help you negotiate a fair package.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fpzq37L4UBUU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dpzq37L4UBUU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fpzq37L4UBUU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/80f9e9ac4d07fb10628657308ac39901/href">https://medium.com/media/80f9e9ac4d07fb10628657308ac39901/href</a></iframe><p>If you receive stock options, consult threads(<a href="https://twitter.com/beersehva/status/1416301132478099457">#1</a>, <a href="https://twitter.com/boazbe/status/1482029479149060098">#2</a>) by @beersehva and <a href="https://medium.com/u/c934e94437e8">Boaz Berman</a> and use tools like EquityBee’s calculator to estimate their value.</p><p><a href="https://equitybee.com/employees/my-options-value">Option Grant Benchmark Tool | EquityBee</a></p><h3>Conclusion</h3><p>I hope these tips and resources will be helpful to you on your job search journey. Remember that finding a new job can be challenging, but you can turn it into a new opportunity with perseverance, a strong network, and the right tools. Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=599b1bc4221f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Failing fast to increase feedback loops]]></title>
            <link>https://dvirsegal.medium.com/failing-fast-to-increase-feedback-loops-6d08f013fa9b?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d08f013fa9b</guid>
            <category><![CDATA[sofware-development]]></category>
            <category><![CDATA[integration-test]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[code-quality]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Wed, 09 Nov 2022 13:38:47 GMT</pubDate>
            <atom:updated>2022-11-09T13:38:47.974Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UOFJXh1-g2mb7l5a" /><figcaption>Photo by <a href="https://unsplash.com/@designedbyflores?utm_source=medium&amp;utm_medium=referral">Omar Flores</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>How we used integration tests to improve confidence in our code</h4><p>Picture this: your product owner brings you a set of new requirements, and together you review them. After some preparation and initial work, you get your design reviewed and approved by relevant stakeholders. Then, you enter your focus zone and start implementing it. While doing so, you want to gain confidence, so you add tons of unit tests to cover it, manually test it, and refactor your code based on your tests&#39; results until you feel comfortable with the outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*wxOAnUORtUJbKGD_dJdzYA.gif" /></figure><p>But still, you&#39;re left wondering, <em>&quot;how do I get to a strong level of confidence in this code?&quot;</em></p><p>In this post, I&#39;ll discuss what I did when faced with the above situation and how my team and I improved the quality of (and our confidence in) our code.</p><h4>Integration tests: what are they, and why do them? 🤔</h4><p>There is a straightforward answer to the second part of the above question: integration tests help ensure <strong>happy customers</strong>.</p><p>Developers take several approaches to test their code to ensure its integrity. Choosing the suitable testing method depends on your context. Nevertheless, some tests are required for every software. These tests are represented as a layer-based model, known as the testing pyramid proposed by <a href="https://www.mountaingoatsoftware.com/blog/the-forgotten-layer-of-the-test-automation-pyramid">Mike Cohn</a>.</p><p>Personally, I think the image below (by <a href="https://medium.com/u/5aa6b9976187">Atlassian</a>) emphasizes what we would like to achieve when choosing a specific testing approach by following each of the layers of the pyramid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*LZKkD_2CaNAHjOrhfAvFJw.png" /><figcaption>test pyramid — <a href="https://www.atlassian.com/blog/add-ons/deliver-faster-and-better-software-using-test-automation">src</a></figcaption></figure><p>Hence, we chose to implement integration tests to answer the question, &quot;Are we building the system right?&quot;</p><p>Why did we choose integration tests? These tests determine whether the parts of the solution work together as expected. Integration tests implementation is relatively easy and can prevent errors that are hard to catch later on. In addition, integration tests help to validate builds faster, reduce the time to ship, avoid human error, adhere to continuous integration (CI) practices, and minimize cost. As a result, everyone is happier in the long run because bugs are detected earlier, and larger problems are avoided. This increases our confidence and results in higher-quality code.</p><h4>How did we build them? 👷🏻‍♀️👷🏻‍♂️</h4><p>At <a href="https://www.igentify.com/">Igentify</a>, our services are deployed as <a href="https://www.docker.com/">Docker</a> containers. In a nutshell, containers isolate apps from their environment, solving the &quot;it works on my machine&quot; problem. Docker has a powerful <a href="https://docs.docker.com/engine/api/">API</a>, which makes it easy to automate its setup and deployment.</p><p>We use the famous <a href="https://www.testcontainers.org/">Testcontainers</a> library that provides lightweight, throwaway instances of anything that can run in a container. The Testcontainers library is test-friendly, open-source, and supports <a href="https://github.com/testcontainers">multiple programming languages</a>. Since Igentify&#39;s services are being deployed as containers, we already have a Dockerfile, and Testcontainers simply create a new temporary image for it on-the-fly.</p><p><a href="https://www.testcontainers.org/">Testcontainers</a></p><p>If you&#39;ve read this far, you&#39;re likely interested in diving into more technical details 🤓</p><p>As an example, if the design of your system is:</p><ul><li>Service A is a container that talks to the &quot;world&quot; using a message broker in the form of <a href="https://www.rabbitmq.com/">RabbitMQ</a></li><li>It gets a message from the RQ_Queue , processes it, requests a pre-signed s3 URL, and stores its result in the bucket using that URL</li><li>When finished, it responds to RS_Queue with the output</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Km1_M5XR5itK-7EH" /><figcaption>Service A Design</figcaption></figure><p>At a high level, the RabbitMQ container is being replaced by TestContainers&#39; <a href="https://www.testcontainers.org/modules/rabbitmq/">RabbitMQ module</a>, and its configuration is being filled by Service A context, which is being initiated by <a href="https://www.baeldung.com/spring-boot-testing#integration-testing-with-springboottest">@SpringBootTest</a> annotation. The blob service is essentially a web server that gets requests via REST calls. As part of its API, the blob service generates pre-signed URLs for uploading to cloud storage, which in our case, is an AWS S3 bucket.</p><p>So, how can a web server be controlled in a test environment? API mocking. In practice, it means you replace the real implementation with a local web server for your testing purposes. We use a well-known library named WireMock, where you simply mock the various requests and responses, and you are able to instruct storing files directly to your local drive, bypassing the cloud storage. Two birds with one stone.</p><p><a href="https://wiremock.org/">WireMock - flexible, open source API mocking</a></p><p>The final piece of the puzzle is to add a consumer for the RS_Queue to get the response and use JUnit5 to assert the expected output, resulting in a self-contained environment for testing. The input should be meticulously selected to cover success and\or failure scenarios.</p><p>Eventually, the integration test diagram looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KN5N-dfQWMtdfnc-" /><figcaption>Service A integration tests</figcaption></figure><p>The last step was incorporating the integration tests into our continuous integration in the <a href="https://www.jenkins.io/">Jenkins</a> server. Currently, we run it every build, but in the future, we will trigger it once a branch is merged into the main (current) branch. That will help us gain certainty that we didn&#39;t break anything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/0*h3evkTl-lK7eWbkR.jpg" /><figcaption>A Jenkins run — <a href="https://www.mememaker.net/meme/run-jenkins-run/">src</a></figcaption></figure><h4>Final Thoughts</h4><p>In this post, we reviewed how we&#39;ve designed integration tests for our Java Spring Boot application with the help of TestContainers and WireMock libraries. We showed how we could easily interact with actual data while being as close as possible to the product, giving us confidence in our code.</p><p>I believe these libraries bring a lot of immediate value with a rich set of functionalities. I encourage you to give them a try. Overall, integration tests are a crucial part of any software development, as they help to ensure a more robust product, resulting in happier customers.</p><p>We used integration tests while building version 7 of our <a href="http://www.igentify.com">Igentify digital genetic platform</a>, which we released last month. We plan to expand the capabilities of these tests in future releases of our software. If you&#39;re interested in learning more, <a href="https://info.igentify.com/en/general">please let us know here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d08f013fa9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to organize a drawer the right way]]></title>
            <link>https://dvirsegal.medium.com/how-to-organize-a-drawer-the-right-way-4db782c07976?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4db782c07976</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cohesion]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-design]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Sun, 30 Oct 2022 11:41:45 GMT</pubDate>
            <atom:updated>2022-10-30T11:41:45.524Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*feDfU6lJBAaHu4Mj" /><figcaption>Photo by <a href="https://unsplash.com/@shawnanggg?utm_source=medium&amp;utm_medium=referral">shawnanggg</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Or let’s talk about cohesion</h4><p>TL;DR To make a system cohesive, you <strong>must</strong> ensure that the parts that go together are close to one another.</p><p>I sometimes find that the cohesion (and coupling) concept is often considered way too academic, and developers tend to talk about other well-known concepts, such as <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a>, <a href="https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it">YAGNI</a>, <a href="https://en.wikipedia.org/wiki/KISS_principle">KISS</a>, and <a href="https://en.wikipedia.org/wiki/Single-responsibility_principle">SRP</a>. The list is long, and I can continue with more acronyms all day 😂 So, I’ve chosen to challenge myself and simplify it.</p><p>I hope I succeeded.</p><p>Have you decided to continue reading? <br>Let’s talk about why it’s crucial or, in <a href="https://medium.com/u/a8ff3eaa42c">Kent Beck’s</a> words:</p><h3>Kent Beck 🌻 on Twitter: &quot;Coupling vs cohesion. Coupling: * Can be hard to find * Can be really hard &amp;/| expensive to eliminate. Cohesive sub-elements are: * Usually easy to find * Cheap to achieve, &amp; * Help you find de-coupling. / Twitter&quot;</h3><p>Coupling vs cohesion. Coupling: * Can be hard to find * Can be really hard &amp;/| expensive to eliminate. Cohesive sub-elements are: * Usually easy to find * Cheap to achieve, &amp; * Help you find de-coupling.</p><p>You wanna strive for higher cohesion which reduces the coupling and complexity of the systems. What 😱? Let’s be formal for a moment:</p><blockquote><a href="https://en.wikipedia.org/wiki/Cohesion_(computer_science)"><em>Cohesion</em></a> is the degree to which the elements inside a module belong together.</blockquote><blockquote><a href="https://en.wikipedia.org/wiki/Coupling_(computer_programming)"><em>Coupling</em></a> is the degree of interdependence between software modules.</blockquote><p>Now it’s time for an analogy. Imagine you’re in the kitchen, it’s cold outside, and you wanna make a hot choco, so you open the silverware drawer, and it’s a total mess. Not only will it be hard to organize, but it’s not clear what belongs where and how to find it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*BwTEHzJUrJyjl96E" /></figure><p>On the contrary, when everything is in its place, you can easily find a knife if needed or store a new spoon. In my eyes, that’s cohesion, lowering the general mess.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*w1CQpbqPkOrI7e9P" /></figure><p>The terms cohesion and coupling are tightly related. They are often considered opposites, which isn’t accurate. Coupling is about <em>connections; cohesion</em> is about <em>belonging together</em>. The challenge is that cohesion is <em>discovered in a context </em>and cannot be created initially, meaning — you keep refactoring your code to keep objects in context.</p><p>The ideal scenario (also visible in the picture above) is when objects are arranged by functionality, or in other words, in a domain-driven context. When done correctly, it will result in loose coupling (there is no direct connection between a fork and knife besides the fact they are kitchenware).</p><p>Now… if you’ve reached this point, some code examples can be helpful. Let’s start with coupling:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*edRVyH-9TRTISpYl7sbsPA.png" /><figcaption>tight coupling</figcaption></figure><p>When running the snippet above, the output is ID is null. You can run it yourself:</p><p><a href="https://replit.com/@dejavo/TightCoupling?v=1">TightCoupling - Java Repl</a></p><p>So what’s going on? Each of the validity checks is being bypassed since Student and School classes are tightly coupled in such a way that School has intimate knowledge of Student’s internals and can set its data members. This design could be better. A quick solution will be declaring studentId with private access, forcing other classes to call the public getter and setter methods to access it, as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xekdWkrcnM1ir-awYHjPjw.png" /><figcaption>loose coupling</figcaption></figure><p>In this case, the output is :</p><pre>You can&#39;t initialize studentId to a null<br>ID is not initialized</pre><p><a href="https://replit.com/@dejavo/LooseCoupling?v=1">LooseCoupling - Java Repl</a></p><p>But how does all of that relate to cohesion 🤷🏻‍♂️ ?</p><p>Let’s get back to the Student and School example. If a class does all the work at once (God object), it results from high cohesion (and high coupling). Basically, there is a strong connection between the object in the same context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1U2SDmyeZc8hp_Db3-OZdQ.png" /><figcaption>low cohesion</figcaption></figure><p>While trying to adhere to the single responsibility (or separation of concerns) principle, the interface should be broken into several <em>classes</em>, each targeting different functionality (domain-driven), making it easier to maintain and update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4LpKxxAmnyq9u0U3jc7yRw.png" /><figcaption>High Cohesion</figcaption></figure><h4>Conclusion</h4><p>Simply put, <strong>cohesion</strong> means that a <em>class</em> should represent a single concept. However, remember that achieving full decoupling is only possible with damaging cohesion and vice versa.</p><p>A system architecture that is easy to understand, easy to change, easy to maintain, and to test, is characterized by high cohesion and loose coupling. This combination contributes to the reduction of accidental complexity and enables the creation of well-defined modules.</p><p>Ultimately, I want readers to take away that following those principles leads to a system that is easier to maintain and refactor in the future. This is where the actual value lies, and that’s why you should care about cohesion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4db782c07976" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Where do I get writing ideas from?]]></title>
            <link>https://dvirsegal.medium.com/where-do-i-get-writing-ideas-from-bc98bb8d17d4?source=rss-c9904a464f9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc98bb8d17d4</guid>
            <category><![CDATA[writer-block]]></category>
            <category><![CDATA[writers-on-writing]]></category>
            <category><![CDATA[ideas]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[blogging]]></category>
            <dc:creator><![CDATA[Dvir Segal]]></dc:creator>
            <pubDate>Sun, 28 Aug 2022 11:34:06 GMT</pubDate>
            <atom:updated>2022-08-28T11:34:06.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MkrMxkFDfcqju54A" /><figcaption>Photo by <a href="https://unsplash.com/@zlucerophoto?utm_source=medium&amp;utm_medium=referral">Zach Lucero</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’m stuck; I’ve no muse about what to write. I can’t find any idea. <br>Aha… the famous <a href="https://en.wikipedia.org/wiki/Writer&#39;s_block"><strong>writer’s block</strong></a>.</p><p>What do I do in those cases? From where does the inspiration to write about stuff come from? Where do I find ideas? How do I find the time?</p><p>Regarding the second, you <strong>make time</strong> — it is all a matter of prioritization. I’ve written about time management in the past, and those methods help me to focus.</p><p><a href="https://dvirsegal.medium.com/arrange-your-time-and-your-mind-will-follow-304ee0c99a29">Arrange your time and your mind will follow</a></p><p><strong>The ideas?</strong> come from various sources. I keep an extensive list of podcasts, newsletters, blogs, etc., which I follow to gain more knowledge or, as I call it, the quest for growth, more on that:</p><p><a href="https://dvirsegal.medium.com/in-the-quest-for-growth-material-8f9fbece9e97">In the quest for growth material</a></p><p>Besides that, I found ideas in unique places. I look for questions on Q&amp;A-based websites such <a href="https://softwareengineering.stackexchange.com/">softwareengineering.stackexchange</a>, <a href="https://workplace.stackexchange.com/">workplace.stackexchange</a> or <a href="https://www.quora.com/">quora</a>.</p><p>Sometimes I get ideas from my colleagues or people I follow on <a href="https://twitter.com/dvir_segal">Twitter</a>. Actually, Twitter is an interesting place to collect them; I tend to tweet my thoughts, and occasionally a debate might evolve; this can be a trigger to <a href="https://dvirsegal.medium.com/effort-estimation-its-complicated-8e1c77bf572c">blog</a> about.</p><p>Anyhow, whether it’s a blog, podcast, or any other source. First, I collect the subjects I think I’d like to write about on a dedicated <a href="https://www.notion.so/">Notion</a> page, a sort of ideas log. Afterward, I follow the method I wrote about here to sort it out:</p><p><a href="https://dvirsegal.medium.com/digital-notes-are-your-life-dashboard-e45ae64c64fc">Digital Notes are your life dashboard</a></p><p><strong>This means that whenever I feel like writing or creating, I already have an arsenal of ideas.</strong></p><p>So now I have a prioritized list, the fun part can begin. I pick the first item and start to research it online and collect the info on the subject’s page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QBL6-3AzNiiXVG2t2yIE1g.png" /><figcaption>My digital notebook of ideas</figcaption></figure><p>Once I feel ready I start writing, which is about the time I feel I consumed enough sources to write about the subject and express my opinion on it. Don’t get me wrong: research is critical, but sometimes, you just have to stop and start writing and see what happens.</p><p>The draft is ready? I read the whole thing repeatedly and then again 😂 and fix whatever doesn’t get along with my main narrative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*KwJoGUjBpXWWCv-p" /><figcaption>forget about it — <a href="https://i.pinimg.com/originals/46/30/6e/46306e05bf17e988dd217e529aa03646.jpg">src</a></figcaption></figure><p>Finally, I use <a href="https://app.grammarly.com/">Grammarly</a> to find any typos and grammar mistakes and if the sentences don’t fit the defined Grammarly goals. I usually pick an informal general audience with a casual domain. My writing style (intent) usually tells a story (as you might have noticed).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*Qx8P5WME1H3Nccbmn5eV7Q.png" /><figcaption>Grammarly goals setting</figcaption></figure><p>Lastly, the reviewers, a bunch of close friends, and colleagues happily read my drafts and share their inputs, and based on their feedback (loops), I’ll rewrite the final draft.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*ElaA7Zhqt7p7pOSG" /></figure><p>Basically, writing is all about reading and then more writing. As the old saying goes, “the only kind of writing is rewriting”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc98bb8d17d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>