<?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 Yaroslav T on Medium]]></title>
        <description><![CDATA[Stories by Yaroslav T on Medium]]></description>
        <link>https://medium.com/@tyschenko?source=rss-ac32252881d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jmhxgmAoLwNzbEwKsp3t6g.jpeg</url>
            <title>Stories by Yaroslav T on Medium</title>
            <link>https://medium.com/@tyschenko?source=rss-ac32252881d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:18:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tyschenko/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[12 Soft Skills for a Senior Engineer]]></title>
            <link>https://tyschenko.medium.com/12-soft-skills-for-a-senior-engineer-837362d9888b?source=rss-ac32252881d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/837362d9888b</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[senior-engineer]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[soft-skills]]></category>
            <category><![CDATA[career-growth]]></category>
            <dc:creator><![CDATA[Yaroslav T]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 08:06:01 GMT</pubDate>
            <atom:updated>2024-06-24T08:06:01.948Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbiIUElootqwVejjsAULoQ.png" /></figure><p>Your growth as a software engineer slows down at some point. Usually, this happens when you become a Senior individual contributor: you can code large features independently with decent speed and quality. At this moment, your hard skills are most likely developed enough, and you need to <strong>focus on soft skills</strong>. Below is a list of 12 soft skills that, in my opinion, every senior engineer should have. I moved away from abstract words like “proactive” and focused on skills whose descriptions take a full sentence and could be observed in more experienced colleagues of your company.</p><p>This article won’t explain how to develop these skills. Use it as a <strong>self-assessment tool</strong>, and for the skills you don’t have or consider weak, create a development plan. Having all of them will increase your value to the team, the company, and the job market!</p><h3>Communication Skills</h3><h4>1. Can neutralise a conflict between people and not generate conflicts myself. Control emotions and don’t let them ruin my work.</h4><h4>2. Can describe the same topic to people with different backgrounds and knowledge (e.g., engineers and designers, new joiners and veterans).</h4><h4>3. Can use the proper communication instrument depending on the situation and participants: online chat, video call, in-person meeting, email, or document in the wiki.</h4><h4>4. Can communicate in text and on calls clearly and effectively; don’t have to repeat or explain with other words.</h4><h3>Team Player Skills</h3><h4>5. Can keep my promises and provide feedback if something doesn’t go as expected. If a promise is impossible to fulfill, can directly say “No.”</h4><h4>6. Can act like an owner for negative team outcomes. Resolve problems without blaming others and create a plan to prevent them from happening again.</h4><h4>7. Can identify what is wrong in the current workflow (bottlenecks, waste of time, or lack of something) and suggest improvements to team processes.</h4><h4>8. Can build work relationships with members of my team and other teams. Be the person with whom other people like to work.</h4><h3>Problem-Solving Skills</h3><h4>9. Can initiate a solution to a problem, resolve all obstacles, and verify if the problem is solved.</h4><h4>10. Can make a decision and take responsibility for it. Don’t wait for somebody else to decide and don’t postpone decision-making without reason.</h4><h3><strong>Mentoring Skills</strong></h3><h4>11. Can conduct 1:1 meetings on schedule with an agenda and use a framework that helps to identify problems and required actions.</h4><h4>12. Can motivate a person to achieve better results using financial and non-financial motivation. Can set goals or a development plan individually.</h4><p>If you don’t know where to start, get advice from your manager or mentor. It’s okay if you don’t have many skills; developing them requires only your desire, hard work, and a relatively short amount of time — all skills you can develop within a quarter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=837362d9888b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 Tips on how to set goals for yourself]]></title>
            <link>https://tyschenko.medium.com/4-tips-on-how-to-set-goals-for-yourself-8135de1742e9?source=rss-ac32252881d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8135de1742e9</guid>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[okr]]></category>
            <category><![CDATA[goals]]></category>
            <category><![CDATA[goal-setting]]></category>
            <category><![CDATA[management]]></category>
            <dc:creator><![CDATA[Yaroslav T]]></dc:creator>
            <pubDate>Sun, 21 Apr 2024 09:54:10 GMT</pubDate>
            <atom:updated>2024-04-21T09:54:10.590Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*mrPaTXn1d5Gw0riedPWN2Q.png" /></figure><p>For personal development, it’s crucial to set goals. They help you build a development plan, create tasks to do in your spare time, and can lead to your promotion. I believe that goals should be adjustable and short-term to remain aligned with your current needs. Personally, I set goals for myself <strong>every quarter</strong> and would like to share my approach.</p><h4>3 common mistakes people make when setting goals:</h4><ol><li>Considering mandatory work as a goal (e.g., Cover feature with tests)</li><li>Using abstract words that don’t make the goal specific and measurable (e.g., Become an independent contributor)</li><li>Making goals dependent on constraints unrelated to you (e.g., Finishing project X, for which nobody knows when it’s going to kick off)</li></ol><p>Here are my hints and some examples for each.</p><h4>Make them personal</h4><p>Imagine you are going to leave your current position in three months. What skills or knowledge do you need to secure a better job and be more successful? If you encounter any pain points at work, focus on resolving them for personal growth.</p><p>If it’s not your own startup, set goals unrelated to the company you work for unless you can benefit from them, such as promotion, improved workload, or resolving recurring issues you have faced.</p><ol><li>Read the three most popular books on giving feedback, write down learned techniques, and apply them with your reports</li><li>Automate routine task X to decrease paperwork by four hours per week</li><li>Sign up for and complete a management course on Coursera</li></ol><h4>Make them measurable</h4><p>Some goals may be binary in nature, meaning they are either achieved or not, while others can be measured on a scale from 1 to 10. In my opinion, a measurable goal is one for which you know what has been accomplished and improved.</p><p>When setting your goal, think about the current state and how the situation could be enhanced. If the goal seems too abstract, consider focusing on a potential outcome one level lower. For example, a goal such as “Dedicate one day per week to bug fixes” could be improved with additional information like “Dedicate one day per week to bug fixes and decrease the number of negative reports by 15%”.</p><ol><li>Increase test coverage from 80% to 95%</li><li>Write down action items from every retrospective session, assign a responsible person and deadline, and ensure that 80% of items are resolved before the end of Q3</li><li>Complete internal training to become a SCRUM master (an example of a goal that is either done or not)</li></ol><h4>Mix them up by time, urgency, and personal profit</h4><p>Set yourself <strong>small</strong> goals and <strong>big</strong> goals. Include <strong>quick wins</strong> and goals that might be too complex to accomplish in one quarter. It’s important to have goals you can pursue in spare time, like one hour, and in a longer timeframe, such as multiple weeks. If the goal is significant, add multiple milestones, but keep the original goal in mind to <strong>not lose sight of it</strong>.</p><p>Many people don’t recommend setting more than 5 goals, but in my opinion, the more goals you have, the easier it is to find what to do depending on the situation. It’s better to finish 4 goals out of 10 than 3 out of 3.</p><ol><li>Fix the problem with missing Slack notifications from TeamCity (small, quick win, urgent)</li><li>Create an online course for new employees with 8 hours of video materials on topics X, Y, Z (big, too complex for a quarter, not urgent, can have milestones like ‘Prepare a video on the topic X’ and eventually lead to a promotion)</li></ol><h4>Write them down and share</h4><p>Share with people responsible for your promotion and those affected by your goals. For example, if you want to improve the team’s planning of sprints, let team members know first.</p><ol><li>Start conducting skip-level report meetings to collect feedback on my reports (share this goal with reports to have them aligned).</li><li>Increase the number of sales in the US market by 35% (share with your manager and, if successful, make it a reason for your promotion).</li></ol><h4>Conclusion</h4><p>There are many frameworks you might have heard about, like SMART or OKRs. Start setting goals for yourself, write down results, and adjust if needed. As I already mentioned, it’s better to finish 4 goals out of 10 than 3 out of 3. Remember that with proper goals every quarter, you will become a better professional!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8135de1742e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Key steps to make a Retrospective more efficient]]></title>
            <link>https://tyschenko.medium.com/3-key-steps-to-make-a-retrospective-more-efficient-20cf758602bc?source=rss-ac32252881d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/20cf758602bc</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[meetings]]></category>
            <category><![CDATA[agile]]></category>
            <dc:creator><![CDATA[Yaroslav T]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 12:39:00 GMT</pubDate>
            <atom:updated>2023-12-11T12:39:00.421Z</atom:updated>
            <content:encoded><![CDATA[<h3>3 Key Steps to Make a Retrospective More Efficient</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jUkNRZn8w-ot7tqG27OJ2Q.jpeg" /></figure><p>No matter how you organize your team’s work, whether it be Scrum, Kanban, Waterfall, or none of the above, I highly recommend conducting <strong>Retro</strong> (short for Retrospective) calls with your team. It’s the easiest and fastest tool to identify problems, blockers, and bottlenecks affecting your team’s performance. In this article, I am not going to explain how Retro works in general; instead, I would like to focus on three things I personally use to make my Retro more efficient, useful for both managers and peers, and effective in solving problems.</p><h4>Focus on Action points instead of Positives and Negatives</h4><p>2 signs you need to do that:</p><ol><li><strong>Similar</strong> problems have been raised before or are raised every time.</li><li>Retro has only a <strong>psychological</strong> effect; it doesn’t improve work processes or solve existing issues.</li></ol><p>If some of the points above are valid for your team, convert the last column on the Retro board into a <strong>TO-DO</strong> list:</p><ol><li>For every problem written in the <strong>Negatives</strong> column, come up with an Action point. Avoid generic ones; instead, formulate it as a clear <strong>task</strong> (e.g., instead of “Improve testing,” write “Schedule a call every two weeks to perform battle testing before release; invite John and Sam”).</li><li><strong>Assign</strong> every problem to a dedicated person. If it’s a one-off task, create a <strong>ticket</strong>. If the solution requires regular work, document it or create a recurring calendar event to remind.</li><li>Start every Retro by reviewing <strong>previous</strong> action points. If something wasn’t done, understand why. Copy that action point to your current Retro and update it to ensure achievement. This way, every team member can see that their problems are addressed and not forgotten, and the Retro is not a waste of precious time.</li></ol><h4>Collect Negative Feedback All the Time Instead of Last Minute</h4><p>Imagine you have a Retro on the last Friday of each month. If a problem occurred on the first Monday, there’s a 99% chance you will forget about it. Collect negative feedback through <strong>all channels</strong> and write it down on the board immediately to not miss a thing. Here are some situations when problems are raised but usually forgotten:</p><ol><li>The problem was raised in the middle of a long Slack thread.</li><li>You have a shy engineer who usually doesn’t highlight problems on group calls but can mention it in a <strong>1-to-1</strong>.</li><li>The problem is a reason for some behavior but is never <strong>reflected</strong>. For example, your iOS and Android engineers started working at the same time. iOS is done, but the Android engineer in Standup says, “I need two more days for development and one day I am going to test every scenario manually.” It’s a perfect situation to understand if there’s something you can improve as a manager. Does the development take more days due to legacy code you can refactor next quarter, or is the lack of UI tests on Android making the engineer do manual testing? The engineer is already accustomed to such a situation, so ask <strong>clarifying questions</strong> to exclude problems to be solved.</li></ol><h4>Create Space for Everyone to Speak</h4><ol><li>Question every person affected by the problem. Using a legacy code example, ask each Android engineer in the team, <strong>one by one</strong>, for their opinion on what action point we can take. Depending on temperament, you may hear answers ranging from “Rewrite everything” to “It’s okay, I can work with it.” After everyone has spoken, ask engineers from other platforms about their usual approaches. Finally, come up with an answer that satisfies every team member, especially Android engineers affected by the mentioned problem. Don’t turn it into a process where an engineer mentions a problem, provides a solution, and you simply move on to the next issue.</li><li>Don’t <strong>mix</strong> problems and action points. If someone wrote three negative points in one, split them and discuss each separately. Don’t be afraid to spend more time; use the approach from the first piece of advice to gather as much feedback on each of the three problems as you can.</li><li>Don’t be afraid of making the <strong>wrong</strong> decision. If, in a problem with legacy code, you agreed on an approach of minor refactoring but noticed no results, <strong>raise the problem again</strong>, gather opinions, and choose a different action point. Perhaps this time, you can try a more radical approach from another engineer. Such a situation will be correctly accepted by team members; the approach of one engineer didn’t work, the problem persists, and now we proceed with an approach from another engineer.</li></ol><h4>Conclusion</h4><p>In my opinion, Retro is the most effective tool to find and solve team problems. Unfortunately, Retro is like going to the gym; if you skip it often or do it without commitment, it won’t have any effect. Focus on making <strong>every</strong> Retro useful, and you should see positive results soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20cf758602bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evolution of translations management for Android at Revolut]]></title>
            <link>https://medium.com/revolut/evolution-of-translations-management-for-android-at-revolut-2f97b5969bfb?source=rss-ac32252881d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f97b5969bfb</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[translation]]></category>
            <category><![CDATA[gradle-plugin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Yaroslav T]]></dc:creator>
            <pubDate>Tue, 05 Dec 2023 17:28:50 GMT</pubDate>
            <atom:updated>2023-12-05T17:28:50.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xVflOy5xgdNVBDbIRR9qHg.png" /></figure><p>Here’s everything you need to know about how translations have evolved at <strong>Revolut</strong>. We currently have 6 apps, with 330 modules containing <em>strings.xml</em> files. And don’t forget, we need to support 33 languages.</p><p>To make the translation process smooth, we use the API of <a href="https://lokalise.com/">Lokalise</a>.</p><p>When one of our engineers adds a new string on the platform, it’s translated into all languages within 1 hour. After that, we need to download and place the translations into the correct module. Now, from an engineering perspective, here comes the most interesting part!</p><h4>Initial implementation</h4><p>In 2017, we began our expansion, and the first supported languages were French and Polish. We quickly reached a stage where fast translation became an integral part of the feature release process.</p><p>Using our partner, Lokalise.com, we started implementing translations for a single app (only Revolut retail app existed at the time).</p><p>We added Lokalise <a href="https://developers.lokalise.com/docs/android-sdk-v1">library</a> to our project and used keys from it via a Singleton pattern:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b55574683f8ebc328b4049d46f1114bf/href">https://medium.com/media/b55574683f8ebc328b4049d46f1114bf/href</a></iframe><p>Library downloads translations from the server once the user opens the app. This approach was fast to implement, but had 2 limitations:</p><ol><li>API has user limit, which is critical for the fast-growing application</li><li>Download translations on app launch degrades the performance</li></ol><h4>First script</h4><p>To answer both of these problems, we created a simple local script that downloads strings and puts them into the resources’ folder. Before releasing a new version of the app, one of the engineers has to call this script and merge translated files into the <em>release</em> branch.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78c6e72e4148de66b8d461b467b0df55/href">https://medium.com/media/78c6e72e4148de66b8d461b467b0df55/href</a></iframe><h4>Simplifying developers’ life</h4><p>Later on, one of our engineers introduced an additional script to upload keys to Lokalise. The goal was to let engineers create new keys in strings.xml during the development process, automatically upload them to the provider, translate them, and then download them back.</p><p>However, we soon discovered that this approach caused confusion: what should be the source of truth, if an iOS developer added the same key on the website, but an Android dev used the script, how to pick the correct key? As a result, after just one month, we decided to disable the new script.</p><h4>Migration to Groovy</h4><p>Python script was executed using a Gradle task:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/573f3122e41a7e2ecb4db0d92012a8f5/href">https://medium.com/media/573f3122e41a7e2ecb4db0d92012a8f5/href</a></iframe><p>Why do we need to wrap it, when we can easily write the same simple script in Groovy? If we’re going to run it on CI, we can remove dependency on Python. After 3 months of using Python script, we migrated to Groovy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10624bd5a8ffdc1d5d805e4f854ea605/href">https://medium.com/media/10624bd5a8ffdc1d5d805e4f854ea605/href</a></iframe><p>For the next 2 years, this script was our main way of downloading strings.</p><h4>Modularisation</h4><p>In 2019, with a large codebase (1+ million lines of code), we embarked on the journey of adapting modern approaches to address the growing build time and initiated the modularisation process. Soon, we realised that the existing script wasn’t flexible enough to be used in a multimodule environment, as it could only place files within the app module</p><p>We migrated to a more complex, but flexible solution using Yaml, Bash, and Kotlin. We used Yaml config to declare all required data, such as token, project ID (each app is represented by a different Localise project), languages, module names, and their corresponding files:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc7b73592f3f24f4b95a064d8e1b0e45/href">https://medium.com/media/fc7b73592f3f24f4b95a064d8e1b0e45/href</a></iframe><p>After parsing this config with Kotlin code, the translations were downloaded and placed into a dedicated module. To execute the Kotlin code, we utilised a Bash script, which was unique for each application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54659f06c25e0964c789be1465e3cc29/href">https://medium.com/media/54659f06c25e0964c789be1465e3cc29/href</a></iframe><p>It was a working solution, but complicated and overwhelming. Let’s highlight the key disadvantages we faced:</p><ul><li>Messy Yaml configs: same modules in different configs, hundreds lines of configuration in one file</li><li>Solution fragility in case of failure: if one config was broken, it caused downloading issues for all Revolut apps</li><li>Difficulty in sharing modules between apps: making modules shared between apps wasn’t straightforward, especially when translations belonged to different projects on Lokalise. For example, sharing a module from Revolut Business with Revolut &lt;18 app required the separation of Bash scripts and Yaml configs.</li><li>Hard to modify Bash script because we need to modify and test all 6 for each app every time</li><li>Inability to execute in parallel: the existing setup didn’t allow for parallel execution, slowing down the process.</li><li>Bash scripts and configs are hard to cover with unit or integration tests, leading to lack of good test coverage</li></ul><h4>Gradle solution</h4><p>We decided to implement a custom <a href="https://docs.gradle.org/current/userguide/custom_plugins.html">Gradle</a> plugin and move the existing downloading logic there. We can pass all required parameters, such as token or file name into Gradle configuration to get rid of Yaml. To get rid of Bash, we can create a Gradle task and execute it straight away for the module.</p><p>Let’s see how it works for the <em>feature_payments</em> module we saw in Yaml config. We need to add these lines to its build.gradle file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/305887e29438281159297fe96c9ce5a0/href">https://medium.com/media/305887e29438281159297fe96c9ce5a0/href</a></iframe><p>To download translations, we have to execute our new task <strong>downloadStrings</strong> using this simple line in the terminal:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df0876b9cd51e48f977e9453481c0535/href">https://medium.com/media/df0876b9cd51e48f977e9453481c0535/href</a></iframe><p>To download Strings for all apps, we can run <em>./gradlew downloadStrings</em></p><h4>How the task works under the hood</h4><ol><li>Clear all files in the module with pattern strings_*.xml</li><li><a href="https://developers.lokalise.com/reference/download-files">Download</a> translations archive from Lokalise api</li><li>Unzip and place files in the module</li></ol><p><strong>Pros of the new approach:</strong></p><ul><li>Each module is configured independently. No more Yaml configs with 300 lines of configuration</li><li>Making modules shared between apps has become effortless, requiring no changes to the configuration</li><li>No need to maintain multiple Bash scripts</li><li>Downloading and moving files can be done in parallel, speeding up the process</li><li>Unit and integration tests on Kotlin included into the CI pipeline to make sure everything works as expected</li><li>The plugin is written on Kotlin, a language familiar to every Android developer in the company, making it easy for them to contribute</li></ul><h4>Improvements</h4><p>After applying configuration to 300+ modules, we noticed 3 fields in Gradle configuration are the same for each app: projectId, apiToken and languages. To encapsulate them, we used the <a href="https://docs.gradle.org/current/samples/sample_convention_plugins.html">Gradle conventional plugin</a>.</p><p>Inside a new plugin, we created a simple Enum class with all our projects:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc808acfa63a8df89e07fabdec2c43e5/href">https://medium.com/media/bc808acfa63a8df89e07fabdec2c43e5/href</a></iframe><p>Instead of writing 3 boilerplate fields, the developer has to specify only <strong>projectName</strong>. The rest would be applied inside the conventional plugin. This is how final configuration looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d5a648429231028bb989eee7b9bbbf5/href">https://medium.com/media/9d5a648429231028bb989eee7b9bbbf5/href</a></iframe><p>Code from Conventional plugin:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb675741d4d081eacfc2514bf6b63763/href">https://medium.com/media/eb675741d4d081eacfc2514bf6b63763/href</a></iframe><h4>Other problems we solved</h4><p><strong>Duplicated files</strong></p><p>We couldn’t have the same strings files in different modules because of transitive R classes, which couldn’t contain duplicates. To fix it, we enabled <a href="https://developer.android.com/studio/build/optimize-your-build#use-non-transitive-r-classes">non-transitive R classes</a>. Now we have to specify the full path to the R in code (e.g. <em>com.revolut.feature.payments.R.string.my_title</em>), but we can make the same file be added to multiple modules.</p><p><strong>Merge conflicts</strong></p><p>Strings files can change quite often if multiple people work on the same feature. In such cases, we might encounter numerous merge conflicts and even risk breaking the main branch.</p><p>For instance, if one person merges a new string “A” and its corresponding code, and later another person merges a file without the string “A,” it can lead to complications and errors.</p><p>We fixed this issue with 2 simple rules:</p><ol><li>No one can merge strings xml files manually. We have a <a href="https://github.com/danger/kotlin">Danger</a> rule to block such Pull requests</li><li>Automated script on CI merges strings to always the same branch (to not have conflicts). Strings are merged to the <em>release</em> branch and automatically back merged to the main <em>development</em> branch. Script is automatically triggered every day or can be triggered by the engineer</li></ol><p><strong>Changed or deleted strings used by older app versions</strong></p><p>Currently, we have at least 3 app versions in the release cycle. For instance:</p><p>- version 1 is available on Google Play</p><p>- version 2 is accessible in the Beta channel</p><p>- version 3 is the one we are currently working on and releasing internally</p><p>We came across a problem: if a decision is made to remove a string that’s no longer needed in version 3, it could potentially break the release of versions 1 and 2, as they’re still utilising that string.</p><p>To prevent such issues, we have another set of rules:</p><ul><li>Don’t remove strings immediately. Move them to the separate file called <em>strings_unused.xml</em> and remove them only after some time, when we’re completely sure it won’t break anything (usually after 6 months)</li><li>If we intend to modify the number of placeholders in the string, it is essential to create a new string. We need it as an incorrect number of arguments, whether shown or not, can lead to unexpected UI and UX bugs</li><li>If an engineer wants to change any text — they’re welcome to do it</li></ul><h4>Conclusion</h4><p>Over the past 7 years, we’ve explored various solutions for translation management. While the task may not appear complicated at first glance, as you can see, there are many pitfalls.</p><p>Even though our current solution isn’t a silver bullet, it’s flexible enough to be improved upon as soon as we face a new challenge.</p><p>If you have a single app with a few modules, it probably doesn’t make sense to invest time into creating your own library; instead, you can use what’s already available or do everything manually.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f97b5969bfb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/revolut/evolution-of-translations-management-for-android-at-revolut-2f97b5969bfb">Evolution of translations management for Android at Revolut</a> was originally published in <a href="https://medium.com/revolut">Revolut Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit tests with mocks in 5 minutes]]></title>
            <link>https://tyschenko.medium.com/unit-tests-with-mocks-in-5-minutes-c6caa11768d0?source=rss-ac32252881d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6caa11768d0</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[mock]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Yaroslav T]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 07:01:49 GMT</pubDate>
            <atom:updated>2023-07-25T07:01:49.766Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unit tests with mocks in 6 minutes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0B0o2mdUgn4-t5Ws1E2glA.jpeg" /></figure><p>When conducting live coding interviews, I see many people who struggle with using Mocks in unit tests. Mocking is a process of simulating code behaviour without actually implementing it (under the hood it is done via <a href="https://www.oracle.com/technical-resources/articles/java/javareflection.html">Java Reflection</a>). If your class depends on other classes, you don’t have to implement them for tests; instead, you can simulate their behavior. This way, you can test each code layer independently.</p><p>In this short article, I am going to cover 6 operators and keywords you need to write unit tests in modern Android projects. While I won’t be discussing <a href="https://martinfowler.com/articles/mocksArentStubs.html">stubs</a> here, as they deserve a separate article, I will instead focus on the topic of mocking.</p><h4>Quick setup</h4><p>Simply add a dependency to <strong>Mockito-kotlin</strong>. You can find an instruction in their <a href="https://github.com/mockito/mockito-kotlin">repo</a>.</p><p>In your Android project, you usually have something like this: a Repository which handles data logic, a Retrofit service which loads values from the backend, and some Cache to call the backend less often. In our example Repository, we have a method to get a nickname, which returns either the cached value or, if it’s not present, the value from the server:</p><pre>interface Service {<br>    @GET(&quot;/user/current/nickname&quot;)<br>    suspend fun getNicknameFromServer(): String<br>}<br><br>interface Storage {<br>    fun putNicknameToCache(nickname: String)<br>    fun getNicknameFromCache(): String?<br>}<br><br>class Repository(<br>    private val service: Service,<br>    private val storage: Storage,<br>) {<br><br>    suspend fun getNickname(): String {<br>        val nicknameFromCache = storage.getNicknameFromCache()<br>        return if (nicknameFromCache == null) {<br>            val nicknameFromBackend = service.getNicknameFromServer()<br>            storage.putNicknameToCache(nicknameFromBackend)<br>            nicknameFromBackend<br>        } else {<br>            nicknameFromCache<br>        }<br>    }<br>}</pre><p>It is time-consuming to unit test this repository if you have to create special instances for all dependencies (imagine you have not only 2 dependencies but 10). Mocks can simplify it significantly. Let’s cover it with unit tests using mocks.</p><h4>Whenever and Verify</h4><p>These 2 operators are enough to write 99% of unit tests. For me, they are like Bonnie and Clyde — they always come together.</p><p>First, let’s define a test structure and initialise each dependency (you don’t have to create an instance of the class, <strong>mock()</strong> does it for you):</p><pre>class RepositoryTest {<br><br>    private val service: Service = mock()<br>    private val storage: Storage = mock()<br>    private val repository = Repository(<br>        service = service,<br>        storage = storage,<br>    )<br>}</pre><p>Let’s cover a scenario where the value is present in the cache. In this case, we need to return it and ensure we haven’t called the backend:</p><pre>@Test<br>fun `GIVEN nickname present in storage WHEN getNickname THEN return value from storage AND don&#39;t call backend`() = runTest {<br>    val expectedNickname = &quot;JohnDoe&quot;<br>    whenever(storage.getNicknameFromCache()).thenReturn(expectedNickname)<br>    <br>    val nickname = repository.getNickname()<br>    <br>    Assert.assertEquals(expectedNickname, nickname)<br>    verify(service, never()).getNicknameFromServer()<br>}</pre><blockquote>whenever(storage.getNicknameFromCache()).thenReturn(expectedNickname)</blockquote><p>This is our first interaction with a mock. We define a rule, what class <strong>storage </strong>should do when <strong>getNicknameFromCache</strong> is called. <strong>thenReturn </strong>specifies the value that will be returned, in our case it is <strong>expectedNickname</strong>.<br>On every call of <strong>getNicknameFromCache </strong>you will receive <strong>expectedNickname </strong>— clear and simple.</p><p>After we mocked return value, now we should interact with the mocked object and validate that everything works correctly.</p><blockquote>Assert.assertEquals(expectedNickname, nickname)</blockquote><p>Common unit tests assertion, checks that 2 values are equal. In our case a value we mocked in <strong>Storage</strong> and a value we received from <strong>Repository</strong>.</p><blockquote>verify(service, never()).getNicknameFromServer()</blockquote><p>Mockito operator <strong>verify </strong>allows us to check how many times and with what arguments methods have been invoked. You have to pass your mocked class (<strong>service</strong> in our case), how many times it is supposed to be invoked (in our case <strong>never()</strong>) and which method was or wasn’t invoked — <strong>getNicknameFromServer</strong>.</p><p>Let me give you an example of the test when the value wasn’t present in the cache, so we had to load the nickname from the backend and put it into the cache:</p><pre>@Test<br>fun `GIVEN nickname not present in storage WHEN getNickname THEN return value from backend AND put to storage`() = runTest {<br>    val expectedNickname = &quot;JohnDoe&quot;<br>    whenever(service.getNicknameFromServer()).thenReturn(expectedNickname)<br>    whenever(storage.getNicknameFromCache()).thenReturn(null)<br>    <br>    val nickname = repository.getNickname()<br>    <br>    Assert.assertEquals(expectedNickname, nickname)<br>    verify(service, times(1)).getNicknameFromServer()<br>    verify(storage, times(1)).putNicknameToCache(expectedNickname)<br>}</pre><p>Try to understand for yourself what each line does in this test.</p><p>From my experience, these 2 operators are enough to write 99% of unit tests. There are very rare scenarios in which you need something additional, such as:</p><h4>ArgumentCaptor, Any and Eq</h4><p><strong>ArgumentCaptor</strong> gives you an exact argument that was used during interaction with the mocked class. You can use <strong>Any</strong> (or its friend <strong>AnyOrNull</strong>) as a placeholder for an argument when you don’t care about its specific value. Within a single interaction, if you used <strong>ArgumentCaptor</strong> or <strong>Any</strong>, exact arguments must be wrapped into <strong>eq(value)</strong>, like <strong>eq(“JohnDoe”)</strong>.</p><p>For example, we are uploading a new avatar, username, and the current timestamp to the backend:</p><pre>interface Service {<br>    @POST(&quot;/user/current/avatar&quot;)<br>    suspend fun uploadAvatarToServer(<br>        @Part file: MultipartBody.Part,<br>        @Part username: String,<br>        @Part timestamp: Long,<br>    )<br>}<br><br>class Repository(<br>    private val service: Service,<br>) {<br><br>    suspend fun uploadAvatar(file: File) {<br>        service.uploadAvatarToServer(<br>            file = MultipartBody.Part.createFormData(<br>                name = &quot;avatar&quot;,<br>                filename = file.name,<br>                body = file.asRequestBody(&quot;image/jpeg&quot;.toMediaType()),<br>            ),<br>            username = &quot;JohnDoe&quot;,<br>            timestamp = System.currentTimeMillis(),<br>        )<br>    }<br>}</pre><p>MultipartBody.Part is a Java class which doesn’t implement <em>equals</em> and <em>hashcode</em>. If you try to manually compare them, you will always get <em>false. </em>In this case we have to use <strong>ArgumentCaptor</strong> to assert values inside MultipartBody.Part:</p><pre>@Test<br>fun `WHEN uploadAvatar THEN request body with file is configured correctly`() = runTest {<br>    val fileName = &quot;myselfie.jpeg&quot;<br>    val expectedHeader = &quot;form-data; name=\&quot;avatar\&quot;; filename=\&quot;$fileName\&quot;&quot;<br>    val expectedMediaType = &quot;image/jpeg&quot;.toMediaType()<br><br>    repository.uploadAvatar(File(fileName))<br><br>    val argumentCaptor = argumentCaptor&lt;MultipartBody.Part&gt;()<br>    verify(service).uploadAvatarToServer(<br>        file = argumentCaptor.capture(),<br>        user = eq(&quot;JohnDoe&quot;), // Validate correct argument using eq<br>        timestamp = any(), // In this test we don&#39;t care about the timestamp<br>    )<br><br>    val partFromRequest: MultipartBody.Part = argumentCaptor.firstValue<br>    val headerFromRequest = partFromRequest.headers!![&quot;Content-Disposition&quot;]<br>    Assert.assertEquals(expectedHeader, headerFromRequest)<br>    Assert.assertEquals(expectedMediaType, partFromRequest.body.contentType())<br>}</pre><blockquote>val argumentCaptor = argumentCaptor&lt;MultipartBody.Part&gt;()</blockquote><p>You have to specify the type for the <strong>argumentCaptor</strong>.</p><blockquote>file = argumentCaptor.capture(),</blockquote><p>Call <strong>capture() </strong>within a mock where you need to assert a value.</p><blockquote>val partFromRequest: MultipartBody.Part = argumentCaptor.firstValue Assert.assertEquals(expectedMediaType, partFromRequest.body.contentType())</blockquote><p>Write common assertions to make sure your code is correct.</p><h4>Spy</h4><p><strong>Spy</strong> creates a copy of your instance and adds the possibility to use <strong>whenever</strong> and <strong>verify</strong>. You can use Spy on any dependency you’re going to provide as a real implementation (although I don’t recommend it) or on your testable object itself:</p><pre>internal class RepositoryTest {<br><br>    private val service: Service = mock()<br>    private val storage: Storage = spy(StorageImpl())<br>    private val repository = spy(<br>        Repository(<br>            service = service,<br>            storage = storage,<br>        )<br>    )<br>}</pre><p>I personally use <strong>spy </strong>only for testing high-level logic. Imagine you have a method which calls other methods at the same class:</p><pre>fun changeNickname(nickname: String) {<br>    changeNicknameOnBackend(nickname)<br>    updateNicknameInCache(nickname)<br>    trackNicknameChanged()<br>}<br><br>fun changeNicknameOnBackend(nickname: String) { ... }<br>fun updateNicknameInCache(nickname: String) { ... }<br>fun trackNicknameChanged() { ... }</pre><p>You can test every method independently and for <em>changeNickname </em>use spy:</p><pre>private val repository = spy(Repository())<br><br>@Test<br>fun `WHEN changeNickname THEN call correct methods`() {<br>    val expectedNickname = &quot;JohnDoe&quot;<br>    repository.changeNickname(expectedNickname)<br><br>    verify(repository).changeNicknameOnBackend(expectedNickname)<br>    verify(repository).updateNicknameInCache(expectedNickname)<br>    verify(repository).trackNicknameChanged()<br>}</pre><h4>Mocking of Static code</h4><p>If you use static invocations (from my experience most common are <em>UUID</em> and <em>Intent.fromChooser</em>), you can test it using <strong>Mockito.mockStatic()</strong>. Let’s take a look at this code:</p><pre>suspend fun changeNickname(newNickname: String) {<br>    service.changeNickname(<br>        nickname = newNickname,<br>        uuid = UUID.randomUUID().toString(),<br>    )<br>}</pre><p>Test for this method looks like this:</p><pre>@Test<br>fun `WHEN changeNickname THEN send correct params to backend`() = runTest {<br>    Mockito.mockStatic(UUID::class.java).use { mockedUUID -&gt;<br>        val expectedNickname = &quot;JohnDoe&quot;<br>        val uuid = mock&lt;UUID&gt;()<br>        whenever(uuid.toString()).thenReturn(&quot;uuid&quot;)<br>        mockedUUID.`when`&lt;Any&gt; { UUID.randomUUID() }.thenReturn(uuid)<br><br>        repository.changeNickname(expectedNickname)<br><br>        verify(service).changeNickname(<br>            nickname = expectedNickname,<br>            uuid = &quot;uuid&quot;,<br>        )<br>    }<br>}</pre><blockquote>mockedUUID.`when`&lt;Any&gt; { UUID.randomUUID() }.thenReturn(uuid)</blockquote><p>You mock static methods of class <strong>UUID::class.java </strong>and specify what to return on the invocation of <strong>randomUUID</strong></p><h4>Conclusion</h4><p>If you don’t write unit tests, develop a good habit of spending 30 minutes after implementation to cover code with tests. No matter which framework you use (<a href="https://github.com/mockito/mockito-kotlin">Mockito</a>, <a href="https://mockk.io/">MockK</a>, or <a href="https://github.com/powermock/powermock">PowerMock</a>) — it is an extra layer of security that ensures you haven’t missed anything or made a mistake. Tests also help you with refactoring the code (tests should remain green after refactoring), and specifically, mocks help us test every layer independently.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6caa11768d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How and when to use Sealed classes in Kotlin and Android]]></title>
            <link>https://tyschenko.medium.com/how-and-when-to-use-sealed-classes-in-kotlin-and-android-4fde2655cdfc?source=rss-ac32252881d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fde2655cdfc</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Yaroslav T]]></dc:creator>
            <pubDate>Sun, 16 Jul 2023 18:32:12 GMT</pubDate>
            <atom:updated>2023-07-16T18:32:12.759Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fZwDUccjU9CAmQIcZDg2hA.png" /></figure><p>In this short article, I would like to briefly explain what sealed classes are in Kotlin, when and how to use them. You can use this article as a cheat sheet for a person who has just started their journey in Kotlin and isn’t familiar with sealed classes.</p><h4><strong>Definition</strong></h4><p>Sealed classes/sealed interfaces represent a type that is limited to specific values and only those values. Inheritors of the sealed class might have different params but still belong to the same type.</p><p>You can find a comprehensive and detailed definition in the <a href="https://kotlinlang.org/docs/sealed-classes.html">official</a> doc, but let me show you a quick example instead:</p><pre>sealed class Time {<br>    object Day : Time()<br>    object Night : Time()<br>}</pre><p>There are no other possible values for time, it can only be either Day or Night.</p><p>For simplicity, I will refer to sealed classes in this article, but the same logic applies to sealed interfaces as well.</p><h4>When to use</h4><p>Use Sealed classes when you know all the possible outputs.</p><pre>fun loadNicknameFromServer(): Flow&lt;Result&gt;<br><br>sealed class Result {<br>    object Loading : Result()<br>    data class Error(val t: Throwable) : Result()<br>    data class Success(val nickname: String) : Result()<br>}</pre><p>When you’re loading a value from the internet, the potential outputs are already known:</p><ol><li>When you start a request, the output is <strong>Loading</strong> (you can represent it on the UI with a progress bar)</li><li>If the request fails, your output is <strong>Error</strong>, so you can show a Toast with an error message and a button “Try again”.</li><li>When the request is successful and the data is loaded, your output is <strong>Success</strong> and you can display the value on the UI</li></ol><h4>How to use</h4><p>To define a sealed class or sealed interface with all possible inheritors, the syntax for both is quite similar:</p><pre>sealed class EventSource {<br>    object Push : EventSource()<br>    object Email : EventSource()<br>}<br><br>sealed interface EventSource {<br>    object Push : EventSource<br>    object Email : EventSource<br>}</pre><p>The main advantage of sealed classes/interfaces is the ability to use an exhaustive when expression to have compile-time checks that you have handled every possible outcome. Additionally, in each when branch, you don&#39;t need to cast the value as it is done automatically:</p><pre>sealed class EventSource {<br>    data class Push(val message: String) : EventSource()<br>    data class Email(val sender: String) : EventSource()<br>}<br><br>fun getEventSource(): EventSource<br><br>val eventSource = getEventSource()<br>when (eventSource) {<br>    is EventSource.Push -&gt; println(&quot;Push has message = ${eventSource.message}&quot;)<br>    is EventSource.Email -&gt; println(&quot;Email is from = ${eventSource.sender}&quot;)<br>}</pre><p>If you don’t need to handle some of the sealed class inheritors, you can use else in the when expression, but I strongly recommend against doing that. By doing so, you might miss handling new variants of your sealed class in the future. Instead, use else with a comma and an empty code block to explicitly state that you have considered all possible cases:</p><pre>sealed class EventSource {<br>    object Push : EventSource()<br>    object Email : EventSource()<br>    object PhoneCall : EventSource()<br>}<br><br>when (eventSource) {<br>    EventSource.Push -&gt; println(&quot;Event is from Push&quot;)<br>    EventSource.Email,<br>    EventSource.PhoneCall -&gt; Unit // Don&#39;t handle other sources except Push<br>}</pre><h4>Difference between Sealed class and Enum class</h4><p>All <strong>enum</strong> constants must override the same arguments, so if you want to different values, you have to write ugly boilerplate code. Look at the example with Push and Email event sources, sealed class looks much cleaner:</p><pre>sealed class EventSource {<br>    data class Push(val message: String) : EventSource()<br>    data class Email(val sender: String) : EventSource()<br>}<br><br>enum class EventSource(val message: String?, val sender: String?) {<br>    Push(message = &quot;text&quot;, sender = null), <br>    Email(message = null, sender = &quot;John&quot;)<br>}</pre><h4>Differences between Sealed class and Sealed interface</h4><p>In my opinion, the only useful difference are private variables in Sealed classes. Imagine you want to categorize the EventSource based on priority, you can define it like this</p><pre>sealed class EventSource(private val priority: Int) {<br>    object Push : EventSource(priority = 1)<br>    object Email : EventSource(priority = 2)<br>}<br><br>sealed interface EventSource {<br>    val priority: Int<br>    object Push : EventSource {<br>        override val priority: Int = 1<br>    }<br>    object Email : EventSource{<br>        override val priority: Int = 2<br>    }<br>}</pre><p>In a sealed interface, you cannot make the priority field private, so other people can access it. But sealed classes allow you to encapsulate any field you want.</p><h4>Usage with Generics</h4><p>Let’s revisit our example with the Result sealed class. It wasn’t flexible because its inheritor was limited to the exact type String:</p><pre>data class Success(val nickname: String) : Result()</pre><p>To make it flexible we can use Kotlin <a href="https://kotlinlang.org/docs/generics.html">Generics</a>:</p><pre>fun loadNicknameFromServer(): Flow&lt;Result&lt;Nickname&gt;&gt;<br><br>data class Nickname(val nickname: String, val dateOfAssign: Long)<br><br>sealed interface Result&lt;out T&gt; {<br>    object Loading : Result&lt;Nothing&gt;<br>    data class Error(val t: Throwable) : Result&lt;Nothing&gt;<br>    data class Success&lt;T&gt;(val content: T) : Result&lt;T&gt;<br>}</pre><h4>Conclusion</h4><p>Sealed classes is not a silver bullet. If you have to handle every possible outcome and would like this code to be clean and easy to maintain, use Sealed classes. Otherwise, a data class with many fields or a regular interface with inheritors could be enough.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fde2655cdfc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>