<?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 Nikolai Nobadi on Medium]]></title>
        <description><![CDATA[Stories by Nikolai Nobadi on Medium]]></description>
        <link>https://medium.com/@nikolai.nobadi?source=rss-8afdd2a0f1b3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GAj0ICaOOKpU3oPwa7GxBQ.jpeg</url>
            <title>Stories by Nikolai Nobadi on Medium</title>
            <link>https://medium.com/@nikolai.nobadi?source=rss-8afdd2a0f1b3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:37:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikolai.nobadi/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[Integrating SwiftData into Standalone Swift Packages]]></title>
            <link>https://medium.com/@nikolai.nobadi/integrating-swiftdata-into-standalone-swift-packages-6cbcb45e5893?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cbcb45e5893</guid>
            <category><![CDATA[swift-package-manager]]></category>
            <category><![CDATA[macos-development]]></category>
            <category><![CDATA[command-line-tools]]></category>
            <category><![CDATA[swiftdata]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Thu, 27 Mar 2025 00:19:22 GMT</pubDate>
            <atom:updated>2025-03-27T03:35:25.155Z</atom:updated>
            <content:encoded><![CDATA[<h4>Overcome App Group, Bundle ID, and CI challenges to share databases between command-line tools and sandboxed macOS apps.</h4><figure><img alt="Cluttered workspace with code screens, coffee cups, and a “Tests Passed!” message." src="https://cdn-images-1.medium.com/max/512/1*Rjf5wKj35nl1ZXZgCX6zSQ.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><p>To share a database between a command-line tool and a sandboxed macOS app yet allow them each to operate independently of one another.</p><p>That’s all I wanted to do.</p><p>And I wanted to do it with SwiftData.</p><p>Because I’m stubborn like that.</p><p><em>I believe it’s called ‘hyper-focus.’</em></p><p>I get fixated on an idea and will spend all of my energy trying to find a solution.</p><p>I’m still trying to figure out if it’s a superpower or a giant character flaw.</p><p><em>Probably both.</em></p><p>Probably.</p><p>But it feels more like a superpower when I succeed. Which in this case, I did.</p><h3>Why SwiftData?</h3><p>Because reasons.</p><p>Let’s pretend they’re good so we can jump right into the tale of my eternal struggles with using SwiftData in a swift package.</p><h3>The First Obstacle: Sharing the database</h3><p>In order to publish a macOS app on the App Store, it has to be ‘sandboxed’.</p><p>Translation: the app is only allowed to play in its own little area unless you specifically give it permission otherwise.</p><p>And even then, there’s still quite a bit the app isn’t allowed to do.</p><p>Luckily, there’s a way to extend the app’s playground with AppGroups.</p><p>When using AppGroups, a special folder is created here:</p><blockquote>~/Library/Group Containers/&lt;appGroupId&gt;/</blockquote><p>Apps with the associated AppGroups entitlement can read/write to that folder without any permissions from the user, as it is treated as merely an extension to the sandbox.</p><p>I originally thought this meant my command-line tool would also have to include the AppGroups entitlement .</p><p>This doesn’t seem to be the case.</p><p>From what I can tell, the AppGroups entitlement is designed to grant sandboxed apps the ability to access a folder outside of their sandbox.</p><p><strong>Non-sandboxed apps and command-line tools</strong> appear to be unaffected either way.</p><p>So, all that was left to do was instantiate the SwiftData ModelConfiguration with the app group id I intended to share.</p><pre>let appGroupId = &quot;appGroupId&quot;<br>// force-unwrapped because nothing would work without it anyway<br>// but feel free to handle the error<br>let appGroupURL = FileManager.default(<br>    forSecurityApplicationGroupIdentifier: appGroupId<br>)!<br><br>// If this folder isn&#39;t already present, SwiftData will create it<br>// but it will output a bunch of errors in the console before<br>// to avoid this, I create it before instantiating the ModelContainer<br>let appSupportURL = appGroupURL<br>    .appendingPathComponent(&quot;Library&quot;, isDirectory: true)<br>    .appendingPathComponent(&quot;Application Support&quot;, isDirectory: true)<br>try FileManager.default.createDirectory(<br>    at: appSupportURL,<br>    withIntermediateDirectories: true<br>)<br><br>let config = ModelConfiguration(groupContainer: .identifier(appGroupId))<br>// force-unwrapped for the same reason<br>let container = try! ModelContainer(for: MyObject.self, configurations: config)<br>let modelContext = ModelContext(container)</pre><p>First obstacle solved!</p><p>But that was the easy one.</p><h3>Second Obstacle: Integrating SwiftData into Standalone Swift Packages</h3><p><em>That’s the name of the article!</em></p><p>It is.</p><p>With the emergence of Swift 6 and the influx of compiler warnings that accompanied it, I was sure that Xcode would have told me that SwiftData wouldn’t work in my swift package without having to run the executable to find out.</p><p>It did not.</p><p>And with a lack of compiler warnings, I confidently continued writing code until I finally decided to give it a little test.</p><p>I was greeted with this:</p><blockquote>SwiftData/DataStoreCoreData.swift:32: Fatal error: Unable to determine Bundle Name</blockquote><p><strong>Why?</strong></p><p>Why does SwiftData need a Bundle Name?</p><p>Well, even after solving the issue I still don’t know the exact reason, but I have my suspicions.</p><p>From what I can tell, SwiftData relies on a Bundle Name (and possibly a Bundle Identifier) to manage the objects declared with the @Modelmagic.</p><p><em>You mean MACRO?</em></p><p>I said what I meant.</p><p>SwiftData offers a fairly complex migration system without much boilerplate code. I’m guessing this information has to be stored somewhere in order to work, which is why a folder is created here:</p><blockquote>~/Library/Application Support/&lt;bundleName&gt;</blockquote><p>Is this in the documentation? I couldn’t find it.</p><p>But the fact remains that in order to use SwiftData, a Bundle Name is required.</p><p>Well that’s easy to solve, right?</p><p>Just pop an info.plist in the swift package and call it a day.</p><p>Nope.</p><p>More hours of agony ultimately led me to this <a href="https://developer.apple.com/forums/thread/734540">this Apple forum</a> that offered me the glorious solution.</p><p><strong>Unsafe Linker Settings.</strong></p><p><em>What makes them unsafe?</em></p><p>I don’t know.</p><p>But what I DO know is that it works.</p><p>Including this bit in the package manifest successfully sweet talks SwiftData into doing its thing in a standalone swift package.</p><pre>let package = Package(<br>    name: &quot;mytool&quot;,<br>    products: [<br>        .executable(name: &quot;mytool&quot;, targets: [&quot;mytool&quot;]),<br>    ],<br>    targets: [<br>        .executableTarget(<br>            name: &quot;nnex&quot;,<br>            dependencies: [],<br>            linkerSettings: [<br>                // this bit is the magic<br>                .unsafeFlags([<br>                    &quot;-Xlinker&quot;, &quot;-sectcreate&quot;,<br>                    &quot;-Xlinker&quot;, &quot;__TEXT&quot;,<br>                    &quot;-Xlinker&quot;, &quot;__info_plist&quot;,<br>                    // this is the location of my info.plist<br>                    &quot;-Xlinker&quot;, &quot;Resources/Info.plist&quot;<br>                ])<br>            ]<br>        )<br>    ]<br>)</pre><p>Second obstacle tackled!</p><p>Well, for the moment at least.</p><p>I still have more experiments to conduct regarding data migrations that affect a command-line tool and a sandboxed macOS app.</p><p>Does the bundle name and identifier need to be the same between each project?</p><p>Will SwiftData handle migrations properly when being used by different projects?</p><p>Will Apple stop hiding so much of their seemingly unproprietary code behind magical macros?</p><p>Only time will reveal the answers to these questions.</p><p>For now, there’s still one more obstacle to face.</p><h3>Third Obstacle: Continuous Integration (CI)</h3><p>I write tests for nearly all of my projects.</p><p>Yes, even my personal/hobby projects.</p><p>If you don’t know the value of a good test suite, <a href="https://medium.com/@nikolai.nobadi/beyond-a-working-app-the-case-for-a-comprehensive-test-suite-74ded95af24e">read this</a>.</p><p>And if you don’t feel like leaving me, don’t worry, you wouldn’t <em>really</em> be leaving me. That link just takes you to another article I wrote.</p><p>Anyway, regarding test suites, I believe they’re essential.</p><p>A good test suite will remain reliable after refactoring the codebase, and it’ll let you know when you introduce breaking changes.</p><p>The goal is a working product, after all.</p><p>If we can keep the product working after making changes, we still have a product.</p><p>And that’s where tests and <strong>continuous integration (CI)</strong> come into play.</p><p>(PS I finally started using the new <strong>Swift Testing</strong> framework and it is <strong>awesome</strong>).</p><p>Instead of just writing code, committing the changes, pushing them to our remote repository, and merging them with the main branch, we can use CI to ensure we’re not merging any broken code.</p><p>A CI workflow will run the test suites associated with the project and prevent the changes from being merged into the main branch.</p><p>A good thing, indeed.</p><p>I typically just use <strong>GitHub Actions</strong>, and while there are plenty of other CI/CD services, they all boil down to using command-line operations to perform various tasks.</p><p>Well, at least that’s true for iOS/macOS/swift-command-line projects, which is where my experience resides.</p><p>Running tests for a swift package from the command-line is quite easy.</p><p>swift test</p><p>Unfortunately, it doesn’t work in my very specific scenario.</p><blockquote>SwiftData/DataStoreCoreData.swift:32: Fatal error: Unable to determine Bundle Name</blockquote><p>Yes, that damn error returned to harass me yet again.</p><p>Which didn’t make sense because I already witnessed my swift package command-line tool in action, both on my developing computer and a random Mac Pro.</p><p>The swift test command was lying to my face.</p><p>I was sure of it.</p><p>I scoured the internet for another solution. Surely Apple forums wouldn’t fail me now.</p><p>But it did.</p><p>Hours of research and toil with no solution.</p><p>I didn’t understand.</p><p>Why did the swift package and its tests run just fine from Xcode, but not from the command-line? And why would the compiled binary work on other computers without any issues?</p><p>The answer seems so obvious when I think about it now.</p><p><strong>Xcode</strong> was the solution.</p><p>You see, when you run tests from Xcode, what’s really happening is a bunch of magic and unicorns frolicking around and…</p><p>Okay, I don’t know what’s happening. But whatever it is, it’s happening in an environment within Xcode.</p><p>Obvious, I know.</p><p>But it’s important to point that out because tests that are initiated with swift test are NOT in an Xcode environment.</p><p>They are in an environment provided by the <strong>Swift toolchain</strong>.</p><p>Swift Packages are designed to be lightweight, after all, so they typically don’t require all the baggage that’s associated with Xcode.</p><p>Using the Swift toolchain to run tests for a swift package causes said package to be built in a much smaller environment.</p><p>And apparently, there’s no room for something as inconsequential as an info.plist in that compact environment.</p><p>The result, of course, is expedited build times.</p><p>But what use is speed if the tradeoff is the exclusion of my info.plist hack to sweet talk SwiftData?</p><p>The solution is drop swift test for this:</p><p>xcodebuild test -scheme &lt;toolname&gt; -destination &#39;platform=macOS’ | xcpretty</p><p>One ugly line of code never looked so beautiful.</p><p>Piping the result through <strong>xcpretty</strong> isn’t necessary, of course. It just replaces the normally verbose output into something, well, pretty.</p><p>(I used -quiet initially, but that flag prevents me from seeing the results of the tests).</p><p>By using xcodebuild test instead of swift test, my info.plist was successfully passed to SwiftData, allowing my test suite to be run without any further issues.</p><h3>Victory is Mine!</h3><p>If you want to see the result of all of my efforts with your own eyes, feel free to check out (or ‘checkout’) my <a href="https://github.com/nikolainobadi/nnex">first public command-line tool: <strong>nnex</strong></a>.</p><p>It’s designed to streamline distributing other command-line tools via <strong>Homebrew</strong> (and the <strong>GitHub CLI</strong>).</p><p>For now, it only works for swift package executables, but I can expand it to support.xcodeproj or other project types if needed.</p><p>While I <em>do</em> think the tool itself is useful, I suspect most of its value may be as an example for how to use SwiftData outside of an iOS/macOS app.</p><p>Having said that, I acknowledge that my solutions are a bit of a hack. If anyone has any alternative solutions or knows any of the inner workings of SwiftData regarding the need/use for a Bundle Name, I’d happily welcome the feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cbcb45e5893" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Weight of Choice]]></title>
            <link>https://medium.com/@nikolai.nobadi/the-weight-of-choice-140ce6c8820b?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/140ce6c8820b</guid>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[decision-making]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[overthinking]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 22:37:57 GMT</pubDate>
            <atom:updated>2025-01-26T17:47:25.203Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring the Complexity of Decisions</h4><figure><img alt="A person standing on a balance scale surrounded by abstract swirling patterns and glowing paths, symbolizing the complexity of decision-making." src="https://cdn-images-1.medium.com/max/512/1*_8_53Id8d43NMRvY47BzOg.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><p>Choosing to do one thing means choosing NOT to do something else.</p><p>That’s why making decisions can feel daunting.</p><p>How can I be sure that what I choose to do is actually better than the alternatives?</p><p>I suppose one way to at least come close to knowing is to outline the pros and cons of each option.</p><p>If a path is followed, what would life look like in an hour? A day? A week? A year?</p><p>As nice as that sounds, it’s not always clear what will occur down the road of life.</p><p>And spending too much time deliberating on the potential outcomes of each possible option in every single decision can be debilitating.</p><p>Too much deliberation can lead to debilitation.</p><p>Deliberate. Debilitate.</p><p>Words are funny.</p><h4>Ever Noticed That ‘Thing’ Everywhere?</h4><p>If overthinking is a problem, should we aim to make decisions as quickly as possible with as little thought as possible?</p><p>Yo.</p><p>A combination of <em>yes</em> and <em>no</em>.</p><p>I mentioned the <em>reticular activating system</em> (RAS) in <a href="https://medium.com/@nikolai.nobadi/rum-bourbon-and-abstraction-coding-lessons-from-americas-revolutionary-spirits-40f14f6274a8">another article I wrote</a>, so it feels like I should probably explain it.</p><p><em>Actually,</em> I <em>was the one who mentioned it.</em></p><p>Yes. The random voice in my head, which is also me, is the one that mentioned it.</p><p>Anyway, RAS.</p><p>Have you ever purchased a unique item that you’ve never seen or haven’t seen much only to encounter dozens of other people with the exact same item?</p><p>How about walking into a crowded room and being unable to understand anything that is being said yet somehow can laser focus on a specific conversation once your name is uttered?</p><p>That’s the reticular activating system (RAS) at work.</p><p>It’s the phenomenon of increased awareness with regard to things that have been deemed <em>important</em> or <em>relevant</em>.</p><p>Before buying that unique item, it meant nothing to you. It was irrelevant, so it was reliably ignored by your brain.</p><p>After buying it, however, the item gained relevance, causing your brain to notice every instance of it.</p><p>While it certainly is possible that you’re a trend-setter, the more likely explanation is that buying the thing increased your awareness of the thing.</p><p>The brain is all about pattern recognition for the sake of survival.</p><p>Once exposed to meaningful information (like I own a unique item), the brain will increase awareness about the new information, allowing (or making) you take notice of the same or similar pieces of information.</p><p>This concept is responsible for the <em>gut feeling</em> that people describe when they are unable to express their reasoning behind certain decisions.</p><p><em>I thought that was the micro-biome…</em></p><p>Yo. Yes and no.</p><p>The infamous <em>second brain</em> that is our microbiome certainly has a role in gut feelings, but it isn’t solely responsible for those feelings.</p><p>It <em>is</em> a little crazy, though.</p><p>Not only do we have millions of bacteria just hanging out inside our bodies, but these very same bacteria actually have a certain degree of influence over the way we feel, and potentially, over the decisions we make.</p><p>Isn’t that weird?</p><h4>Snap Back to Reality</h4><p>Ope, there goes gravity, ope, there goes Rabbit…</p><p>No, back to <em>decisions</em>.</p><p><em>Mom’s spaghetti.</em></p><p>It’s always better to make decisions as quickly as possible, regardless of their importance.</p><p>If the decision is correct, then there’s no reason to fret.</p><p>If not, then better to find out sooner than later so you can rectify the mistake.</p><p>That only applies to reversible decisions, of course, which I suspect makes up the majority of decisions a person can make.</p><p>However, I’d also argue that rapid decision-making is best practiced when one has had adequate exposure to the circumstances to which the decision pertains, as well as at least a brief history of positive results.</p><blockquote>Consistency is only a virtue if you’re not a failure.</blockquote><p>Without the necessary experience, our brains (the organ and the bacteria hive-mind) cannot be trusted to deliver acceptable results.</p><p>A pattern can only be recognized if it has been seen before.</p><p>When encountering a decision where you lack sufficient experience, it may be best to invest some time in some careful deliberation to ensure a quality outcome.</p><p>Likewise, if only a history of failure (or negative outcomes) can be associated with the decision, it is safe to assume that the pattern recognized by your brains is one that will likely lead to more failure, thus an investment in extra deliberation may also be warranted.</p><p>But how much time should be allotted for deliberation with such decisions?</p><p>And what is the most effective way to deliberate?</p><p>Diapers.</p><p><em>Diapers?</em></p><p>Depends.</p><p>The potential costs of making the wrong decision should heavily influence the amount of time to deliberate, as well as the specific methods of deliberation.</p><p>Reversible decisions with low stakes? Act quickly.</p><p>Decisions with high stakes and/or irreversible decisions? Take it slow.</p><p><em>Kokomo.</em></p><p>And don’t be afraid to change your mind. If a better path reveals itself, make the change without hesitation.</p><blockquote>“No human being has sufficient foresight to build plans that need no alteration.” – Napoleon Hill, <em>The Law of Success</em></blockquote><h4>Practical Tips for Better Deliberation</h4><p>Here are strategies to help you deliberate effectively without getting stuck:</p><ul><li><strong>Absorb, Don’t Overload:</strong> Learn enough to feel confident. When the same information keeps repeating, it’s time to act.</li><li><strong>Flip the Coin Test:</strong> Not for the actual decision, but for clarity. When the coin is in the air, what outcome are you hoping for?</li><li><strong>Seek Neutral Advice:</strong> Share facts, not your feelings, and avoid biasing others toward your preferred outcome. Listen without arguing.</li><li><strong>Understand Your Emotions:</strong> Ask yourself why you feel a certain way. Your emotions might not always be rational, but they can still hold valuable clues.</li></ul><h4>The Final Thought</h4><p>Decisions don’t have to be perfect. They just have to be made.</p><p>When you have experience, trust your instincts. When you don’t, take time to gather the information you need.</p><p>What matters most is choosing to act, because purposeful action creates the life you want.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=140ce6c8820b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Truth, Lies, and the Codetender]]></title>
            <link>https://medium.com/@nikolai.nobadi/truth-lies-and-the-codetender-3caf74fff2ec?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3caf74fff2ec</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[bartending]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Tue, 14 Jan 2025 00:46:53 GMT</pubDate>
            <atom:updated>2025-01-20T20:00:03.471Z</atom:updated>
            <content:encoded><![CDATA[<h4>Lessons from Bartending and AI</h4><figure><img alt="Futuristic bartender station with a cocktail shaker, glass, and circuit board countertop, blending classic bar decor with glowing binary code and robotic arms." src="https://cdn-images-1.medium.com/max/1024/1*bdddWEEvJ-RiIXuyjWKOqg.png" /></figure><p>When the third version of ChatGPT first rolled out, it was mind-blowing.</p><p>Here was tangible proof of the infamous singularity that was destined to bring human civilization to the brink of extinction.</p><p>It was impressive.</p><p>It still <strong>is</strong> impressive.</p><p>But as someone who has worked extensively with ChatGPT every week for the last few years, let me just say that it certainly lives up to the <em>artificial</em> aspect of <strong>Artificial Intelligence</strong>.</p><p>It’s imitation crab meat.</p><p>It may fool the inexperienced, but it is obviously not the real thing.</p><p>At least not yet.</p><p>It solves problems inefficiently at times.</p><p>It struggles to make obvious connections between seemingly unrelated concepts at times.</p><p>And it <strong>lies</strong>. Oh boy, does it lie.</p><p><em>Are you describing AI or humans?</em></p><p>Wow.</p><p>I guess AI isn’t so different from us humans after all.</p><p>Still, it’s not the grim reaper of human society that’s often depicted in movies.</p><p>The main thing AI is going to do is create an even blurrier line between fiction and reality.</p><p>Once AI has been fully integrated into our society, will we ever be able to trust any source of information ever again?</p><p>Probably not, but that’s nothing new.</p><p>The truth has always been a slippery slope, even before the advent of AI.</p><p>Yes, AI is making the waters even murkier, but history shows that humans have been blurring lines for centuries.</p><h4>Story Time</h4><p>Before the early 1800s, American establishments selling alcohol were required by law to provide patrons with food and lodging.</p><p>But in 1832, Congress passed the <strong>Pioneer Inn and Tavern Law</strong>, freeing these establishments to sell alcohol without the additional services and marking the official birth of the <strong>bar</strong>.</p><p>And, by extension, the <strong>bartender</strong>.</p><p>As the leader of the <em>local watering hole</em>, bartenders held a prestigious role in society.</p><p>They didn’t just mix drinks.</p><p>They were craftsmen, advisors, and entertainers, curating experiences for their thirsty patrons.</p><p>Then came <strong>Prohibition</strong>.</p><p>For 13 miserable years, the craft was driven underground, transforming the once-prestigious bartender into a criminal forced to work in illegal speakeasies (the replacement for bars during those dark times).</p><p>When Prohibition ended, the industry struggled to recover its former glory.</p><p>To make matters worse, pre-mixed concoctions were introduced to the scene, further tarnishing the reputation of the bartender and kicking off the <em>Kool-Aid</em> era of bartending.</p><p>That narrative certainly makes for a compelling origin story for bartenders, but it’s not entirely true.</p><p>Prohibition was real, as were pre-mixed drink mixers, but what about the <em>Pioneer Inn and Tavern Law</em>?</p><h4>Debunking the Myth</h4><p>I first learned this questionable ‘truth’ in 2012 when I read a book called <em>The Craft of the Cocktail</em> by Dale Degroff.</p><p>I actually learned quite a bit from that book, but I never considered any of the information fraudulent.</p><p>Fast forward to the end of 2024.</p><p>I decided waiting until the new year to pick up my writing habit was silly, so I started writing again.</p><p>And for some reason, I decided to blend alcohol and coding.</p><p>Not literally, of course. Just the concepts.</p><p>So I whipped out the notes I took when I read Mr. Degroff’s book and did some brainstorming.</p><p><em>Do you take notes on </em><strong><em>all</em></strong><em> of the books you read?</em></p><p>Do you <em>not</em>?</p><p><em>…</em></p><p>Anyway, I saw a reference to the <em>Pioneer Inn and Tavern Law</em> and decided to ask my good buddy <em>Helix</em> for some intel on the topic.</p><p>Oh, and <em>Helix</em> is the name I gave ChatGPT, mainly because <em>ChatGPT</em> is annoying to say. And annoying to type out.</p><p>But Helix (ChatGPT) said he didn’t know anything about the <em>Pioneer Inn and Tavern Law</em>.</p><p>So I told him to look it up.</p><p>He said he couldn’t find it.</p><p>I sighed, slightly annoyed at the blatant lie, and did a quick internet search for an article explaining the law and presented it to Helix (ChatGPT).</p><p>Helix thanked me for the information, but then he called it fiction.</p><p>I didn’t be<strong>LIE</strong>ve him, of course, but I needed to prove it.</p><p>Since the quick search didn’t reveal much more than a few unofficial articles, I did a bit more research into the 22nd United States Congress (the one from 1832).</p><p>Imagine my surprise when I couldn’t find a single reference to the <em>Pioneer Inn and Tavern Law</em>.</p><p>It was a myth. A lie.</p><p>Not created by AI, but by humans.</p><h4>From Bartenders to Codetenders</h4><p>Full disclosure, I didn’t exactly perform a comprehensive analysis of the 22nd Congress, so the verdict is still up in the air, but the lack of readily available information was intriguing.</p><p>Whether the law existed or not doesn’t matter, as its validity has no bearing on my day-to-day life.</p><p>However, this situation was a reminder that history, like technology, is often shaped by myths and half-truths.</p><p>Bartenders were once revered as craftsmen. They balanced flavors, guided patrons through unique experiences, and created works of art in a glass.</p><p>Prohibition and the rise of pre-mixed concoctions diluted their craft, reducing bartenders to little more than drink dispensers.</p><p>It took decades for the industry to reclaim its prestige.</p><p>Modern developers face a similar challenge.</p><p>With the rise of AI, low-effort solutions threaten to erode the standards of our craft.</p><p>Just as bartenders fought to reclaim their prestige, codetenders must ensure their work maintains integrity in a world where quick fixes are often prioritized over quality.</p><h4>The Final Toast</h4><p>AI isn’t the enemy. It’s merely a new tool to be harnessed.</p><p>As codetenders, we must take pride in our craft, striving to create products that are not only functional, but also elegant and enduring.</p><p>We must embrace continuous learning, stay vigilant in upholding quality, and prioritize thoughtful designs over shortcuts.</p><p>AI will continue to evolve, offering even more powerful tools, but its value will always depend on the skill and intention of those who wield it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3caf74fff2ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rum, Bourbon, and Abstraction: Coding Lessons from America’s Revolutionary Spirits]]></title>
            <link>https://medium.com/@nikolai.nobadi/rum-bourbon-and-abstraction-coding-lessons-from-americas-revolutionary-spirits-40f14f6274a8?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/40f14f6274a8</guid>
            <category><![CDATA[alcohol]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[abstraction]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 23:35:19 GMT</pubDate>
            <atom:updated>2025-01-07T01:27:07.277Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Revolutionary Spirits: Coding Lessons from Rum and Bourbon</strong></h3><h4>How distillation, reusability, and loose coupling shaped both early America and better software.</h4><figure><img alt="Glass of bourbon on a table with a laptop displaying code, set against a background of vintage American elements like a parchment and quill." src="https://cdn-images-1.medium.com/max/512/1*FlhdLQHF8KshkSbcFPOYUA.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><p>Another article about alcohol and coding.</p><p>I promise I’m not an alcoholic. There’s just so many interesting comparisons between the two major industries I’ve worked in.</p><p><em>Sounds more like hindsight and the reticular activating system.</em></p><p>Nobadi knows what that means.</p><p><em>Ahhh… I see what you did there.</em></p><p>Moving on.</p><p>Love it or hate it, alcohol has played a major role in the development of human civilization.</p><p>From including a bit of wine in water to kill any lingering bacteria to kickstarting the American Revolution, alcohol has been there-</p><p><em>How did alcohol start the American Revolution? What about the Boston Tea Party?</em></p><p>Tea was just the excuse. Alcohol was the motive.</p><h4>Story Time</h4><p>Before encapsulating their society with the creation of America, colonists kept themselves busy with what they thought was a little harmless refactoring.</p><p>Back in those days, sugar was a key feature in Western exports, specifically in the Caribbean.</p><p>For those unfamiliar with sugar’s development cycle, here’s a quick summary.</p><p>Sugar starts out as a tropical grass.</p><p>Once cut down and gathered, it is refined into the familiar crystals that sweeten things.</p><p><em>How exactly is it refined?</em></p><p>Unimportant for this story, but you can check out the <a href="https://www.youtube.com/watch?v=EP_fgp7zYKk&amp;t=98s">documentation at your leisure.</a></p><p>What <em>is</em> important are the number of variables returned from the refining method.</p><p>There’s two: sugar and molasses.</p><p>While sugar has a number of uses, like <a href="https://medium.com/@nikolai.nobadi/coding-like-a-classic-cocktail-8078950d4f15">mixing in the perfect ratio to make gomme syrup for an Old Fashioned</a>, molasses is just a by-product of the refinement process.</p><p>And it looks kind of gross (it’s a brownish syrup).</p><p>Rather than simply discarding the questionable substance, colonists found a way to make it conform to the Distillable protocol.</p><p><em>Is that supposed to be a joke?</em></p><p>Of course not, jokes are funny. I was being serious.</p><p>In order to extract alcohol from a substance, it must be <em>distilled</em>, which can be done with a <em>still</em>.</p><p>Colonists swapped out their usual ingredients for molasses and distilled away.</p><p>The result?</p><p><em>Captain Jack Sparrow!</em></p><p>No.</p><p>Well… Kinda.</p><p>The real answer is <strong>rum</strong>, and despite Captain Jack’s complaints, the rum was certainly NOT always gone during this period of pre-American history.</p><p>In fact, by 1733 rum surpassed all other exports from the colonies.</p><p>Unfortunately, this attracted some not-so-good attention from the British, who were losing their market share of alcohol in the colonies. So it wasn’t long before-</p><p>BOOM!</p><p>Britain hits the soon-to-be-Americans with the Molasses Act, forcing colonists to pay a hefty tax on non-British molasses.</p><p>This was later accompanied by the Sugar Act, then the Stamp Act, then…</p><p>Well, then it was time to do some major refactoring to the colonial society.</p><p>After one of the most successful stand-up meetings in American history, the Declaration of Independence became the ultimate ticket, setting a sprint for revolution in motion until the United States was ready to launch.</p><p>While they successfully managed to deploy their own country, the founding devs had quite a bit of technical debt to manage after the war.</p><p>SECOND BOOM!</p><p>Alexander Hamilton slapped the public with a federal excise tax on rum and other spirits.</p><p>But it was okay, because <em>this</em> taxation had proper representation.</p><p>What <em>wasn’t</em> okay was the British and their absurd pull request in 1812.</p><p><em>You’re reaching a bit with these analogies.</em></p><p>Meh, coders will understand.</p><p>In an effort to ensure America didn’t provide aid to France, whom the British were fighting in 1812, the red coats decided to block American trade to the Caribbean (which was owned by France at the time).</p><p>But that’s where sugar came from, and no sugar meant no molasses, and no molasses meant no rum, and no rum meant unbearably sober evenings.</p><p><em>Why is the rum always gone?</em></p><p>It doesn’t matter.</p><p>The production of alcohol doesn’t depend on a concrete type like molasses, remember? It depends on an abstraction.</p><p>Any Distillable object can be passed to the method that produces alcohol.</p><p>The early American devs knew this. So when molasses was unavailable, they turned to something more abundant and more local: corn.</p><p>In what I assume was meant to be a jab at the British, they named this new corn whiskey <strong>Bourbon</strong> in honor of the French.</p><h4>Lessons Learned</h4><p>Okay, that story was a bit longer than I expected, but it holds some interesting parallels to coding.</p><h4>Refactoring and Encapsulation</h4><p>The creation/formation of America highlights the importance of breaking down complex systems into smaller, more manageable components.</p><p>As a single societal repository, Britain and the colonies proved too much for any one government to properly manage. Dependencies became tangled, communication bottlenecks arose, and priorities clashed.</p><p>Classic symptoms of a monolithic architecture.</p><p>By transitioning to a modular system, where each state operated as an independent component within a larger, independent framework, the newly formed United States gained flexibility, scalability, and maintainability.</p><p>In software, a modular project offers the same advantages.</p><p>Each component handles a specific responsibility, reducing the risk of one failure cascading through the entire system.</p><p>This allows for isolated updates, easier debugging, and the ability to replace or upgrade parts without overhauling the entire codebase.</p><h4>Reusability</h4><p>The creation of rum demonstrates the importance of reusable code.</p><p>By utilizing the by-product of a completely unrelated process (sugar refinement), colonists were able to reap huge profits by simply repurposing the molasses to fit into their current project of distillation.</p><p>This is a concept I try to emulate each time I learn some new technique or framework.</p><p>Most code can be reused in a variety of projects if they can be made generic enough, which (most of the time) doesn’t take much more effort than it does to implement into a specific project, granted you know what you’re doing.</p><p>I admit, this takes a bit of practice, but it certainly pays off in dividends later when you can simply rely on your own custom interface instead of having to re-learn that obscure framework you only use once every few months.</p><h4>Dependency Injection and Loose Coupling</h4><p>The colonists were able to swap out the molasses for corn because neither substance was <em>hard-coded</em> into the distillation process.</p><p>If a substance can be distilled, then it can be injected into the distillation process and used to make alcohol.</p><p>In other words, there is a loose-coupling between the still and the distillable ingredient.</p><p>Unfortunately, this concept is often not as obvious in code as it is in real life.</p><p>Too often, developers tightly couple frameworks with their apps, making it nearly impossible to swap one for another without a complete overhaul.</p><p>This is like building a still that only works with molasses. When the supply runs out, you’re stuck.</p><p>It doesn’t matter if you never anticipate the need to change frameworks, the possibility that such a change will become a necessity is very real.</p><p>We’re talking about software development, after all. The products we build are destined to constantly be changing.</p><p>By designing systems with abstractions and protocols, you can create a process as flexible as distillation: one where the ingredient is interchangeable, and the framework can adapt to new requirements without breaking everything else.</p><h4>The Final Toast</h4><p>Alcohol has undeniably shaped history, just as good design principles shape the future of software.</p><p>But there’s more to the story of alcohol and coding.</p><p>Just as bartenders became the stewards of cocktails, guiding patrons through the experience of great drinks, developers have a similar role in shaping user experiences.</p><p>Next time, we’ll explore the rise of bartenders, their societal prestige, and their eventual dilution.</p><p>Developers might not be slinging cocktails, but as AI creeps into the craft, will the <em>codetender</em> suffer a similar fall from grace?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40f14f6274a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mixing Code Like a Cocktail]]></title>
            <link>https://medium.com/@nikolai.nobadi/mixing-code-like-a-cocktail-2bb3e8331766?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bb3e8331766</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cocktails]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[app-design]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Tue, 31 Dec 2024 03:15:06 GMT</pubDate>
            <atom:updated>2024-12-31T03:37:59.406Z</atom:updated>
            <content:encoded><![CDATA[<h4>Lessons from an Old Fashioned on frameworks, polish, and maintainability.</h4><figure><img alt="An empty rocks glass on a wooden desk, with a blurred laptop displaying code and a mouse in the background, lit by warm ambient lighting." src="https://cdn-images-1.medium.com/max/896/1*--DzibkrxygMCVNzLNBvFQ.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><p>I’ve almost been an iOS developer for as many years as I was a bartender, so it felt natural to blend the two topics. Despite having tended bars for almost a decade, I’m not really a big drinker. However, when I find myself out with friends, I’ll typically order an Old Fashioned.</p><p><em>That’s the drink from your last article!</em></p><p>It is.</p><p>I started this comparison venture into <a href="https://medium.com/@nikolai.nobadi/coding-like-a-classic-cocktail-8078950d4f15">cocktails and coding</a> by outlining my preferences for using gomme (rhymes with ‘home’) syrup in my Old Fashioned instead of the traditional sugar cube, but I didn’t talk much about the other ingredients.</p><p><em>Nor about much coding.</em></p><p>Well, allow me to elaborate on both counts.</p><h4>The Balancing Act</h4><p>Here’s my preferred Old Fashioned recipe:</p><ul><li>2 oz rye (Rittenhouse for a bolder flavor, Bulleit or High West for a smoother one)</li><li>1/4 oz gomme syrup</li><li>2–3 dashes Angostura bitters</li><li>1 giant ice cube (2x2 inches)</li><li>Orange peel garnish</li></ul><p>I’ve already covered the sugar.</p><p>I also mentioned my preference for rye but didn’t explain why.</p><p>Rye whiskey has a spicier, earthier flavor than bourbon, which typically runs on the sweeter side. Since gomme syrup already handles the sweetness, using bourbon could offset the balance.</p><p>By using rye, the gomme syrup remains the single source of truth for sweetness in the Old Fashioned rather than splitting the responsibility between two ingredients.</p><p>Viewed from this light, choosing the right type of whiskey for an Old Fashioned is a lot like choosing the right framework to depend on in an app.</p><p>Even if two frameworks offer similar functionality, one may prove better suited for specific types of apps.</p><p>In most of my iOS apps, I usually rely on Firebase Firestore for data persistence.</p><p>However, SwiftData has come a long way since its inception, and while <a href="https://medium.com/@nikolai.nobadi/swiftdata-and-the-mystery-of-cascading-deletes-270530ca3b0c">it still has a few problems of its own</a>, it has the potential to contend with Firebase.</p><p>Under the proper circumstances, of course.</p><p>If you need cross-platform support and/or real-time data sharing, Firebase is a clear winner.</p><p>If, on the other hand, you’re only releasing on Apple devices and real-time updates aren’t a concern, SwiftData might be simpler to integrate for SwiftUI apps.</p><p>There are, of course, plenty of other options when it comes to data persistence, but the concept remains the same.</p><p>The choice you make will have an effect on the quality of the final product, whether it’s the type of whiskey in an Old Fashioned or the type of framework in an app.</p><h4>The Bitters</h4><p>I’ll admit, when compared to the other ingredients, my knowledge of bitters is a bit lacking. But that shouldn’t be a problem.</p><p>Bitters are super concentrated flavor extracts made from roots, barks, herbs, and spices. While they were first invented for medicinal purposes, they eventually made their way into the recipe for many alcoholic beverages.</p><p>When and how this happened is still a mystery to me.</p><p>The one I use, Angostura bitters, is one of the more popular brands and can be found in most bars across the United States.</p><p>I’m going to be honest. You can still make a decent Old Fashioned without adding bitters, especially if you use rye.</p><p>But excluding them will leave a noticeable difference.</p><p>Remember, making a drink is all about balance.</p><p>While spice from the right rye whiskey could offer some balance to the sweetness of the gomme, the absence of those 2–3 dashes of bitters will reduce the overall complexity of the drink.</p><p>Less complexity may be a good thing in software development, but not for cocktails.</p><p><em>Aren’t you supposed to be showing the similarities between cocktails and coding, not the differences?</em></p><p>Adding bitters to an Old Fashioned can be likened to including haptics or polished transitions to an app. They’re not strictly necessary, but they elevate the overall user experience.</p><p>As long as you don’t overdo it, of course.</p><p>Too many fancy transitions can be just as distracting as too much bitters in a cocktail, and both can ruin the final product.</p><h4>Ice Ice… Infant</h4><p>Ice might seem like an afterthought, but it’s a critical component in many cocktails.</p><p>Especially the Old Fashioned.</p><p>Anyone who has ever sipped straight alcohol knows it burns.</p><p>The addition of ice softens that burn, and as it melts, unlocks the subtler nuances of the spirit.</p><p>The goal is to use the type of ice that will offer the best chill and dilution rate to match the cocktail.</p><p>For an Old Fashioned, you want slow dilution so the integrity of the drink remains intact for as long as possible. That’s why a single large 2x2-inch ice cube (or sphere) is ideal. It chills the drink without watering it down too quickly.</p><p>Colder and more diluted drinks weaken the taste of the alcohol, and by extension, diminish its flavor profile.</p><p>That’s why people who order vodka martinis want them shaken.</p><p>Most vodkas have no flavor. They’re just alcohol.</p><p>To avoid the terrible taste, they opt for a drink that resembles more of a slushy than a martini.</p><p><em>Didn’t James Bond order his martinis shaken, not stirred?</em></p><p>Bond’s drink of choice wasn’t a martini. It was a Vesper. And he specifically ordered his ‘Vesper-slushy’ to combat the low quality alcohol that he anticipated receiving from the questionable establishments he visited during his missions.</p><p>I digress.</p><p>The takeaway here is to understand the impact ice will have on the length of time the integrity of the cocktail can be maintained once it has been served.</p><p>When viewed from the lens of a developer, this relates to the maintainability of an app.</p><p>An app might work fine if the code is just slopped into a single file or module, but how long will it take for a bottleneck to reveal itself?</p><p>Even if the code is adequately organized, if the specific architecture that was implemented doesn’t match the underlying design of the app, modifications can be more difficult than they need to be.</p><p>This can also relate to the type of test cases in an apps test suite.</p><p>Writing tests can take a long time. And they often end up being more lines than the actual code.</p><p>For this reason, it would be much better to have tests that don’t require much upkeep to deliver the same value (which is to allow developers to refactor with confidence).</p><p>Brittle test cases are like those little moon-shaped ice cubes. They may work in the beginning, but they ‘melt too quickly’, so to speak. They have no resistance to changes, so even small modifications to the codebase end up triggering failures even if the underlying functionality of the app remains intact.</p><p>By contrast, test cases that resemble the giant ice cube can be relied on to ensure the integrity of the lines of code they cover.</p><h4>The Finishing Touch</h4><p>The final ingredient of the Old Fashioned is the garnish, which is the orange peel in my recipe.</p><p>This is more than the proverbial ‘cherry on top’.</p><p>At the very least, spritzing the oils of an orange peel over the drink, then rubbing the rind of the peel on the rim of the glass before dropping it in sets the stage for the entire experience.</p><p>The small hints of citrus offer an aroma that prepares the senses for the onslaught of flavor complexity the drink has to offer even before the first sip.</p><p>Beyond that, the very act of adding the garnish can turn a boring drink into an exciting spectacle.</p><p>When there was time (so not when it was super busy), I would hold the peel over the flame of a match, gently caramelizing its oils before spritzing them over the flame and into the drink.</p><p>The result was a small burst of fire that not only caught the eye of anyone at the bar, but also added subtle smokiness to the citrus.</p><p>In either case, the orange peel serves to introduce the drinker to the cocktail.</p><p>This can easily be compared to the onboarding experience of an app.</p><p>While including a certain degree of showmanship can work well to catch the eye of prospective users, the primary goal should be to provide a proper introduction to the app.</p><p>A poor onboarding can act more like a roadblock, preventing users from ever experiencing what an app has to offer.</p><p>The worst examples of this are those ‘free’ apps that immediately block access to the rest of the app with a paywall.</p><p>You’re not offering a free app at that point, so just set the price at installation.</p><p><em>May the socks of the developers of such apps always fall down.</em></p><p>Amen.</p><h4>Putting It All Together</h4><p>Even with the perfect ingredients, it’s still possible to ruin an Old Fashioned, or any drink for that matter.</p><p>The sequence matters.</p><p>As this article is already quite long, just remember to add the alcohol last.</p><p>Why, you ask?</p><p>So you don’t have to throw away alcohol if you mess up the recipe.</p><p>When coding, I typically implement a sort of skeleton of the basic features without ever having to add any of the actual dependencies.</p><p>This allows me to get a feel for the general flow of the app without having to make the commitment of integrating potentially complex dependencies.</p><p>Restructuring code is a lot easier with fewer dependencies.</p><h4>A Final Toast</h4><p>Just like an Old Fashioned, great apps require care and intentionality.</p><p>The right balance of ingredients, the patience to refine the process, and a thoughtful finishing touch can elevate the result from functional to truly memorable.</p><p>Whether it’s an app or a cocktail, aim for elegance and simplicity, but don’t forget to add your personal flair. After all, the best products are the ones that leave an impression, long after the last sip (or tap).</p><p>So here’s to you, dear reader. May your apps run smoothly, your drinks flow perfectly, and your socks never fall down.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bb3e8331766" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Like a Classic Cocktail]]></title>
            <link>https://medium.com/@nikolai.nobadi/coding-like-a-classic-cocktail-8078950d4f15?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8078950d4f15</guid>
            <category><![CDATA[cocktails]]></category>
            <category><![CDATA[coding-practice]]></category>
            <category><![CDATA[craftsmanship]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Mon, 23 Dec 2024 23:48:20 GMT</pubDate>
            <atom:updated>2024-12-24T00:01:28.847Z</atom:updated>
            <content:encoded><![CDATA[<h4>What crafting an Old Fashioned can teach us about balance and overhead in software</h4><figure><img alt="Glass of whiskey with a single ice cube beside a laptop on a wooden table." src="https://cdn-images-1.medium.com/max/512/1*G17ArxICVkLbYbZY2qbJEQ.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><p>Writing code is a lot like making a cocktail.</p><p>Technically anyone can do it, but not everyone can do it well.</p><p>And for the most part, you can’t really know the skill of the person until after they have produced something. Even then it still may not be immediately apparent.</p><p>A cocktail, for example, can look beautiful yet still taste like cough medicine, just as an app can feature a beautiful UI design while its codebase is an unmaintainable mess.</p><p>Interestingly enough, there are people in this world who don’t seem to find a problem in either case.</p><p>Some simply don’t know any better, which is understandable considering the subtle nuances within each industry, but others just don’t care.</p><p>If the only reason to drink is to catch a quick buzz, after all, who cares what it tastes like?</p><p>And if a working app is all that matters, who cares how it’s written?</p><p>My response to such barbaric questions is to counter them with a few inquiries of my own.</p><p>If you’re going to drink, wouldn’t you rather enjoy the entire experience?</p><p>And if building a working app is your goal, wouldn’t you prefer a codebase that’s both easy to read and easy to modify?</p><p>Such goals require a bit more effort. But whether you’re mixing drinks or writing code, the results are worth it.</p><h4>To follow tradition or not… That is the question</h4><p>I’m typically not a fan of traditions as I find that they tend to promote drone-like behavior in those that follow them.</p><p>But sometimes the classic approach ends up being the pragmatic one.</p><p>Take the Old Fashioned, for example. An icon among classic cocktails.</p><p><em>What’s an Old Fashioned Cocktail?</em></p><p>It’s just called an ‘Old Fashioned’, and its name is derived from the first official definition of the term <em>cocktail</em> from way back in 1806.</p><blockquote>a spirit of any kind, sugar, water, and bitters.</blockquote><p>The word <em>spirit</em> is just jargon for alcohol, as the process to distill (or create) alcohol is to extract the essence, or spirit, from a base substance.</p><p>The ingredients of an Old Fashioned are an exact reflection of those found in that first cocktail definition: whiskey (spirit), ice (water), sugar, and bitters.</p><p>And an orange peel to garnish.</p><p><em>That sounds fairly simple.</em></p><p>It is. Anyone can make one.</p><p>But… not everyone can make a good one.</p><p>You see, while the list of ingredients in an Old Fashioned is relatively short, the quality of those ingredients remains quite important.</p><p>The wrong whiskey will all but ruin the cocktail, but so will the wrong type of ice. And don’t even get me started on the choice of sugar.</p><p>Actually, people need to hear this.</p><h4>It’s all about that Gomme</h4><p>Purists often claim that the only correct way to make an Old Fashioned is by first muddling a sugar cube with a few drops of bitters.</p><p>(Muddling == gentle smashing.)</p><p>I disagree. Here’s why.</p><p>Sugar cubes create unnecessary overhead. After muddling them and adding the whiskey, you have to stir the mixture until the sugar dissolves.</p><p>This can take some time. Like a couple of minutes, which is quite a long time in the world of bartending.</p><p>And if you don’t stir long enough, the drink remains infected with undissolved sugar granules, which alters the balance of the drink.</p><p>Of course, some drinkers actually like the sensation of crunching on the residual sugar with every sip, and they are entitled to such preferences.</p><p>I simply prefer more balance in my cocktails.</p><p>Enter <strong>gomme syrup</strong>, a simple mixture of sugar and water with a 3 to 1 ratio that creates a velvety-sweet concoction.</p><p>That’s 3 parts sugar to 1 part water.</p><p>Using gomme syrup eliminates the need for prolonged stirring while ensuring every sip is smooth and balanced.</p><p>It’s like choosing efficient, reusable code over repetitive, error-prone workarounds.</p><p>This requires a bit more preparation to use than the sugar cube, of course, but the upfront preparation saves time in development by requiring much less work to fully integrate into the final product.</p><p>And there’s no risk of any lingering bugs in production.</p><p><em>You mean no lingering sugar in the drink?</em></p><p>Yeah, that too.</p><p>I’d be just as embarrassed to serve a drink with sugar granules littered at the bottom of the glass as I’d be to release an app that’s riddled with bugs.</p><p><em>You’ve done that second option, though.</em></p><p>Quite a few times, yes.</p><p>But it never took me long to rectify those tiny errors.</p><p>And that’s why I said writing code ‘is a lot like making a drink’ instead of claiming the two activities are the same.</p><p>Writing code is much more complex than stirring (or shaking) a few ingredients together, after all.</p><p>Luckily for us developers, it’s also a lot easier to fix our mistakes after they’ve made it to production.</p><p>You can’t fix a cocktail after a customer already started drinking it.</p><p><em>Well, technically you can…</em></p><p>That’s a little sloppy. Better to just make them a new drink.</p><p>But there’s nothing wrong with patching a few bugs after a user has already interacted with the app.</p><p>So I guess you could say software is like a class while a cocktail is like a struct.</p><p>You know… Because structs are immutable.</p><p>And classes aren’t.</p><p>It’s a joke. A Swift joke.</p><p><em>No, dude. Jokes are funny.</em></p><p>And this article is getting a little long.</p><p>In summation, I’d like to emphasize the importance of choosing gomme syrup rather than sugar cubes while coding.</p><p>Metaphorically speaking, of course.</p><p>In development, overhead is unavoidable. But we often have the power to <strong>decide</strong> where that overhead will <strong>reside</strong>.</p><p>(Don’t worry, I’m not going to start rapping after that rhyme. Just know that I could)</p><p>If a custom solution saves time during development, it’s your gomme syrup, an upfront cost that pays dividends later.</p><p>If it adds complexity without clear benefits, consider it more like your whiskey. You don’t need to make your own, use one someone else created, just make sure you choose the right one for your product.</p><p><em>And the metaphorical sugar cube?</em></p><p>Sugar cubes are for horses, not for cocktails.</p><p>And certainly not for code.</p><p>But there’s more to crafting the ideal cocktail than sugar and whiskey (especially since I didn’t even mention the type of whiskey that goes best in an Old Fashioned. Spoiler, it’s rye).</p><p>Small details make all the difference in both cocktails and coding.</p><p>Choosing the right tools, applying enhancements in moderation, and finishing with care are all critical for creating something elegant and functional.</p><p>I’ll touch on these topics more next time.</p><p>And yes, I’ll also include my own recipe for the ideal Old Fashioned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8078950d4f15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SwiftData and the Mystery of Cascading Deletes]]></title>
            <link>https://medium.com/@nikolai.nobadi/swiftdata-and-the-mystery-of-cascading-deletes-270530ca3b0c?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/270530ca3b0c</guid>
            <category><![CDATA[data-persistence]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[swiftdata]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 22:38:45 GMT</pubDate>
            <atom:updated>2024-11-25T22:38:45.608Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why Your Delete Rules Don’t Always Work</h4><figure><img alt="A minimalist illustration of a digital trash bin with cascading arrows, symbolizing data persistence and delete rules." src="https://cdn-images-1.medium.com/max/512/1*utSHpAYLjFH-7Y7hXmx7CQ.png" /><figcaption>Image generated by ChatGPT.</figcaption></figure><p>I’m an iOS developer.</p><p>I own an iPhone, an iPad, a Mac studio, a Mac pro, and… Well, I lost my apple watch, but you get the point. I’m an Apple guy.</p><p>But when it comes to data persistence and real-time sharing, I often turn to Firebase Firestore.</p><p>It’s simple, reliable, and fits most of my needs.</p><p>However, recently, I’ve been diving deeper into relational databases.</p><p><em>Doesn’t Apple offer a framework for that?</em></p><p>Yes, Core Data is Apple’s way of interacting with a relational database, and the newer SwiftData is a SwiftUI-friendly wrapper around Core Data.</p><p><em>You love SwiftUI!</em></p><p>I do. So rather than simply using a third-party tool for my relational database needs, I figured I’d try out the native solution.</p><p>I mean, I’m all about native development when it comes to cross-platform projects, so why not use native frameworks?</p><p><em>Because they don’t always work?</em></p><p>Because they don’t always work. At least not as expected.</p><h4>The Situation</h4><p>SwiftUI relies heavily on property wrappers and macros to do what it does.</p><p><em>You mean magic?</em></p><p>David Blaine magic.</p><p>And SwiftData is no different.</p><p>This magic certainly makes things easier. But it’s magic. And only magicians know how magic works.</p><p>Luckily, the magicians at Apple provided an explanation to understand the magic of SwiftData.</p><p>Want to create a data model for persistence? Just make it a class and slap the @Model annotation on top and you’re good to go.</p><p>Want to set up the persistent container so you can save your data?</p><p><em>What even is that?</em></p><p>It doesn’t matter, because it’s as easy as adding a single view modifier to your app.</p><p><em>No, seriously, what’s a persistent container?</em></p><p>It’s… not what I’m trying to explain right now. I’m trying to get to the <strong>situation</strong>…</p><p>…</p><p>Ugh, okay fine. But after this it’s straight back to the <strong>situation</strong>.</p><h4>SideNote: SwiftData’s Persistent Container</h4><p>When we want to save data to access later, we use a database.</p><p>If data is money, a database is the bank.</p><p>Remember me mentioning Firebase Firestore? That’s a <strong>document-based NoSQL</strong> database.</p><p>SwiftData uses a <strong>relational database. SQL.</strong></p><p><em>And SQL means…?</em></p><p>Structured Query Language.</p><p>It is both the name of the language used in the database as well as the database itself.</p><p>It’s just a bunch of tables with a specific way to access the data in those tables. If you’ve ever seen a spreadsheet, it’s kind of like that, just more complex.</p><p>Now, setting up an SQL database takes a bit of effort. And interacting with an SQL database requires its specific language (SQL).</p><p><em>Who has time for all that?</em></p><p>That’s where SwiftData is supposed to swoop in and save the day.</p><p>Rather than having to do the setup and talking to the database, we can simply set up a persistent store with SwiftData.</p><p>It’s like the middleman between us and the database.</p><p>Not only does it set everything up, it provides a context for us to easily read and/or write data using Swift as opposed to SQL (the language).</p><p>This Model Context is responsible for displaying a representation of the contents within the underlying SQL database.</p><p>This representation is like a picture or snapshot that we can edit.</p><p>It’s like a notepad. Or a whiteboard.</p><p>But it’s not the actual database.</p><p>In order for changes to make it to the database, they have to be <em>saved</em> to the database, which is, as I mentioned, the responsibility of the persistent store.</p><p>And would you look at that? We’re back on track.</p><h4>The Situation… Continued</h4><p>There are two ways for the changes we make in the model context (the editable snapshot/notepad/whiteboard) to be saved to the database.</p><ol><li>Automatically based on SwiftData’s discretion.</li><li>Manually by specifically telling the context to save.</li></ol><p>Both methods work, but not always. At least not as you might expect.</p><p>The unexpected behavior occurs once relationships are established between different data models stored in the database.</p><p>Consider thisFolder model, for example.</p><pre>@Model<br>final class Folder {<br>    var items: [Item] = []<br>    // ...<br>}</pre><p>While it may literally contain an array of Item models when written in Swift, this isn’t true once it’s written to the (SQL) database.</p><p>Instead, the data for each model is saved in a row in their corresponding table.</p><p>There’s a Folder table and an Item table.</p><p>In the database, the relationship is established by simply adding a new column to each row with some kind of identifier referencing the object in the other table.</p><p>This is called a <em>foreign_key</em>.</p><p>But we don’t have to know anything about that. We have SwiftData to do that for us.</p><p>Now, once a relationship is made, we have to inform the database what to do should one model in the relationship be deleted.</p><p>We do this by defining a <strong>delete rule</strong>.</p><p>In the Folder/Item scenario, it would be nice if, after deleting a Folder, all of the Item models it contains are also deleted.</p><p>And great news! SwiftData provides an easy way to do that.</p><pre>@Model<br>final class Folder {<br>    @Relationship(deleteRule: .cascade) var items: [Item] = []<br>    // ...<br>}</pre><p>By including .cascade in the @Relationship annotation, SwiftData knows to delete all corresponding Item models in the Folder once the Folder is deleted.</p><p>Unfortunately, this only works when autosave is enabled in the persistent store.</p><p>If you disable autosave, then the cascading delete will not occur despite the inclusion of the delete rule.</p><p>Perhaps this is the intended behavior.</p><p>I couldn’t find any indication of this in the documentation, but maybe such behavior is simply implied.</p><p>After all, the cascade delete rule is an automatic process, so it makes sense that disabling autosave will also disable the delete rule.</p><p><em>That makes no sense.</em></p><p>Well, let’s frame this concept in a new light before we start throwing stones.</p><h4>Analogy Time</h4><p>Imagine a high-tech trash bin that automatically empties its contents into a larger bin when it detects trash inside.</p><p>If you disable the auto-empty feature, you can still press a button to empty it manually.</p><p>Now imagine putting a binder full of paper into the trash bin. The binder has rings that hold the paper together.</p><p>Those rings are our delete rule.</p><p>When the trash bin empties, whether automatically or manually, both the binder and its paper go into the larger bin.</p><p>This makes sense because the relationship between the binder and the paper has nothing to do with whether the bin is in auto or manual mode.</p><p>But in SwiftData, disabling autosave somehow breaks this relationship, leaving the paper behind while the binder is trashed.</p><h4>Why This is Unexpected</h4><p>Delete rules govern relationships and data integrity, deciding what happens to child objects when a parent is deleted.</p><p>Autosave, on the other hand, controls when changes are persisted to the database.</p><p>These are two separate concerns. Changing one should not affect the other.</p><p>For a framework designed to abstract away complexity and simplify persistence, this behavior feels counterintuitive.</p><p>Developers need confidence that delete rules will behave consistently, regardless of autosave settings.</p><p>Until I find a better workaround (or perhaps a solution), if autosave is disabled, I’ll just manually delete child objects before saving.</p><p>If you’d like to explore this issue further or experiment with possible fixes, check out my GitHub repository: <a href="https://github.com/nikolainobadi/SwiftDataCascadeBug">SwiftDataCascadeBug</a>. It’s a simple project designed to reproduce the behavior described in this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=270530ca3b0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Foundations of Effective Testing]]></title>
            <link>https://medium.com/@nikolai.nobadi/the-foundations-of-effective-testing-82b6d5aa5780?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/82b6d5aa5780</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Mon, 18 Nov 2024 23:46:53 GMT</pubDate>
            <atom:updated>2024-11-19T04:45:57.241Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building a Comprehensive Test Suite, One Layer at a Time</h4><figure><img alt="Futuristic layered pyramid symbolizing software testing, with distinct glowing layers interconnected in a high-tech digital environment." src="https://cdn-images-1.medium.com/max/512/1*KAKiMh_oupG4LUjgU2ZbCQ.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><blockquote>Everything important is, at bottom, utterly simple. — John Wheeler</blockquote><p>Testing software is a world.</p><p>Spend even a few minutes browsing the internet (or chatting with your preferred AI) and you’re likely to encounter a cacophony of advice, a cornucopia of techniques, and perhaps a sudden lack of <em>test-writing</em> motivation.</p><p><em>Lackadaisical.</em></p><p>Lethargic.</p><p><em>Languid.</em></p><p>Lasagna.</p><p>Okay, maybe that last one is a bit random.</p><p>Or is it?</p><p>What if the secrets of testing software could be as simple as a slice of lavishly layered lasagna?</p><p><em>Is it alliteration time?</em></p><p>No, just dinner time. But bear with me, this analogy works.</p><h4>Layers of a Good Test Suite</h4><p><a href="https://medium.com/@nikolai.nobadi/beyond-a-working-app-the-case-for-a-comprehensive-test-suite-74ded95af24e">In my last article</a>, I emphasized the importance of having a comprehensive test suite to ensure that changes could be made to a working product without fear of breaking it.</p><p>And I also mentioned that a good test suite is more than just unit tests.</p><p>It’s lasagna.</p><p>Each layer in lasagna adds something essential to the outcome. There’s the pasta for structure, the sauce for flavor, and the cheese to bring it all together. Skip a layer, and dinner might very well be ruined.</p><p>It’s the same for writing tests.</p><p>Unit tests are the pasta, the foundation. They’re the building blocks that hold everything up. Integration tests are the sauce, ensuring that all the components blend together nicely. And UI tests are the cheese, making sure the final product both looks and tastes great.</p><p>And yes, I’m eating lasagna as I write this.</p><p>But enough with analogies. What is it exactly that distinguishes each type of test from the other? And when should each be utilized in the test suite?</p><h4>Unit, Integration, or UI?</h4><p>For simplicity, let’s use the example of deleting an item from a database to help answer those questions. And to do that, I’ll need to ask my own questions.</p><p>The content of my question (as well as the answer I seek) will dictate which test should be used.</p><p>And as a general rule, I always make sure the answers to my questions can only be one of two options: yes or no.</p><p><strong>Unit:</strong> Was an attempt to delete the item made?</p><p><strong>Integration:</strong> Was the item removed from the database?</p><p><strong>UI:</strong> Did the item disappear from the displayed list?</p><p>While those questions may look similar, they are each designed to reveal where the code is broken if they return a <em>no</em> when asked.</p><p><strong>Unit:</strong> If there wasn’t an attempt to delete the item, then the problem is in the method or class that’s making the delete request.</p><p><strong>Integration:</strong> If the attempt was made (unit test passed) but the item remains in the database, then the problem lies in the communication between the deleting method and the persistence/networking layer.</p><p><strong>UI:</strong> If the item was removed from the database (unit/integration tests passed) but the item remains in the displayed list…</p><p><em>Then the UI is broken.</em></p><p>B-b-b-bingo!</p><p>By including each layer, you get comprehensive coverage without unnecessary redundancy. And you don’t even have to have 100% code coverage to do this.</p><h4>A Word on Test-Driven Development (TDD)</h4><p>For anyone unfamiliar with the concept, TDD is the practice of writing tests <em>before</em> any code is written.</p><p>If I’m being honest, it’s a great way to go about coding.</p><p>At least in theory.</p><p>I’m always striving to <a href="https://medium.com/@nikolai.nobadi/the-struggle-for-perfect-software-architecture-4c7878a5d671">find the perfect architecture</a>, even if it means <a href="https://medium.com/@nikolai.nobadi/from-constellations-to-code-simplifying-software-architecture-with-astronomy-de675adc61b8">staring into the starry abyss</a> to find the answers I seek, but-</p><p><em>Did you just reference two of your own articles in a single sentence?</em></p><p>Guilty as charged. But I can’t help it.</p><p>I just finished coding my own custom SwiftUI Text editor with syntax highlighting and line numbers for one of my macOS apps and I’m having so much fun testing out the different colors for links and bold text and…</p><p>And I’m getting off topic again.</p><p>Where was I?</p><p><em>Shameless self-promoting.</em></p><p>The failures of TDD. That’s what I was talking about.</p><p>Well, I suppose it’s really my own failures while trying to use TDD.</p><p>Anyway, while many apps share many things in common, they all undoubtedly deserve their own specific architecture, as well as their own specific business rules (the way they validate/process/distribute the data they use).</p><p>As such, it may not always be possible to know if the architecture that was planned will end up being the architecture that’s used in production.</p><p>I learned this the hard way many times.</p><p>Countless hours spent identifying the tests that would lead me to write the perfect code only to realize there was a better way. Or that what I wanted wouldn’t work. Or the client changed their mind. Again.</p><p>It didn’t matter that the code I had written was (ideally) bug-free. It didn’t end up meeting the overall requirements of the product, and thus had to be scrapped.</p><p>So now I follow a sort of hybrid approach when it comes to testing.</p><p>And I say <em>hybrid</em> because even though I save the actual writing of the tests until after I’ve already written the code (with a few exceptions), I still follow one of the principles of Test-Driven Development.</p><h4>Red/Green Testing</h4><p>The concept of red/green testing is fairly simple.</p><ol><li>Write a failing test (red).</li><li>Write just enough code to make the test pass (green).</li><li>Refactor the code without breaking the test.</li></ol><p><em>How do you write a failing test if the code is already written?</em></p><p>I just comment the code out.</p><p>I’m not sure if this is the best approach, but it hasn’t failed me yet. I’m still able to determine that the passing test is only passing in response to the code I wrote, so that’s all that matters to me.</p><h4>A Final Note</h4><p>Writing tests isn’t about perfection, it’s about protection. Protection for your time, your sanity, and ultimately, your users.</p><p>A good test suite doesn’t just validate code. It validates confidence.</p><p>It lets you know that when changes come (and they always do), your code will stand strong.</p><p>So, whether you’re layering lasagna or layering tests, remember: simplicity doesn’t mean easy, but it does mean essential. Every layer has its purpose. Every layer contributes to the whole.</p><p>Testing software is a world, yes. But like any world, it’s built one layer at a time.</p><p>Now, if you’ll excuse me, I have some lasagna left to finish.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82b6d5aa5780" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond a Working App: The Case for a Comprehensive Test Suite]]></title>
            <link>https://medium.com/@nikolai.nobadi/beyond-a-working-app-the-case-for-a-comprehensive-test-suite-74ded95af24e?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/74ded95af24e</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[continuous-improvement]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Mon, 11 Nov 2024 23:30:20 GMT</pubDate>
            <atom:updated>2024-11-18T23:54:14.164Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why Tests Matter — Even in Personal Projects</h4><figure><img alt="A pathway of circuits leading to a glowing check mark, symbolizing software development from a basic product to a robust, tested codebase." src="https://cdn-images-1.medium.com/max/512/1*U-lEJ0Udl9dGHwOLwoD6lA.png" /><figcaption>Image generated by ChatGPT.</figcaption></figure><p>A working product.</p><p>That’s all anybody cares about.</p><p>It doesn’t matter how clean or sloppy the code is, or that you have the perfect ratio of unit/integration/UI tests.</p><p>The app needs to work.</p><p>Yes, it also needs to be easy to use and probably look pretty, but none of that is as important as a working product.</p><p>Here’s the thing: while anyone can build a working product, not everyone can build one that works well and is easy to modify.</p><p>And modification matters, so the easier the better.</p><p>One of the most beautiful (and terrifying) things about software is that it is destined to change.</p><p><em>Terrific.</em></p><p>No, I said terrifying…</p><p>Actually can we talk about that word really quick?</p><h4>Sidenote</h4><p>The word <em>terrific</em> makes no sense to me.</p><p>Terror/Terrible/Terrifying = bad.</p><p>Horror/Horrible/Horrifying = bad.</p><p>Horrific. Still bad.</p><p>Terrific… Good?</p><p>I digress.</p><p>Since software is destined to change, either in response to advances in technology or a client’s new inspiration, it would behoove the humble developer to find a way to make changes to the codebase without fearing a catastrophe.</p><p>That’s where tests come in.</p><h4>The Test Suite</h4><p>A comprehensive and robust test suite, one that thoroughly exercises the code and stays reliable through changes, is a critical component to any project, be it personal or professional.</p><p>Unfortunately, the ability to write a test suite of such caliber heavily depends on the quality of the code being tested.</p><p>Sloppy code makes it hard to write tests that stand the test of time.</p><p>And here’s the travesty: it’s easy to skimp on the test suite for personal projects because they’re, well, personal.</p><p>Most aren’t meant to be deployed to the public. They’re simply a way for us crazy developers who love coding to have some fun.</p><p>After all, it should be a joy to invest time into a personal project.</p><p>But there’s nothing joyful about going back to refactor an old project and spending hours refining the codebase with all the cool new techniques you’ve learned in the last couple of months only to realize that the project no longer works because <strong><em>past-you</em></strong> neglected to add a proper test suite but seemed to have no problem implementing hidden dependencies which of course you trashed because how could you know how important that random piece of code was? You wrote it 5 months ago!</p><p>I’m not bitter. I mean, it’s not like that very specific scenario has ever happened to me.</p><p>Just someone I know.</p><p><em>And they happen to share your name?</em></p><p>As I was saying…</p><p>Including a good test suite is essential to any project. And coding in a way that makes it easier to write reliable tests can make life for <strong><em>future-you</em></strong> much easier.</p><p>That’s why I spend so much time <a href="https://medium.com/@nikolai.nobadi/the-struggle-for-perfect-software-architecture-4c7878a5d671">planning the architecture of my projects</a>.</p><p>That’s why it’s so important to make sure the implementation of said architecture is <strong>SOLID</strong>.</p><p><em>I see what you did there.</em></p><p>Good, because it was a ploy to divert your attention from the fact that I don’t have a link to the implementation article because I haven’t written it yet.</p><p>But the delay is strategic.</p><p>Sure, I tend to get side-tracked easily, but any talk of code implementation could certainly benefit from a discussion about the reasoning behind the implementation tactics I tend to employ.</p><p>That reason, of course, is to make it easier to write tests so that any changes to a working product could be made in confidence instead of fear.</p><p>So, before diving into the universe of test-friendly code implementation, I’ll expand this detour and explore the <a href="https://medium.com/@nikolai.nobadi/the-foundations-of-effective-testing-82b6d5aa5780">anatomy of a good test suite</a>.</p><p>Spoiler alert: it contains more than just unit tests.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74ded95af24e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Constellations to Code: Simplifying Software Architecture with Astronomy]]></title>
            <link>https://medium.com/@nikolai.nobadi/from-constellations-to-code-simplifying-software-architecture-with-astronomy-de675adc61b8?source=rss-8afdd2a0f1b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/de675adc61b8</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[astronomy]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nikolai Nobadi]]></dc:creator>
            <pubDate>Mon, 04 Nov 2024 21:21:19 GMT</pubDate>
            <atom:updated>2024-11-04T22:41:40.738Z</atom:updated>
            <content:encoded><![CDATA[<h4>Apply universal concepts like separation of concerns and fractal geometry to create structured code.</h4><figure><img alt="Illustration of cosmic-inspired software architecture: translucent code modules arranged in a fractal pattern, blending galaxies and star clusters to symbolize modularity and scalability." src="https://cdn-images-1.medium.com/max/512/1*doOI3pQ-5cfnNTSi_INZ-g.png" /><figcaption>Image generated by ChatGPT.</figcaption></figure><p>Thinking about the big picture is often overwhelming.</p><p>I’m not sure when I first began to realize this, but the most readily available memory is from my freshman year of college when I took astronomy, a class that had nothing to do with my eventual major.</p><h4>Story Time</h4><p>The class was super easy (barely an inconvenience) mainly because attendance was only required on exam days and the content of the exams was found almost verbatim in the course textbook.</p><p>But I didn’t know that when I first signed up for the class. I just thought learning about the universe would be cool.</p><p>Well, that and it gave me an excuse to ask girls on dates under the guise of stargazing to ‘help me with my homework’.</p><p>I went on quite a few of those ‘dates’ throughout the semester, and aside from promptly being friend-zoned by the end of the night, I noticed another recurring pattern:</p><blockquote>talking about constellations was fine — people could relate to the recognizable patterns in the night sky. But as soon as we started talking about the history of the universe, they would quickly give up and shift the conversation to something lighter.</blockquote><p><em>What does any of that have to do with software development?</em></p><p><a href="https://medium.com/@nikolai.nobadi/the-struggle-for-perfect-software-architecture-4c7878a5d671">Planning an app’s architecture</a> can be as daunting as exploring the history of the universe, so it’s tempting to rush through the process, or worse, skip it altogether, in order to get to the fun part.</p><p>But the finished product, if it ever makes its way to reality, will have some kind of architecture, and if it’s sloppy, then that just means more work will be required just to maintain or enhance the app.</p><p>So the upfront work <em>is</em> worth it.</p><p>And it’s easy.</p><p>Just plan the different modules, identify necessary dependencies, establish logical boundaries, consider potential edge cases, and…</p><p>Okay, this is kind of overwhelming.</p><p><em>Maybe astronomy can help.</em></p><p>Oh, yeah. I guess it’s a good thing I took that astronomy course back in college, huh?</p><p>Too bad I don’t remember any of it.</p><p>But fear not! For since that time, I have watched my fair share of Neil deGrasse Tyson YouTube videos and have read a couple of books on the subject.</p><h4>Universal Insights</h4><p>It’s all about <strong>encapsulation</strong> and <strong>separation of concerns</strong>.</p><p><em>That… sounds suspiciously like computer science jargon.</em></p><p>That’s because it is! That’s what we’re talking about, after all.</p><p>The key to mitigating the overwhelming sensation that often accompanies topics of vast complexity, like software architecture, is to encapsulate that complexity and separate the information into cohesive chunks or, dare I say it, into <strong>distinct modules</strong>.</p><p>These concepts are fundamental to software development and —</p><p><em>And those thieving astronomers STOLE them!</em></p><p>Well, those concepts aren’t really exclusive to programmers.</p><p>Language itself is the grand central station of encapsulation. Every word is like a package containing complex thoughts or emotions.</p><p>And as for separation of concerns, I have yet to walk into a house or apartment that doesn’t keep the kitchen and the bathroom separated.</p><p>Which is quite the feat considering I spent most of my twenties living in studio apartments.</p><p><em>Are you just going to pretend like you didn’t try to rhyme?</em></p><p>Language. The graaaand central-STA-tion of encapsu-LA-tion. Separate-concerns-or-find-a-different-occu-PA-tion.</p><p>I feel like that’s not going to read as cool as it sounds in my head.</p><p><em>Probably not.</em></p><p>Let’s get back on track.</p><p>The universe is vast and complex, but you don’t have to know anything about turbulent gases or nuclear fusion to know what a <strong><em>star</em></strong> is. Likewise, you don’t have to understand electromagnetism or the way bosons interact to know what <strong><em>light</em></strong> is.</p><p>This is encapsulation at its finest.</p><p>Another example, you say? Sure.</p><p>Any number of <strong><em>planets</em></strong> can orbit around a <strong><em>star</em></strong> to form a <strong><em>solar system</em></strong> that itself orbits the center of a <strong><em>galaxy</em></strong> that can belong to one of many <strong><em>galactic clusters</em></strong> that comprise the visible <strong><em>universe</em></strong>.</p><p>There, I give you the overall architecture of <strong>universe.exe</strong>.</p><p><em>Aren’t you an iOS Developer?</em></p><p><em>Ahem.</em> <strong>Universe.xcodeproj</strong>.</p><p>Notice how encapsulated objects naturally lead to separation of concerns?</p><p>That’s because it isn’t technically necessary to know or understand the specific <strong><em>implementation</em></strong> of any object in the universe to understand its overall architecture. What’s more important are the <strong><em>relationships</em></strong> between each object.</p><p>By focusing only on relationships and dependencies during the creation of an app’s architecture, it becomes easier to establish appropriate boundaries in the codebase, which, if enforced, leads to proper separation of concerns.</p><p>At that point, it should be possible to work on any component in the project without directly requiring any other component.</p><p>Our dear astronomer friends are pros at doing this.</p><p>Broadly speaking, they separate the universe into the macro and micro, each with their own specialized theories that sort of act as frameworks for whatever it is they do when they do what they do.</p><p><strong>General relativity</strong> for the <em>macro-verse</em>, and <strong>quantum mechanics</strong> for the <em>micro-verse</em>. Two theories that don’t seem to have anything to do with one another yet they happily co-exist thanks to proper separation of concerns.</p><p><em>And Marvel for the ‘Multi-verse.’</em></p><p>Curse you, random thoughts!</p><p>Ugh, now I have to go watch Infinity War for the 50th time.</p><p>Anyway, you don’t need to know every particle or orbit to see the larger picture. Recognizable structures, like modules and their boundaries, are what hold a codebase together.</p><p>And here’s the cool part: once this initial structure is established, it can (and likely should) be reused over and over in each module.</p><p>Why, you ask?</p><p>Because that’s what the universe does.</p><h4>Enter Fractals</h4><p>A fractal is a pattern that repeats itself at every scale, from galaxies down to the branches of a tree. From the orbit of planets to the orbit of protons and electrons. Each part resembles the whole, no matter how closely you look.</p><p>By designing an app’s architecture using a fractal approach, where each component mirrors the principles of the entire structure, the resulting codebase is not only consistent and easy to understand, but it’s also easy to expand.</p><p><em>Oh dear, you’re rhyming again.</em></p><p>But this is only the first half of the story.</p><p>With the architecture done, it’s time to get to the actual implementation.</p><p>And yes, the universe can help with that as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de675adc61b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>