<?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 Karel van der Merwe on Medium]]></title>
        <description><![CDATA[Stories by Karel van der Merwe on Medium]]></description>
        <link>https://medium.com/@karelvdmmisc?source=rss-2af0d8c82993------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_IaKTKhYhMTAbuHp.jpg</url>
            <title>Stories by Karel van der Merwe on Medium</title>
            <link>https://medium.com/@karelvdmmisc?source=rss-2af0d8c82993------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 21:42:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karelvdmmisc/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[The Lost Craft of Software Engineering — and Why I Write to Preserve It]]></title>
            <link>https://medium.com/@karelvdmmisc/the-lost-craft-of-software-engineering-and-why-i-write-to-preserve-it-fb75cc4a7c60?source=rss-2af0d8c82993------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb75cc4a7c60</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[craftsmanship]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Karel van der Merwe]]></dc:creator>
            <pubDate>Sat, 13 Sep 2025 20:45:08 GMT</pubDate>
            <atom:updated>2025-09-13T20:45:08.629Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Lost Craft of Software Engineering — and Why I Write to Preserve It</h3><p><em>“Why do I write?”</em> That’s the question I asked myself recently. The answer is simple, yet deeply personal: I write because the craft of software engineering — the pride in building something elegant, thoughtful, and well-designed — has largely disappeared from the tech industry in 2025.</p><p>In a corporate environment, speed, metrics, and outputs often outweigh creativity, intellectual curiosity, and careful design. I realized that without that sense of craftsmanship, my work felt like a series of tasks rather than a practice that challenges me, excites me, and makes me feel fulfilled.</p><h3>The Craft of Software Engineering 10–15 Years Ago</h3><p>A decade or more ago, engineering was often treated as a <strong>true craft</strong>. Code wasn’t just written to work; it was written to <strong>stand the test of time</strong>, to remain maintainable, readable, and robust long after it was deployed. Developers debated over patterns, architectures, and trade-offs not because they had to, but because they <strong>cared deeply about the work itself</strong>.</p><p>Deadlines were real, and projects had schedules — but focusing on craftsmanship didn’t slow progress; it <strong>accelerated productivity over time</strong>. Thoughtful design and clear architecture meant fewer bugs, less technical debt, and a smoother path for future development. Teams refactored and refined their code regularly, ensuring the system remained clean and agile. Today, by contrast, much of the industry <strong>accepts the mess as inevitable</strong>, letting code entropy accumulate rather than investing in upkeep.</p><p>Code reviews were more than a checkbox — they were <strong>conversations about excellence</strong>, opportunities to learn, refine thinking, and share knowledge. There was pride in building something that wasn’t just functional, but <strong>intellectually satisfying</strong>, a small piece of a larger puzzle solved thoughtfully.</p><p>The environment fostered curiosity. Engineers were encouraged to explore new approaches, experiment, and challenge assumptions. <strong>Craftsmanship was inseparable from fulfillment</strong>, and each line of code carried a sense of ownership and artistry, even while deadlines were met and deliverables shipped on time.</p><h3>Writing as a Way to Preserve the Craft</h3><p>Today, much of that has faded. Corporate pressures — deadlines, KPIs, and metrics — can strip work of the intellectual stimulation it once offered. That’s where writing comes in.</p><p>Writing allows me to <strong>exercise the very skills that the modern environment often neglects</strong>. It forces clarity, reflection, and structured thinking — the same principles that define quality software. When I write, I think deeply about patterns, principles, and decisions in a way that mirrors the care I used to put into coding.</p><p>It’s a form of <strong>mental craftsmanship</strong>. Each article is a small project, a way to preserve the mindset and pride that I miss in day-to-day work. Through writing, I keep the craft alive — not just for myself, but for anyone who might read and find resonance in it.</p><h3>Encouraging a Return to Craft</h3><p>If you’re an engineer who feels this too, you’re not alone. The industry may have shifted toward speed and output, but that doesn’t mean the principles of craftsmanship are gone. We can choose to <strong>value quality, clarity, and thoughtful design</strong>, even when it’s not required.</p><p>Writing, mentoring, contributing to open-source, or simply taking the time to refactor code thoughtfully are all ways to <strong>keep the craft alive</strong>. These small acts remind us why we became engineers in the first place — for the challenge, the creativity, and the joy of building something meaningful.</p><p>I write because I want to <strong>reclaim what has been lost</strong>, to exercise my intellect and preserve the craft I love. And if my words inspire even one other engineer to value their work beyond metrics, then it’s worth it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb75cc4a7c60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SwiftUI for Android Developers - Kotlin Multiplatform]]></title>
            <link>https://medium.com/@karelvdmmisc/swiftui-for-android-developers-in-kotlin-multiplatform-cdb3688f3dec?source=rss-2af0d8c82993------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdb3688f3dec</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[compose-ui]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Karel van der Merwe]]></dc:creator>
            <pubDate>Tue, 08 Jul 2025 15:44:40 GMT</pubDate>
            <atom:updated>2025-07-11T15:25:58.896Z</atom:updated>
            <content:encoded><![CDATA[<h3>Article 1: Understanding the Core Differences Between Jetpack Compose and SwiftUI</h3><p>As Kotlin Multiplatform adoption grows, more Android developers are finding themselves writing SwiftUI for the first time. While SwiftUI and Jetpack Compose both fall under the “declarative UI” umbrella, they differ in ways that go far beyond syntax.</p><p>This article provides a side-by-side comparison of key concepts, with the goal of helping Compose developers build a solid mental model for working effectively in SwiftUI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9tolaH99KtRgbKf1Nm94Ew.png" /></figure><h3>Declarative UI Isn’t One-Size-Fits-All</h3><p>Both Jetpack Compose and SwiftUI represent modern declarative UI frameworks, where:</p><ul><li>UI is a function of state</li><li>Views are composed of smaller pieces</li><li>State changes automatically trigger UI updates</li></ul><p>But how they implement these principles differs in <strong>philosophy</strong>, <strong>mechanics</strong>, and <strong>developer control</strong>.</p><h3>Core Differences: Jetpack Compose vs. SwiftUI</h3><p><strong>State Ownership</strong></p><ul><li><strong>Jetpack Compose:</strong> remember, mutableStateOf, ViewModel</li><li><strong>SwiftUI:</strong> @State, @ObservedObject, @EnvironmentObject</li></ul><p><strong>Unidirectional Data Flow</strong></p><ul><li><strong>Jetpack Compose:</strong> Enforced (typically via MVI/MVVM)</li><li><strong>SwiftUI:</strong> Encouraged, but often broken via global state</li></ul><p><strong>Preview Support</strong></p><ul><li><strong>Jetpack Compose:</strong> Robust previews, parameterised</li><li><strong>SwiftUI:</strong> Limited, no preview params (Xcode 16 improves it)</li></ul><p><strong>Side-effect Handling</strong></p><ul><li><strong>Jetpack Compose:</strong> LaunchedEffect, SideEffect, rememberCoroutineScope</li><li><strong>SwiftUI:</strong> onAppear, task, @MainActor, Combine</li></ul><p><strong>View Models</strong></p><ul><li><strong>Jetpack Compose:</strong> Lifecycle-aware (ViewModel)</li><li><strong>SwiftUI:</strong> Manual management (ObservableObject)</li></ul><p><strong>Navigation</strong></p><ul><li><strong>Jetpack Compose:</strong> Compose Navigation or custom MVI</li><li><strong>SwiftUI:</strong> NavigationStack, NavigationLink (still evolving)</li></ul><p><strong>Composition Lifecycle</strong></p><ul><li><strong>Jetpack Compose:</strong> Clear control with recomposition scopes</li><li><strong>SwiftUI:</strong> Implicit; tied to value-type view recomputation</li></ul><p><strong>Tooling &amp; Error Messages</strong></p><ul><li><strong>Jetpack Compose:</strong> Compose compiler, structured errors</li><li><strong>SwiftUI:</strong> Often vague runtime errors, especially around state</li></ul><h3>State Management: Explicit vs Implicit</h3><p>In Compose:</p><ul><li>State is typically <strong>explicit</strong> and colocated using remember or injected via a ViewModel.</li><li>You control lifecycle, visibility, and sharing.</li></ul><p>In SwiftUI:</p><ul><li>State is more <strong>decentralized</strong>: multiple property wrappers for different ownership models.</li><li>@EnvironmentObject and @ObservedObject often lead to hidden dependencies and global state.</li></ul><p><strong>Example:</strong></p><p>Jetpack Compose</p><pre>val viewModel = hiltViewModel&lt;MyViewModel&gt;()<br>val state by viewModel.uiState.collectAsState()</pre><p>SwiftUI</p><pre>@EnvironmentObject var session: Session<br>@ObservedObject var viewModel = MyViewModel()</pre><p><strong>In SwiftUI, state is easier to access, but harder to trace.</strong><br> In Compose, state is more work to wire up — but <strong>predictable and testable</strong>.</p><h3>ViewModel Differences</h3><p>Jetpack Compose’s ViewModel is tied to the Android lifecycle and plays a central role in separation of concerns.</p><p>SwiftUI has <strong>no built-in ViewModel abstraction</strong>. Instead, it relies on:</p><ul><li>ObservableObject + @Published for reactive data</li><li>Manual injection and management (no lifecycle integration)</li></ul><p>As a result:</p><ul><li>Compose ViewModels are <strong>isolated and testable</strong></li><li>SwiftUI view models are <strong>often tightly coupled to the UI</strong></li></ul><p>If you’re building a KMP app, it’s best to <strong>preserve shared logic in the KMP layer</strong> and keep SwiftUI dumb — just like you would with Compose.</p><h3>Navigation Differences</h3><p>Compose:</p><ul><li>Navigation is explicit, testable, and part of your architecture.</li><li>You can intercept and control navigation easily.</li></ul><p>SwiftUI:</p><ul><li>Navigation uses NavigationStack, NavigationLink, or programmatic bindings.</li><li>The view hierarchy often <em>owns</em> navigation, making it harder to centralise logic.</li></ul><pre>NavigationStack {<br>    NavigationLink(&quot;Go to Details&quot;, value: someModel)<br>}</pre><p>This makes <strong>deep linking</strong>, <strong>state restoration</strong>, and <strong>custom routing</strong> more complex than Compose.</p><h3>Side Effects and Lifecycle</h3><p>Compose offers:</p><ul><li>Clear lifecycle-aware tools (LaunchedEffect, DisposableEffect, etc.)</li><li>Coroutine-based side effect management</li></ul><p>SwiftUI gives you:</p><ul><li>onAppear, task, onChange, and Combine</li><li>Less visibility into lifecycle phases</li></ul><p><strong>Compose example:</strong></p><pre>LaunchedEffect(Unit) {<br>    viewModel.loadData()<br>}</pre><p><strong>SwiftUI equivalent:</strong></p><pre>.task {<br>    await viewModel.loadData()<br>}</pre><p>SwiftUI side effects are tied to <strong>view creation</strong>, not lifecycle, which can lead to <strong>multiple unexpected re-runs</strong> during recomposition.</p><h3>Composition Model</h3><p>Jetpack Compose:</p><ul><li>Views are recomposed when state changes inside a Composable function</li><li>You can scope recomposition</li></ul><p>SwiftUI:</p><ul><li>Views are <strong>value types</strong>, so they’re <strong>rebuilt from scratch</strong> on each change</li><li>There is <strong>no fine-grained control</strong> over recomposition</li></ul><p>This makes performance tuning and understanding redraw behavior more opaque in SwiftUI.</p><h3>Migration Mindset: What to Keep from Compose</h3><p>Here’s how to <strong>stay sane</strong> as an Android developer entering SwiftUI:</p><p><strong>Keep from Compose</strong></p><ul><li>Explicit state management</li><li>ViewModel separation</li><li>Unidirectional data flow</li><li>Predictable navigation flow</li><li>Side-effect boundaries (LaunchedEffect)</li></ul><p><strong>Adjust for SwiftUI</strong></p><ul><li>Avoid overusing @EnvironmentObject</li><li>Build testable, logic-isolated view models</li><li>Pass data down and events up explicitly</li><li>Wrap SwiftUI navigation in coordinators</li><li>Use task, but isolate logic outside views</li></ul><h3>Conclusion</h3><p>While Jetpack Compose and SwiftUI share the same declarative DNA, they <strong>differ sharply in state management, lifecycle, and architectural philosophy</strong>.</p><p>As an Android developer entering SwiftUI via Kotlin Multiplatform, your background gives you a huge advantage — you already know how to build scalable UIs with clear data flow.</p><p>By recognizing the hidden mechanics of SwiftUI and applying <strong>Compose-era discipline</strong>, you can build iOS UIs that are <strong>predictable, testable, and maintainable</strong> — even if the platform doesn’t encourage it by default.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdb3688f3dec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eliminating UI Duplication in Kotlin Multiplatform with Clean Architecture, DDD & MVI]]></title>
            <link>https://medium.com/@karelvdmmisc/eliminating-ui-duplication-in-kotlin-multiplatform-with-clean-architecture-ddd-mvi-6fa513ee30ab?source=rss-2af0d8c82993------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fa513ee30ab</guid>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[mvi]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <dc:creator><![CDATA[Karel van der Merwe]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 15:05:12 GMT</pubDate>
            <atom:updated>2025-07-03T05:42:55.178Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6sWp5SnKrTeN1XJwPmBXA.png" /></figure><p>In the age of declarative UIs, it’s time we stop duplicating logic across platforms. If you’re building a Kotlin Multiplatform (KMP) app and still rewriting business logic, formatting rules, or state handling in both SwiftUI and Jetpack Compose — you’re doing too much work.</p><p>In this article, I’ll show how combining <strong>Clean Architecture</strong>, <strong>Domain-Driven Design (DDD)</strong>, and <strong>MVI</strong> gives you a powerful architecture that keeps your <strong>platform UIs thin, declarative, and reactive to shared state</strong>, with <strong>zero duplication of logic</strong>.</p><h3>Why This Stack?</h3><p>Each architecture piece brings something essential:</p><ul><li><strong>Clean Architecture</strong>: Separates layers with clear direction of dependencies.</li><li><strong>DDD</strong>: Models your real-world logic in code using rich domain models.</li><li><strong>MVI (Model–View–Intent)</strong>: Ensures unidirectional flow and predictable UI behavior.</li></ul><p>Together, they offer <strong>clarity</strong>, <strong>reusability</strong>, and <strong>testability</strong> — across Android and iOS — without compromising user experience.</p><h3>The Layered Flow</h3><p>Your app should transform data like this:</p><pre>[UserDto] → [User (Domain)] → [UserUi (Presentation)] → [Platform UI]</pre><h3>Example: Mapping a User Object</h3><p>Let’s say your API gives you this:</p><pre>data class UserDto(<br>    val id: String,<br>    val fullName: String,<br>    val emailAddress: String,<br>    val balanceInCents: Int<br>)</pre><h3>Domain Layer</h3><pre>@JvmInline<br>value class Coin(val amount: Int)<br><br>data class User(<br>    val id: String,<br>    val name: String,<br>    val email: String,<br>    val balance: Coin<br>)</pre><h3>Presentation Model</h3><pre>data class UserUi(<br>    val displayName: String,<br>    val email: String,<br>    val balanceFormatted: String<br>)</pre><h3>Mapping Logic</h3><pre>fun UserDto.toDomain() = User(<br>    id = id,<br>    name = fullName,<br>    email = emailAddress,<br>    balance = KidCoin(balanceInCents)<br>)<br><br>fun User.toUi() = UserUi(<br>    displayName = name,<br>    email = email,<br>    balanceFormatted = &quot;${balance.amount / 100}.${balance.amount % 100}&quot;.padEnd(5, &#39;0&#39;) + &quot; KC&quot;<br>)</pre><p>This allows your domain and UI to evolve independently from your backend — safely and cleanly.</p><h3>The Power of Thin UI Layers</h3><h4>Jetpack Compose (Android)</h4><pre>@Composable<br>fun UserCard(user: UserUi) {<br>    Column(Modifier.padding(16.dp)) {<br>        Text(user.displayName, style = MaterialTheme.typography.titleLarge)<br>        Text(user.email, style = MaterialTheme.typography.bodyMedium)<br>        Text(user.balanceFormatted, style = MaterialTheme.typography.bodyLarge)<br>    }<br>}</pre><h4>SwiftUI (iOS)</h4><pre>struct UserCard: View {<br>    let user: UserUi<br><br>    var body: some View {<br>        VStack(alignment: .leading) {<br>            Text(user.displayName).font(.title2)<br>            Text(user.email).font(.subheadline).foregroundColor(.gray)<br>            Text(user.balanceFormatted).font(.headline).foregroundColor(.blue)<br>        }<br>        .padding()<br>    }<br>}</pre><p>The UI just renders.<br>No formatting logic.<br>No conditionals or business rules.<br>Same result across both platforms.</p><h3>MVI for Predictable UI</h3><p>Use MVI to drive your screens reactively based on shared state:</p><pre>sealed interface UserUiState {<br>    object Loading : UserUiState<br>    data class Success(val user: UserUi) : UserUiState<br>    data class Error(val message: String) : UserUiState<br>}</pre><h3>Jetpack Compose Example</h3><pre>@Composable<br>fun UserScreen(state: UserUiState) {<br>    when (state) {<br>        is UserUiState.Loading -&gt; CircularProgressIndicator()<br>        is UserUiState.Success -&gt; UserCard(user = state.user)<br>        is UserUiState.Error -&gt; Text(&quot;Error: ${state.message}&quot;)<br>    }<br>}</pre><blockquote><em>Same logic applies in SwiftUI using </em><em>@Published state from a shared </em><em>ViewModel.</em></blockquote><h3>The Benefits Stack Up</h3><ul><li><strong>Zero duplication</strong> of formatting or logic across platforms</li><li><strong>Declarative UIs</strong> stay clean and focused only on rendering</li><li><strong>Domain models</strong> evolve independently from transport or UI concerns</li><li><strong>MVI architecture</strong> keeps state predictable and testable</li><li><strong>Business logic and state management</strong> live entirely in shared code</li><li><strong>Business logic </strong>is extremely easy to unit test</li></ul><h3>Final Thought</h3><p>By leveraging <strong>Clean Architecture</strong>, <strong>Domain-Driven Design</strong>, and <strong>MVI</strong> in Kotlin Multiplatform, you’re not just sharing code — you’re sharing the <em>right</em> code.</p><p>You avoid repeating logic, reduce bugs, and gain complete control over the user experience — while each platform renders in its native UI system.</p><p>With this approach, <strong>your platform UIs become truly thin and declarative</strong>, powered by a deeply structured, testable shared core.</p><h3>Want to See It in Action?</h3><p>If you’d like a complete starter project using this exact architecture — including:</p><ul><li>Shared ViewModel with MVI</li><li>Compose &amp; SwiftUI screens</li><li>Domain logic with unit tests</li></ul><p><strong>Drop a comment or message me</strong> — and I’ll share a GitHub repo soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fa513ee30ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Multiplatform: Pitfalls, Anti-Patterns, and Solutions.]]></title>
            <link>https://medium.com/@karelvdmmisc/my-journey-with-kotlin-multiplatform-mobile-pitfalls-anti-patterns-and-solutions-525df7058018?source=rss-2af0d8c82993------2</link>
            <guid isPermaLink="false">https://medium.com/p/525df7058018</guid>
            <category><![CDATA[kmm]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[multiplatform]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Karel van der Merwe]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 14:13:18 GMT</pubDate>
            <atom:updated>2025-07-10T14:05:06.067Z</atom:updated>
            <content:encoded><![CDATA[<p>Of late there has been a growing misconception that Kotlin Multiplatform offers a fully integrated, cross-platform experience with complete IDE support — and that iOS development simply involves wiring up a few views in Swift.</p><p>In reality, KMM still lacks mature IDE tooling on the iOS side, and platform-specific concerns still require significant Swift development, deep understanding of Apple frameworks, and careful coordination between Kotlin and native code. Further more Kotlin Multiplatform will put every architectural decision you make in the shared code under a magnifying glass and amplify every compromise.</p><p>I’ve seen how challenges like ambiguous shared state models, misaligned team structures, and unclear platform boundaries can lead to anti-patterns — particularly on the iOS side — that compromise code clarity and maintainability. In this article, I share those experiences, unpack the underlying causes, and offer practical strategies to help teams navigate the realities of working with KMM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9WzATW55AHhY6oki" /></figure><h3>The Promise and misconceptions of KMM</h3><p>Having recently been involved with multiple KMM projects, I was initially excited to apply my Kotlin and Swift expertise to create unified, maintainable codebases. The promise of shared business logic, reduced duplication, and faster feature delivery was compelling. However, the reality proved to be more nuanced. While Android implementations often adhered to solid architectural patterns like MVVM and StateFlow, the iOS integrations frequently struggled — hindered by duplicated logic, convoluted Swift code, and recurring anti-patterns that made even basic feature development difficult to manage.</p><p>A major contributing factor was a common misunderstanding from business stakeholders — and sometimes even Android engineers — that iOS would only require a thin layer of Swift UI code on top of the shared Kotlin logic. This oversimplification often led to underestimating the platform-specific work required on iOS, from navigation and state handling to bridging Kotlin types, managing lifecycle differences, and adhering to Apple’s strict design and UX conventions. As a result, iOS was frequently left under-resourced and treated as an afterthought, which only amplified the technical debt and made collaboration across platforms more difficult.</p><p>The root issues boiled down to three core problems: ambiguous shared state models, siloed Android and iOS teams, and limited debugging capabilities for shared code on iOS. These challenges led to a cascade of anti-patterns that not only frustrated me but also hindered the team’s ability to deliver a cohesive product.</p><h3>Anti-Patterns and Their Causes</h3><h3>1. Logic Forking from Android</h3><p><strong>Description</strong>: The iOS codebase frequently diverged from the shared logic, with iOS-specific implementations duplicating functionality already present in the KMM module.</p><p><strong>Cause</strong>: The shared code was heavily Android-centric, designed with Android’s lifecycle and Jetpack libraries in mind. For example, StateFlow-based ViewModels worked seamlessly with Jetpack Compose but felt alien to SwiftUI’s reactive paradigm. Without clear abstractions, iOS developers struggled to adapt shared state, leading to forking. Additionally, the shared module was rigid, making it easier to rewrite logic in Swift than to modify Kotlin code.</p><p><strong>Impact</strong>: Duplicated code increased maintenance costs and introduced inconsistencies between platforms. Features that should have been shared required separate debugging and testing, doubling our workload.</p><h3>2. Ambiguous Shared State Models</h3><p><strong>Description</strong>: Shared state models were poorly defined, with unclear contracts and Android-biased assumptions, making it hard for iOS developers to understand or use them effectively.</p><p><strong>Cause</strong>: The shared module lacked explicit interfaces or documentation. For instance, a UserProfileViewModel emitted states via StateFlow, but the state structure wasn’t intuitive for SwiftUI, which expects Combine publishers or async streams. iOS developers, unfamiliar with Kotlin, couldn’t easily decipher the intent of state transitions, leading to misinterpretations.</p><p><strong>Impact</strong>: Ambiguity forced iOS developers to create workarounds, such as duplicating state logic or misusing shared data, resulting in inconsistent behavior and bugs that were hard to trace.</p><h3>3. View-Layer Logic Overload</h3><p><strong>Description</strong>: iOS views were bloated with business logic that belonged in ViewModels or higher layers, violating MVVM principles.</p><p><strong>Cause</strong>: The shared ViewModels were difficult to integrate with SwiftUI due to their Android-centric design and lack of Swift-friendly APIs. Rather than wrestle with Kotlin or debug shared code, iOS developers pushed logic into SwiftUI views, prioritizing feature delivery over architecture.</p><p><strong>Impact</strong>: The iOS codebase became unreadable, with tightly coupled views that were hard to test or refactor. This anti-pattern made maintenance a nightmare and increased technical debt.</p><h3>4. Debugging Nightmares</h3><p><strong>Description</strong>: Debugging shared Kotlin code from Xcode was nearly impossible, forcing iOS developers to rely on logs or guesswork.</p><p><strong>Cause</strong>: KMM’s tooling for iOS is immature compared to Android. Breakpoints in shared code rarely worked in Xcode, and iOS developers lacked Kotlin expertise to debug in IntelliJ. The team’s siloed structure meant Android developers handled shared code, leaving iOS developers in the dark.</p><p><strong>Impact</strong>: Without effective debugging, iOS developers resorted to duplicating logic or adding excessive logging, further degrading code quality and slowing development.</p><h3>5. Team Silos and Lack of Collaboration</h3><p><strong>Description</strong>: Android and iOS teams operated independently, with minimal cross-platform collaboration, exacerbating all other issues.</p><p><strong>Cause</strong>: The team structure separated Android and iOS developers, with Android developers owning the shared module. iOS developers had little exposure to Kotlin and no incentive to contribute to shared code, creating a disconnect in priorities and understanding.</p><p><strong>Impact</strong>: Silos led to misaligned implementations, with iOS developers treating shared code as a black box and Android developers unaware of iOS pain points. This lack of collaboration perpetuated anti-patterns and hindered codebase cohesion.</p><h3>Solutions: A Path to KMM Success</h3><p>Drawing on my experience as a mobile solutions architect, I believe these pitfalls can be addressed with a combination of architectural improvements, team alignment, and better tooling. Below are my proposed solutions, inspired by patterns like Clean Architecture and the Strangler Pattern, tailored to our KMM project’s challenges.</p><h3>1. Adopt a Contract-First Architecture</h3><p>To address logic forking and ambiguous state models, I propose a <strong>contract-first architecture</strong>, where shared logic is defined by explicit, platform-agnostic interfaces. For example, a UserProfileContract could define a state model and actions:</p><pre>sealed interface UserProfileState {<br>    data object Loading : UserProfileState<br>    data class Success(val profile: UserProfile) : UserProfileState<br>    data class Error(val message: String) : UserProfileState<br>}</pre><pre>interface UserProfileContract {<br>    val state: StateFlow&lt;UserProfileState&gt;<br>    suspend fun fetchProfile(userId: String)<br>}</pre><p>On iOS, we can create Swift wrappers to integrate with SwiftUI:</p><pre>class UserProfileViewModel: ObservableObject {<br>    @Published var state: UserProfileState<br>    private let contract: UserProfileContract</pre><pre>    init(contract: UserProfileContract) {<br>        self.contract = contract<br>        contract.state.asPublisher().assign(to: &amp;$state)<br>    }</pre><pre>    func fetchProfile(userId: String) async {<br>        await contract.fetchProfile(userId: userId)<br>    }<br>}</pre><p>This approach ensures shared state is clear, reusable, and adaptable to both platforms, reducing forking and ambiguity.</p><h3>2. Use the Strangler Pattern for Incremental Refactoring</h3><p>If a full refactor is impractical, I recommend the <strong>Strangler Pattern</strong> to gradually replace legacy code. Start with a high-impact feature, like user authentication, and implement it using a contract-first approach alongside the existing code. Use a facade to toggle between old and new implementations:</p><pre>object AuthFacade {<br>    private val legacyAuth = LegacyAuthService()<br>    private val newAuth: AuthContract = AuthContractImpl()</pre><pre>    suspend fun login(email: String, password: String): AuthState {<br>        return if (useNewImplementation()) {<br>            newAuth.login(email, password)<br>            newAuth.state.value<br>        } else {<br>            legacyAuth.login(email, password)<br>        }<br>    }<br>}</pre><p>This allows us to test new code without disrupting existing functionality, phasing out legacy code as confidence grows.</p><h3>3. Move Logic Out of Views</h3><p>To eliminate view-layer logic overload, we must enforce MVVM principles by ensuring shared ViewModels are accessible and reactive. For iOS, expose shared state as Combine publishers or async streams, aligning with SwiftUI’s declarative nature. Enforce this through code reviews and static analysis tools like SwiftLint.</p><h3>4. Improve Debugging Workflows</h3><p>To address debugging challenges, enhance shared code with comprehensive logging (e.g., using Kermit) and write unit tests for shared logic using Kotlin Test. Train iOS developers on basic Kotlin debugging in IntelliJ, and set up CI/CD pipelines to run tests across both platforms, catching issues early.</p><h3>5. Break Down Team Silos</h3><p>Foster cross-functional teams where Android and iOS developers collaborate on shared code. Conduct workshops to teach iOS developers basic Kotlin and Android developers SwiftUI basics. Encourage pair programming and cross-platform code reviews to align priorities and share knowledge.</p><h3>6. Document and Standardize</h3><p>Create clear documentation for shared contracts, state models, and integration patterns. Use tools like Dokka for Kotlin and Jazzy for Swift to generate API docs. Standardize naming conventions and architecture patterns to improve codebase readability.</p><h3>Lessons Learned and Moving Forward</h3><p>My experience with this KMM project has been a humbling reminder that cross-platform development requires more than just shared code — it demands thoughtful architecture, robust tooling, and team collaboration. Above all else it requires stakeholder buy in and understanding to allocate resources accordingly. The anti-patterns we faced, from logic forking to view-layer bloat, stemmed from a lack of clear contracts and siloed workflows. By adopting a contract-first architecture, leveraging the Strangler Pattern, and fostering cross-platform collaboration, we can turn these pitfalls into opportunities for a more cohesive, maintainable codebase.</p><p>If you find yourself in this situation, it’s crucial to take proactive steps toward improving your team’s approach. Start by prototyping a contract-first feature to establish clear boundaries between platforms, advocate for cross-functional collaboration to break down team silos, and invest in better debugging workflows for shared code. Kotlin Multiplatform has immense potential, but unlocking it requires discipline, clarity, and a shared commitment to bridging the gap between platforms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=525df7058018" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When DRY Backfires: Why Abstraction Needs Architecture]]></title>
            <link>https://medium.com/@karelvdmmisc/when-dry-backfires-why-abstraction-needs-architecture-81b14ef34518?source=rss-2af0d8c82993------2</link>
            <guid isPermaLink="false">https://medium.com/p/81b14ef34518</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Karel van der Merwe]]></dc:creator>
            <pubDate>Wed, 11 Jun 2025 15:01:42 GMT</pubDate>
            <atom:updated>2025-06-11T15:10:40.871Z</atom:updated>
            <content:encoded><![CDATA[<p>DRY but at what cost?</p><p>The DRY principle — <strong>Don’t Repeat Yourself</strong> — is one of the most quoted ideas in software engineering. At first glance, it’s intuitive: duplication is bad, so eliminate it. But in practice, especially in large or evolving systems, DRY can become dangerous — <strong>not because it’s wrong, but because it’s incomplete.</strong></p><p><strong>DRY without architectural foresight often leads to tight coupling, brittle abstractions, and a tangled mess of dependencies.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lsrU3nzFNGmvJ6PFDNYigQ.png" /></figure><h3>The Illusion of Progress</h3><p>When engineers apply DRY early in a project, it often feels like progress. Shared functions, helper classes, and utility layers multiply — code becomes “cleaner,” duplication disappears.</p><p>But then, as the system grows, something breaks:</p><ul><li>A small change in a shared utility has unintended consequences in multiple features.</li><li>A new requirement doesn’t fit the abstraction and forces ugly workarounds.</li><li>Teams can’t move independently because they’re tied to each other’s logic through shared code.</li></ul><p>That’s not just unfortunate. It’s a failure of <strong>architecture</strong>.</p><h3>DRY Assumes You Know the Shape of the System</h3><p>The core danger of DRY is that it assumes you have enough insight into your system’s <strong>boundaries</strong> to safely share logic. But most teams <strong>start DRYing code before the architecture is fully understood</strong>, and that’s where it backfires.</p><p>DRY works best when the architecture is:</p><ul><li><strong>Well-bounded</strong> (clear module or domain boundaries),</li><li><strong>Stable</strong> (not shifting rapidly),</li><li><strong>Consciously designed</strong> (not just grown organically).</li></ul><p>Without those, DRY prematurely locks parts of the system together based on surface-level similarities, not deep understanding.</p><h3>Tight Coupling: DRY’s Unintended Side Effect</h3><p>Suppose two features both validate user input in similar ways. A naive DRY implementation might extract a shared validateUserInput() method. Now both features depend on the same code. But if one feature&#39;s validation rules change, the other is impacted—or worse, breaks.</p><p>This creates a form of <strong>tight coupling</strong>: when two parts of the system rely on a shared abstraction that doesn’t fit either perfectly, changes in one ripple into the other. Over time, these shared abstractions become landmines no one wants to touch.</p><h3>Architecture First, DRY Second</h3><p>Instead of jumping to DRY, <strong>build boundaries first</strong>:</p><ul><li><strong>Split features by business domains</strong> (using domain-driven design).</li><li><strong>Use modules or layers to isolate concerns</strong>.</li><li><strong>Duplicate tactically</strong> until a pattern emerges <em>within a well-defined boundary</em>.</li></ul><p>Once the architecture is stable and responsibilities are clear, then you can start abstracting confidently — knowing that shared logic has a natural home.</p><h3>Better Than DRY: Contextual Reuse</h3><p>Instead of mindlessly applying DRY, consider these alternatives:</p><ul><li><strong>AHA</strong>: <em>Avoid Hasty Abstractions</em>. Let duplication teach you where abstractions should live.</li><li><strong>DDD</strong>: <em>Domain-Driven Design</em>. Build software around the business, not just code shape.</li><li><strong>SRP</strong>: <em>Single Responsibility Principle</em>. Keep units of code focused and replaceable.</li><li>Composition over inheritance.</li></ul><p>These approaches don’t reject DRY — they <strong>contextualize it within the broader goal of resilient architecture</strong>.</p><h3>Conclusion</h3><p>The DRY principle isn’t inherently bad — but when applied without a holistic view of the system, it <strong>destroys cohesion</strong>, <strong>introduces tight coupling</strong>, and <strong>slows progress</strong>.</p><p><strong>Duplication is not your enemy — premature abstraction is.</strong></p><p>So next time you’re tempted to “clean up” code with DRY, ask yourself:</p><blockquote>Do I understand the architecture well enough to share this logic?</blockquote><p>If the answer is no, maybe the right move isn’t to abstract — but to wait, observe, and let the architecture guide you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81b14ef34518" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The software engineer hipster and how this counterculture affects your team.]]></title>
            <link>https://medium.com/@karelvdmmisc/the-software-engineer-hipster-and-how-this-counterculture-affects-your-team-fc2cfa24c2a6?source=rss-2af0d8c82993------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc2cfa24c2a6</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Karel van der Merwe]]></dc:creator>
            <pubDate>Sun, 05 May 2024 20:02:44 GMT</pubDate>
            <atom:updated>2024-05-06T20:51:57.510Z</atom:updated>
            <content:encoded><![CDATA[<p>I have recently coined the phrases “code hipster” and “hipster code smell”. Let me explain what I mean by that in a bit more detail.</p><p>We all have that one person in our circle of friends, you know the one who always embraces counterculture and always gravitates towards the alternative for no other reason than to be different. These individuals often react with disdain to any common practices or well defined methods.</p><p>When it comes to software engineering this is no different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*2szJrXU2r8AcHche.jpg" /></figure><p>For example I will use the task of choosing a library. If you have had some experience as an engineer you should know by now that choosing any third party library is not a task to be taken lightly.</p><p>Now a normal software engineer would probably do his research and pick the top supported, most widely used library that also meets all the defined criteria.</p><p>Say for instance this is a mobile application that will be used across a wide range of non generic devices and say the library is a networking library.</p><p>The normal engineer would realize the importance of using a widely used, well supported library, since it is most likely that the non generic device manufactures would have tested with this library to made sure it works. At the very least there will be other apps running on that device experiencing the same issue and it is likely that someone would have found a workaround or the manufacturer is working on a fix.</p><p>The hipster engineer is most likely to pick a fringe library that is not widely used and has unknown support. They will justify their decision by citing reasons from minor performance differences (that will never be noticed in real life) to minor size differences or ease of use.</p><p>Now lets look at the likely outcome of the above decision. As mentioned above this is a networking library. Now we are in a position where the entire data layer is built around this library. QA is happy since it passed on all known devices and the app is released.</p><p>The fun however begins a few months later when there is a request to test support for a new device type - big surprise the library does not work on the device as intended. The hipster engineer has since left the company and you are now tasked with adding support for this device.</p><p>The first thing you do is test with a go to mainstream library and it works perfectly, so you start looking for support. Unfortunately there is very little support at all for the said library - never mind the library and device combination.</p><p>You spend a few hours trying to debug the issue looking for a workaround since you know changing the library at this point would mean refactoring the entire data layer (that is if you are lucky and the app even has some kind of layered architecture) - not to mention that the app would also have to go through a full QA cycle across multiple devices.</p><p>After several hours and a lot of frustration you realize that the only option is to change the library. In this case setting off the chain reaction of refactoring your data layer and QA needing to go through a complete testing cycle of the app.</p><p>This was a really costly exercise for the company holistically but what is even more damaging here is the team culture and work environment these individuals seem to create. They are usually so blinded by the need to be seen as special they have a tendency to heavily criticize anyone in the team who questions these “counterculture” decisions. Junior developers are usually especially susceptible to copying these bad habits.</p><p>If this is a senior engineer you are very likely to end up with a codebase where “counterculture” patterns were encouraged. Similar issues are bound to keep popping up, out of the box OS functionality is less likely to work as indented and even less likely to be future proof.</p><p><strong>As software engineers we make decisions not for ourselves but for the team, the product and those that will work on the codebase after us, because they will have to live with the consequences of our decisions.</strong></p><p>These individuals can be extremely difficult to impossible to work with and at times the best you can do is highlight this during code reviews.</p><p>Examples of hipster code smells:</p><ol><li>Unnecessary usage of counterculture patterns, libraries and methodologies, for no apparent reason other than to be different.</li><li>Premature optimization over readability.</li><li>Reinventing the wheel over using proven practices and patterns.</li><li>To new hires and new starters the codebase will look nothing like the established standards they would expect.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc2cfa24c2a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>