<?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 Dimitar Zabaznoski on Medium]]></title>
        <description><![CDATA[Stories by Dimitar Zabaznoski on Medium]]></description>
        <link>https://medium.com/@dimitar.zabaznoski?source=rss-e5292586a700------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*y_C-UPVmK1PFs0RKc8iozA.jpeg</url>
            <title>Stories by Dimitar Zabaznoski on Medium</title>
            <link>https://medium.com/@dimitar.zabaznoski?source=rss-e5292586a700------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 10:13:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dimitar.zabaznoski/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[Modularize your Kotlin Multiplatform Project]]></title>
            <link>https://medium.com/web-factory-llc/modularize-your-kotlin-multiplatform-project-6e5831508a81?source=rss-e5292586a700------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e5831508a81</guid>
            <category><![CDATA[ports-and-adapters]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[modular-design]]></category>
            <dc:creator><![CDATA[Dimitar Zabaznoski]]></dc:creator>
            <pubDate>Sat, 18 May 2019 19:30:50 GMT</pubDate>
            <atom:updated>2021-07-11T22:48:16.864Z</atom:updated>
            <content:encoded><![CDATA[<p>A sample project using Kotlin Multiplatform to build a currency converter app for iOS and Android with multiple shared modules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ph9BPqk1M6A4s98T" /><figcaption>Photo by <a href="https://unsplash.com/@florianklauer?utm_source=medium&amp;utm_medium=referral">Florian Klauer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Intro to Kotlin Multiplatform</h3><p>Kotlin Multiplatform provides a mechanism for sharing code among platforms. The key difference from many other cross-platform tools is that it doesn’t compile all code to platform specific code. Instead, we are given full control over what will be shared and what will be native. Generally, we choose to share the business logic and leave the UI be native to the platform for more natural user experience. This allows us to reap the benefits of writing cross-platform solutions without any of the limitations that usually come with it, like their inflexibility when it comes to writing platform-specific code.</p><p>This is implemented by using the Common <a href="https://kotlinlang.org/api/latest/jvm/stdlib/index.html">Kotlin standard library</a> to write the shared module and then compiling the code to different target platforms — JVM, JS, and Native. This means then Kotlin/JVM or any Java or Javascript code can’t be used to write the shared code. Accessing the platform APIs is done by using the provided <a href="https://kotlinlang.org/docs/reference/platform-specific-declarations.html">expect/actual mechanism</a>.</p><p>This is the short version, for more information check out the <a href="https://kotlinlang.org/docs/reference/multiplatform.html">official documentation</a>.</p><h3>Modularization</h3><p>The motivation for breaking the shared code into modules is to prevent it from growing into one giant module with tons of responsibilities, coupled features, hardcoded dependencies, some low-level utilities, and anything that can be shared. Basically, our app without UI. <br>Instead we should aim to create many components, independent from one another, providing a very focused set of functionality. Client apps then have complete control over what they depend on and use.</p><p>We can modularize our app around features. In the following example, the currency converter is one feature in a much larger system, that is developed independently from other components, e.g. analytics or user management. <br>We can further develop the currency converter by abstracting away dependencies to external resources and infrastructure, allowing us to e.g. easily switch servers or use different HTTP clients on different platforms.</p><p>The architecture followed in this sample is <strong>Hexagonal Architecture</strong> (a.k.a. Ports and Adapters). Hexagonal architecture isolates the central logic of our application from the outside concerns by placing the inputs and outputs at the edge of our design. This allows us to easily swap their implementation without changing the central logic. For more details here’s an <a href="https://github.com/jankovd/dagger2-ports-and-adapters">android sample project</a> that applies this architecture with Dagger 2.</p><h3>Currency converter</h3><p>The currency converter app provides an exchange rate based on an input from-to currency pair i.e. the rate at which one currency will be exchanged for another.</p><p>The app has an exchange rate provider that fetches rates from a data source like a server, a database, or in our case a mock source with hardcoded values. When a conversion is requested the app uses a rate calculator to find a conversion path between the two currencies.</p><p>The main entry point for using the converter is the <strong>CurrencyConverter </strong>component. The converter internally uses an <strong>ExchangeRateProvider </strong>that fetches exchange rate data and a <strong>RateCalculator</strong> performing the conversion. <br>When building the converter the clients are required to plug-in an ExchangeRateProvider implementation to make it fully functional. This is how we allow customizability of our feature.</p><p>The source code on GitHub &gt; <a href="https://github.com/webfactorymk/kotlin-multiplatform-currency-converter">webfactorymk/kotlin-multiplatform-currency-converter</a></p><h4>A high-level diagram of the solution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*Z-7KmOmkZLU_2NCuBr-KHw.png" /></figure><h4>Modules</h4><ul><li><strong>currency-converter-core</strong> — The core module contains only the domain logic without implementation.</li><li><strong>rate-provider-mock</strong> — A mock implementation of a rate provider with dummy exchange rates. Works on all platforms.</li><li><strong>rate-provider-api-ktor — (TBD)</strong> <a href="https://ktor.io/clients/http-client/multiplatform.html">Ktor</a> implementation of a rate provider. Ktor is a multiplatform Http client so we can use this module for all target platforms.</li><li><strong>rate-provider-api-retrofit — (TBD)</strong> <a href="https://square.github.io/retrofit/">Retrofit</a> implementation of a rate provider. This is a great library but it targets Java and Android. This means that for the other target platforms we can not use this module.</li><li><strong>ios-configuration — </strong>At this version (Kotlin 1.3) the iOS app supports only one K/MPP module. To bypass this and achieve a multi-module app this module will include all modules for the iOS application and be added to the iOS app.</li></ul><h4>Usage in client apps</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04cf59f61250d4a2723da81773964220/href">https://medium.com/media/04cf59f61250d4a2723da81773964220/href</a></iframe><p><em>For complete reference see the </em><a href="http://htmlpreview.github.io/?https://github.com/webfactorymk/kotlin-multiplatform-currency-converter/blob/master/core/javadoc/common/core/mk.webfactory.dz.converter.currency.core/index.html"><em>JavaDoc</em></a><em>.</em></p><h4>Screenshots</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*OyacTmzYknNSGryWUKzXkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*HuwfyHkpfj-8ecmhq8ze7g.png" /><figcaption>Android app (left) &amp; iOS app (right; *one can see I’m an Android developer)</figcaption></figure><h3>Limitations</h3><h4>The IDEs are not quite prepared</h4><p>There is still no single IDE in which you can develop for all platforms supported by multiplatform. You’ll need to jump from IDEA to Android Studio, to Xcode, etc. Configuring gradle for use of multiple shared modules is not straight forward, and is something that needs to be done by hand. The bigger downside is that multiplatform is still not a finished product, and until then, we can expect that there will be additional build issues introduced in newer releases. However, this is all common for a feature still in development.</p><h4>Multiple K/MPP frameworks for iOS</h4><p>The iOS module is packaged as a framework and currently, there cannot be more than one Kotlin Multiplatform framework imported in the iOS project. This doesn’t play well with modular design described in this sample. As a workaround, a new ios-configuration module is added to include the iOS dependencies. <a href="https://github.com/JetBrains/kotlin-native/issues/2423">This thread</a> contains more information.</p><p>There is currently no support in gradle for building iOS projects, and it takes some effort to set up an automatic framework link to the iOS project, especially with multiple shared modules. This is a hurdle that you need to pass, as it is useful because it enables changes in shared modules to be automatically imported to the iOS project.</p><h3>Gradle multi-module project</h3><p>Gradle is used as a build automation tool since it supports the currently used platforms except for iOS.</p><p>For this sample, an empty gradle project was created and modules were gradually added as described in <a href="https://guides.gradle.org/creating-multi-project-builds/">this tutorial</a>.</p><h3>Summary</h3><p>Breaking the shared code into multiple modules that serve a specific purpose will create components with limited scope that are more readable, reliable, and maintainable. Client applications can then choose what they need and tailor a specific configuration that will best fit the platform. The benefits of this design over having one all-purpose shared module are worth considering.</p><p><em>Thanks to </em><a href="http://jankovd.mk/"><em>Dejan Jankov</em></a><em> for reviewing the draft versions of this post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e5831508a81" width="1" height="1" alt=""><hr><p><a href="https://medium.com/web-factory-llc/modularize-your-kotlin-multiplatform-project-6e5831508a81">Modularize your Kotlin Multiplatform Project</a> was originally published in <a href="https://medium.com/web-factory-llc">Web Factory LLC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code assessment checklist]]></title>
            <link>https://medium.com/web-factory-llc/code-assessment-checklist-b927083495ef?source=rss-e5292586a700------2</link>
            <guid isPermaLink="false">https://medium.com/p/b927083495ef</guid>
            <category><![CDATA[quality-software]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Dimitar Zabaznoski]]></dc:creator>
            <pubDate>Fri, 23 Nov 2018 18:11:48 GMT</pubDate>
            <atom:updated>2018-11-23T18:11:48.490Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s say you’ve written a piece of code with all the clean code principles and all the cool patterns in mind. You run the code, it works. Now, would you go through a reverse process and rate the quality of your work, find design flaws, potential bugs, and breaking points?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_pSybxrA_6bPMU3C" /><figcaption>Photo by <a href="https://unsplash.com/@tyler_milligan_visuals?utm_source=medium&amp;utm_medium=referral">Tyler Milligan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When writing code you have the option to stop as soon as the code does the specific job you have at the moment, or you can design the components to be standalone, less bug-prone, easy to understand, scalable and testable. With the second approach, you will end up with an app that is adaptable to change, easy to maintain, and long-lasting. This will save you a lot of headaches and, even though it seems counter-intuitive, it’s faster to develop clean code than a mess of interconnected dependencies that will blow up some day.</p><p>All the principles and design patterns can be a little abstract, especially if you’re reading the formal definition for the first time without looking at meaningful examples. After designing a component, it’s important to take some time to look back at the code. Your best chance at doing a refactor is during the development process, afterward, it just gets tougher as time goes by.</p><p>Here’s a checklist to go through:</p><ol><li><strong>The code is easily testable<br></strong>This is one of the most effective ways to assess your code since it will point out design flaws instantly. Even if you don’t write tests, check if you need too many mock objects for your component. If you need half a platform, a web server, and a file system you are doing something wrong.</li><li><strong>A change has low impact on the code<br></strong>Just imagine your client and all the possible future requirements that creative devil can think of. How will your system handle the potential changes? Will you need a new design from scratch?<br>Note that you can’t predict all the possible scenarios that can happen and you shouldn’t design a system that handles everything. However, you can have multiple standalone, single responsibility components that do not heavily depend on each other that you can add/remove/modify to fit the new design.</li><li><strong>Adding and removing components takes little effort<br></strong>Suppose you want to add a caching mechanism. Every component that has nothing to do with the data management in your app should not be affected. <br>Afterwards, changing the cache implementation would ideally affect only the dependency injection section of the app where you decide what concrete implementation you want.</li><li><a href="http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod"><strong>SOLID</strong></a><strong> principles not violated</strong></li><li><strong>What are its breaking points?</strong> <br>Is it encapsulated just enough? Can someone easily extend its behavior, but not be able to break it? Can you find any bugs?</li><li><strong>Easy to understand<br></strong>You will get back to this code at some point. You should be happy when you do, not in denial.</li><li><strong>Formatted code<br></strong>It’s surprising how important this is! Nobody wants to read an unstructured mess.</li><li><strong>Well documented methods and classes, but no line comments<br></strong>No redundant documentation, just brief specification where needed.<br>Having line comments usually means having poor naming or a too long method.</li><li><strong>Ask for a code review<br></strong>Another set of eyes will reveal another set of problems.</li><li><strong>Finally, the test of time</strong><br>Release it, see what happens :)</li></ol><p>This is a checklist I’ve gathered through time and find useful when assessing a component I’ve just written. <br>What would you add? Am I missing something important?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b927083495ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/web-factory-llc/code-assessment-checklist-b927083495ef">Code assessment checklist</a> was originally published in <a href="https://medium.com/web-factory-llc">Web Factory LLC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>