<?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 Guy Lis on Medium]]></title>
        <description><![CDATA[Stories by Guy Lis on Medium]]></description>
        <link>https://medium.com/@guylis?source=rss-290527b69969------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9WRjixpUF9ONan_Sq_6w0Q.jpeg</url>
            <title>Stories by Guy Lis on Medium</title>
            <link>https://medium.com/@guylis?source=rss-290527b69969------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:57:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@guylis/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[Jenkins vs GitHub Actions]]></title>
            <link>https://medium.com/@guylis/jenkins-vs-github-actions-eec8ffcd4b07?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/eec8ffcd4b07</guid>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Sun, 06 Apr 2025 06:09:34 GMT</pubDate>
            <atom:updated>2025-04-06T06:09:34.949Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*tKTYW3PSBM2MdWp71e7zGg.png" /></figure><h3>Background</h3><p>In a world where we develop for mobile apps, mobile sdks, servers or any other types of software components, coding is not enough. Our code needs to be verified, built, and deployed in a scalable manner. For this, there are Continuous integration/Continuous deployment automation servers dedicated for this purpose that most companies use. In the past, dedicated teams handled this aspect of development. Today, more and more of this responsibility falls under the developers working on the code.</p><h3>Motivation</h3><p>In order to give some examples of what these CI/CD servers can perform, I’ll share from my experience working on an SDK for mobile apps:</p><ul><li>Build the SDK using a repository that contains its code and an application running it, either from a user prompt, in a scheduled mechanism or from various triggers like a pull requests.</li><li>Run various verifications such as unit tests, integration tests and automation tests on the code prior to updating it in the remote repository/when opening a pull request.</li><li>Format/Validate the code using some sort of code formatter to align it between all the developers.</li><li>Prepare a release candidate for the sdk based on a branch in the repository holding the relevant code along with an incremented version.</li><li>Publish the release candidate via maven central for android, ios for cocoa pods, swift package manager.</li></ul><h3>Different CI/CD server implementations</h3><p>I have worked on several CI/CD servers including Jenkins, GitHub Actions and Yamato. There are also many others such as circleCI, Bitrise, Azure devops, Gitlab and more. In most cases where you work in a company, you don’t get to choose the server. In others, the decisions leading from one to another can change over time. The decision can be affected by questions such as :</p><ul><li>Whether the server is self managed or self hosted.</li><li>How many people are going to use this server.</li><li>Special requirements from this server operating systems like a Mac, Unity.</li><li>Which other platforms is the team working with that will work in collaboration, for example what is used for code reviews or for storing the code base.</li></ul><h3>Jenkins Pros/Cons</h3><h4><strong>Pros</strong></h4><ul><li><strong>Open-Source</strong> — flexibility to have something matching your needs</li><li><strong>Stability in relation to downtime</strong> — The server is self managed so if there is any downtime or issue, you have more flexibility on handling it.</li><li><strong>UI Flexibility</strong> — Jenkins provides more flexibility in UI customization for workflows compared to GitHub Actions.</li><li><strong>Scalability</strong> — enabling distributed builds across multiple machines for improved speed and can also use cloud environments such as AWS.</li></ul><h4><strong>Cons</strong></h4><ul><li><strong>Maintenance</strong> — since the server is self managed, you are responsible for upgrading the machines the server is installed on and the server version itself meaning additional cost.</li><li><strong>Complex setup</strong> — a lot of manual installation and configuration is needed.</li><li><strong>Outdated UI/UX</strong> — compared to modern CI/CD tools</li><li><strong>Troubleshooting </strong>self-hosted runners is challenging, and diagnosing infrastructure failures, such as plugin issues, can be time-consuming.</li><li><strong>No native integration with supporting systems</strong> — unlike github actions, there’s no built in integration for a system needed for code storage or code reviews.</li><li><strong>Security management</strong> — since Jenkins is self-hosted, you are responsible for securing it.</li></ul><h3>GitHub Actions Pros/Cons</h3><h4><strong>Pros</strong></h4><ul><li><strong>Github integration</strong> — When working with git as your code repository as well as for code reviews, GitHub Actions integrates well for both. No need for additional external integrations.</li><li><strong>Maintenance</strong> — Since GitHub Actions is a cloud-based solution, you do not need to manage server infrastructure</li><li><strong>Pre-build actions</strong> — ability to automate common tasks instead of writing your own.</li><li><strong>Flexibility in defining workflows</strong> — using YAML files allowing modular design and reusable actions.</li><li><strong>Monitoring</strong> — have detailed logs for troubleshooting and the UI show the workflow progress, making it easy to track build failures.</li><li><strong>Workflow optimization</strong> — support both parallel runs, scheduled runs and dependencies between workflows.</li></ul><h4><strong>Cons</strong></h4><ul><li><strong>Handling downtime</strong> — there is little you can do when issues arise.</li><li><strong>The UI is limited —</strong> GitHub Actions does not have too much Options UI related, e.g. you cannot create a workflow with more than 10 input fields.</li><li><strong>Limitation for debugging</strong> — Debugging workflows is limited since testing must be done remotely rather than locally.</li><li><strong>Workflow management</strong> — the yml syntax used for the workflows is limited compared to programming languages and be hard to maintain for large projects.</li><li><strong>Performance</strong> — GitHub-hosted runners have performance limitations compared to self-hosted runners.</li></ul><h3>Migrating from one to another</h3><p>I was part of migrating from Jenkins to GitHub Actions. Some tips I can share on this:</p><ul><li>Break the migration into smaller steps, considering platforms and CI processes separately.</li><li>For multiple platforms, maintain a consistent CI/CD implementation across them, except where platform-specific adjustments are necessary.</li><li>This type of migration is hard to validate, so make sure to have a backup of all migrated processes in the old infra available as well as an easy way to revert a change if needed.</li></ul><h3>Conclusion</h3><p>While working with a CI/CD server may not be as exciting as coding and leans more toward DevOps than traditional software engineering, it is an increasingly valuable skill for developers. Just as programming languages evolve — such as the shift from Java to Kotlin in Android or Objective-C to Swift in iOS — CI/CD tools also change over time. Being adaptable and ready to transition between different CI/CD solutions is essential in a fast-moving development environment</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eec8ffcd4b07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Release process — why do we run from it?]]></title>
            <link>https://medium.com/@guylis/release-process-why-do-we-run-from-it-fef32bbd28be?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/fef32bbd28be</guid>
            <category><![CDATA[release-management]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 06:41:49 GMT</pubDate>
            <atom:updated>2024-12-02T06:41:49.012Z</atom:updated>
            <content:encoded><![CDATA[<h3>Release process — why do we run from it?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VsFYiFURI0EdzejiXAm_Ag.jpeg" /></figure><h3>Background</h3><p>As a software developer, I can confidently say there are certain tasks that some of us loathe.</p><p>Some developers dread code reviews. It forces them out of the comfort zone of their own work into unfamiliar codebases. They need to understand and critique someone else’s logic, suggest refactors, or propose architectural changes — sometimes inviting pushback or even frustration from their peers. Worse yet, they might uncover bugs they now have to deal with.</p><p>Others find themselves avoiding testing their code. Manual testing can be tedious and time-consuming, while writing unit or integration tests may expose just how poorly designed the code is for testability.</p><p>Today, I want to focus on another dreaded responsibility: <strong>being the one in charge of a release</strong> — whether it’s for an SDK, an app, or a server deployment.</p><h3>The process</h3><p>Management typically pushes for frequent releases, aiming to deploy features as soon as they’re ready while keeping the process as fast and efficient as possible.</p><p>However, when dealing with client-side releases, the stakes are much higher. Even small issues can lead to significant consequences, making the release process both complex and time-consuming.</p><p>To handle this, development teams often assign a release owner — usually the team lead or a designated developer. This role involves more management and operational responsibilities than coding, which is why many developers shy away from it. It requires careful planning, coordination, and execution, skills that aren’t always part of a developer’s typical toolkit.</p><p>In the sections that follow, I’ll break down the potential requirements of a release process and offer recommendations on how to tackle each challenge effectively.</p><h3>Breakdown</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9CTsHYPaMOrz5-uSVWrMRA.png" /></figure><h4><strong>Ticket Validation</strong></h4><p>Regardless of using Jira, Monday, Trello or Google Sheets to understand the tickets relevant for the release, In some flows, the release owner is expected to have a basic knowledge of each item, follow up on their readiness, make sure they are validated as part of the release and mention them in the publication process. Having tickets spread across different tools or formats can lead to confusion and inefficiencies in management.</p><h4><strong>Dependency Management</strong></h4><p>When there are multiple products released within the company and there are dependencies between them, during the release of one, either the others are in freeze, or the dependencies needs to be handled when they are released in parallel.</p><h4><strong>Manual Testing &amp; Regression</strong></h4><p>Despite using unit tests, integration tests, end to end tests and other validations, some edge cases, UI changes, or external integrations might not be fully covered by the mentioned tests and require manual testing. This is usually a tedious process that takes time.</p><h4><strong>Issue Management During Release</strong></h4><p>Throughout the release process, problems can and will occur and even when the release owner isn’t expected to handle all of them, he is expected to assess and prioritize issues while communicating effectively with stakeholders.</p><h4><strong>Distributed Teams &amp; Coordination</strong></h4><p>In some cases, the release is split into several teams that can be in different time zones. This slows down the release creating dependencies between the teams.</p><h4><strong>Automation</strong></h4><p>While automation offers significant speed advantages over manual checks, it is not without challenges. Test instability can lead to noisy results and false negatives, which complicate release decisions. Additionally, some tests may become outdated or irrelevant, warranting conversion into faster integration tests or outright removal. Maintaining the automation infrastructure can also become burdensome, creating a scenario where teams end up “working for the automation” rather than having it work for them.</p><h4><strong>Publishing</strong></h4><p>The publishing process itself, when having manual parts like uploading an app to the store/sdk to the server, merging code in the repository and even writing the publication mail, can be long.</p><h3>Suggestions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Sf1pcRNqPydNIWEsB_Kow.png" /></figure><h4><strong>Ticket Validation</strong></h4><ul><li>Establishing a <strong>single source of truth</strong> for tickets reduces maintenance overhead and confusion.</li><li>Use <strong>automation tools or scripts</strong> to handle ticket-related tasks, such as updating statuses, tracking time, or validating requirements (e.g., leveraging Jira automation for ticket workflows).</li></ul><h4><strong>Dependency Management</strong></h4><ul><li>Aim to <strong>reduce the release time</strong> to no more than a day to limit disruptions caused by dependencies.</li><li>Work towards <strong>decoupling dependencies</strong> between products, enabling each to be released independently.</li></ul><h4>Manual Testing &amp; Regression</h4><ul><li>Transition as many manual checks as possible to <strong>automated tests</strong>, including unit, integration, and end-to-end tests.</li><li>For remaining manual tests<br>- Ensure they are <strong>clearly defined</strong> so that any team member can execute them<br>- Regularly assess their necessity and eliminate redundant ones.</li></ul><h4><strong>Issue Management During Release</strong></h4><ul><li>Assign an <strong>on-call team member</strong> to handle release-related issues or ensure the <strong>entire team’s availability</strong> during critical phases.</li><li>Conduct a <strong>retrospective after each release</strong> to analyze recurring issues and implement preventative measures.</li></ul><h4><strong>Distributed Teams &amp; Coordination</strong></h4><ul><li>Invest in infrastructure changes to <strong>centralize knowledge</strong> and ensure all relevant teams/developers can handle releases independently.</li><li>Until full decentralization is feasible:<br>- Foster strong <strong>communication practices</strong> between teams through periodic meetings.<br>- Create a <strong>shared online space</strong> to log and prioritize release-related issues, emphasizing high-priority tasks.</li></ul><h4><strong>Automation</strong></h4><ul><li>Focus on making the automation suite as <strong>stable</strong> as possible to reduce false negatives and noise.</li><li>Ensure the infrastructure supports:<br>- <strong>Ease of adding tests</strong> with minimal refactoring.<br>- <strong>Efficient debugging tools</strong> to quickly identify and resolve issues in automated workflows.</li><li>Periodically check the existing tests to make sure they are still relevant.</li></ul><h4><strong>Publishing</strong></h4><ul><li>Strive for full <strong>automation of publishing tasks</strong>, such as:<br>- Sending notification emails.<br>- Merging code.<br>- Updating the knowledge center or documentation.</li></ul><h3>Summary</h3><p>The release process can often feel long, error-prone, and frustrating. However, with the right strategies and improvements, it’s possible to make it shorter, more reliable, and far less stressful.</p><h3><strong>What about your release process?</strong></h3><p>Releases can be stressful, but they’re also a chance to improve workflows and foster teamwork. I’d love to hear about your experiences:</p><ul><li>What challenges have you faced during releases?</li><li>Do you have tips or strategies that worked for your team?<br>Share your thoughts or stories in the comments — let’s learn from each other!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fef32bbd28be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automatic update for new Xcode version]]></title>
            <link>https://medium.com/@guylis/automatic-update-for-new-xcode-version-796e716e25bb?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/796e716e25bb</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Sun, 03 Nov 2024 15:02:14 GMT</pubDate>
            <atom:updated>2024-11-03T15:02:14.854Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tEsF-mWj-7pVg8iLOjcAA.png" /></figure><h3>Motivation</h3><p>Apple requires app developers to use the latest version of Xcode to upload their apps to the store. Starting April 24th, 2024, apps must be built with Xcode 15.</p><h3>Available Methods</h3><p>In order to be notified when the latest Xcode is released, there are several options:</p><ol><li>Periodically check the app store <a href="https://apps.apple.com/il/app/xcode/id497799835?mt=12">here</a></li><li>Periodically check the Apple developer site <a href="https://developer.apple.com/download/applications/">here</a></li><li>Register for mailing lists from Apple <a href="https://developer.apple.com/account#EmailsCard">here</a> from your developer account</li></ol><p>All these options require manual intervention, which is a push-based approach, where you actively seek the updates. Wouldn’t it be nice if you can get notified of this? Here’s how:</p><h3>Automated Version Checking</h3><p>Unfortunately, Apple doesn’t give API to receive this information, but they have it in an html site, so the process is as follows:</p><ol><li>Write a script that parses this site, and retrieves the latest Xcode version.</li><li>Use git actions to create a scheduled job running on an Xcode machine and installs the Xcode you’re building your apps on.</li><li>Run the script above daily using git actions, comparing the version in the Apple site and the one in the machine.</li><li>When the versions differ, GitHub Actions can send you an email notification about the new version</li></ol><h3>Examples</h3><p>Example for script parsing the site, retrieving the local Xcode version and comparing them</p><pre>import urllib.request<br>import subprocess<br><br>from html.parser import HTMLParser<br><br><br># Step 1: Fetch the Web Page<br>def fetch_releases_page():<br>    url = &quot;https://developer.apple.com/news/releases/&quot;<br>    try:<br>        with urllib.request.urlopen(url) as response:<br>            return response.read().decode(&#39;utf-8&#39;)<br>    except Exception as e:<br>        print(f&quot;Failed to fetch the page. Error: {e}&quot;)<br>        return None<br><br><br># Step 2: Parse the HTML Content<br>class XcodeVersionParser(HTMLParser):<br>    def __init__(self):<br>        super().__init__()<br>        self.latest_version = 0<br>        self.in_article = False<br>        self.in_title = False<br><br>    def handle_starttag(self, tag, attrs):<br>        if tag == &#39;article&#39;:<br>            self.in_article = True<br>        if self.in_article and tag == &#39;h2&#39;:<br>            self.in_title = True<br><br>    def handle_endtag(self, tag):<br>        if tag == &#39;article&#39;:<br>            self.in_article = False<br>        if tag == &#39;h2&#39;:<br>            self.in_title = False<br><br>    def handle_data(self, data):<br>        if self.in_title and &#39;Xcode&#39; in data:<br>            # check if version includes beta or RC<br>            if (&#39;beta&#39; in data) or (&#39;RC&#39; in data):<br>                return<br>            # Extract version in the form of 15.4 from 15F31d<br>            version_parts = data.split(&#39; &#39;)<br>            if len(version_parts) &gt; 1:<br>                version_str = version_parts[1]<br><br>                # Parse version to a float for comparison<br>                try:<br>                    current_version = float(version_str)<br><br>                    # If self.latest_version is not set or current version is higher, update latest_version<br>                    if (not hasattr(self, &#39;latest_version&#39;)) or current_version &gt; self.latest_version:<br>                        self.latest_version = current_version<br>                except ValueError:<br>                    return<br><br><br>def parse_xcode_version(html_content):<br>    parser = XcodeVersionParser()<br>    parser.feed(html_content)<br>    return parser.latest_version<br><br><br>def get_xcode_version():<br>    try:<br>        # Run the xcodebuild command and capture its output<br>        result = subprocess.run([&#39;xcodebuild&#39;, &#39;-version&#39;], capture_output=True, text=True, check=True)<br><br>        # Extract the version line from the output<br>        output = result.stdout<br>        lines = output.splitlines()<br>        for line in lines:<br>            if line.startswith(&#39;Xcode&#39;):<br>                # Extract the version number after &#39;Xcode &#39;<br>                version = line.split(&#39; &#39;)[1]<br>                return version<br><br>        raise ValueError(&quot;Xcode version not found in the output.&quot;)<br><br>    except subprocess.CalledProcessError as e:<br>        print(f&quot;Error executing xcodebuild: {e}&quot;)<br>    except Exception as e:<br>        print(f&quot;An error occurred: {e}&quot;)<br><br><br># Step 4: Combine Everything<br>def check_for_new_xcode_version():<br>    html_content = fetch_releases_page()<br>    if not html_content:<br>        return &quot;&quot;<br><br>    latest_version = parse_xcode_version(html_content)<br>    if not latest_version:<br>        print(&quot;No Xcode version found.&quot;)<br>        return &quot;&quot;<br><br>    local_version = get_xcode_version()<br>    if local_version != latest_version:<br>        print(f&quot;New Xcode version found: {latest_version}&quot;)<br>        return latest_version<br>    else:<br>        print(&quot;No new Xcode version.&quot;)<br>        return &quot;&quot;<br><br><br>if __name__ == &quot;__main__&quot;:<br>    new_version = check_for_new_xcode_version()</pre><p>Example for git action installing a specific Xcode version and running the script</p><pre>  check-xcode-version:<br>    runs-on: macos-14<br>    outputs:<br>      new_version: ${{ steps.check-xcode.outputs.new_version }}<br><br>    steps:<br>      - name: Set up Xcode version<br>        uses: maxim-lobanov/setup-xcode@v1<br>        with:<br>          xcode-version: &#39;15.4&#39;<br><br>      - name: Checkout code<br>        uses: actions/checkout@v2<br><br>      - name: Check Xcode version<br>        id: check-xcode<br>        run: |<br>          new_version=$(python ./scripts/checkXcodeVersion.py)<br>          echo &quot;Xcode version: $new_version&quot; <br>          echo &quot;::set-output name=new_version::$new_version&quot;</pre><p>Example for git action, sending a mail for the new Xcode version</p><pre>name: Send Email<br>inputs:<br>  email-recipient:<br>    description: The email to notify to<br>    type: string<br>    required: true<br>  email-subject:<br>    description: Email Subject<br>    type: string<br>    required: true<br>  email-body:<br>    description: Email Body<br>    type: string<br>    required: true<br>  email-password:<br>    description: The password of the email account to send the notification from<br>    required: true<br>runs:<br>  using: composite<br>  steps:<br>    - name: Checkout code<br>      uses: actions/checkout@v3<br>    - name: Send mail<br>      uses: dawidd6/action-send-mail@v3<br>      with:<br>        server_address: smtp.gmail.com<br>        server_port: 465<br>        username: **********<br>        password: ${{ inputs.email-password }}<br>        subject: ${{ inputs.email-subject }}<br>        to: ${{ inputs.email-recipient }}<br>        from: Github Actions<br>        html_body: ${{ inputs.email-body }}</pre><p>You can find further documentation for GitHub Actions <a href="https://docs.github.com/en/actions/writing-workflows">here</a></p><h3>Conclusion</h3><p>While there is a potential issue if Apple’s site changes, causing the script to break, this is a rare occurrence. In the worst case, you won’t receive the notification, but this method ensures you’re generally aware of Xcode releases and can decide when to update your app accordingly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=796e716e25bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding Mobile Crashes: A Comparative Guide for Android and iOS]]></title>
            <link>https://medium.com/@guylis/decoding-mobile-crashes-a-comparative-guide-for-android-and-ios-c311a9476079?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/c311a9476079</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 14:39:08 GMT</pubDate>
            <atom:updated>2024-09-04T14:39:08.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*oFfYtAcdvmicwf8h.jpeg" /></figure><p>Who among us engineers hasn’t encountered a crash — whether in production or during development and testing? It’s never fun, often difficult to reproduce, and sometimes even harder to trace back to its source, especially when the offending code isn’t ours. In this post, I’ll break down the problem and provide a step-by-step guide on how to analyze crashes both usig a third-party app and locally:</p><h3>Analyzing Crashes Using a Third-Party App</h3><p>The most popular SDK for analyzing crashes on both Android and iOS is Crashlytics by Google. To use it:</p><ol><li><strong>Integrate Crashlytics into your app</strong>: [See instructions <a href="https://firebase.google.com/docs/crashlytics/get-started?platform=android">here</a>].</li><li><strong>Check the Crashlytics dashboard</strong> for detailed crash reports and analysis.</li></ol><p>example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAs14M8FsYK54PkYcPJQNw.png" /></figure><h3>Analyzing Android Crashes Locally</h3><p>If the crash occurred recently and you have access to the device:</p><ol><li><strong>Enable on-device debugging</strong>: [See instructions <a href="https://developer.android.com/studio/debug/dev-options">here</a>].</li><li><strong>Ensure Android platform tools are installed on your computer</strong>: [See instructions <a href="https://developer.android.com/tools/releases/platform-tools">here</a>]. You’ll need the adb command-line tool.</li><li><strong>Run the following command</strong>: adb logcat -d &gt; crashes.txt.</li><li><strong>Search the crashes.txt file</strong> for the crash by looking for the text FATAL EXCEPTION.</li></ol><p>crash example</p><pre> FATAL EXCEPTION: main<br> Process: foxfoodreviews.wheretoeat, PID: 27186<br> java.lang.NullPointerException<br>  at foxfoodreviews.wheretoeat.view.fragments.ReviewDetailsFragment.updateReview(ReviewDetailsFragment.kt:172)<br>  at foxfoodreviews.wheretoeat.view.fragments.ReviewDetailsFragment.onCreateView(ReviewDetailsFragment.kt:293)<br>  at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2950)<br>  at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515)<br>  at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)<br>  at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)<br>  at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088)<br>  at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)<br>  at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)<br>  at android.os.Handler.handleCallback(Handler.java:942)<br>  at android.os.Handler.dispatchMessage(Handler.java:99)<br>  at android.os.Looper.loopOnce(Looper.java:226)<br>  at android.os.Looper.loop(Looper.java:313)<br>  at android.app.ActivityThread.main(ActivityThread.java:8762)<br>  at java.lang.reflect.Method.invoke(Native Method)<br>  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)<br>  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)</pre><h3>Class Names and Methods — impact of obfuscation</h3><p>When uploading an app to the Google Play Store, many apps undergo an obfuscation process that changes class names and methods into shorter, less recognizable forms. For example, the retrieveData method in the Review class might become b in class A. This process, known as obfuscation, can make crash reports harder to interpret. [See an example of an obfuscated crash below].</p><pre> E AndroidRuntime: FATAL EXCEPTION: main<br> E AndroidRuntime: Process: foxfoodreviews.wheretoeat, PID: 13511<br> E AndroidRuntime: java.lang.NullPointerException<br> E AndroidRuntime:  at a9.g.l2(Unknown Source:1097)<br> E AndroidRuntime:  at a9.g.A0(Unknown Source:126)<br> E AndroidRuntime:  at androidx.fragment.app.Fragment.d1(Unknown Source:15)<br> E AndroidRuntime:  at androidx.fragment.app.t.f(Unknown Source:188)<br> E AndroidRuntime:  at androidx.fragment.app.t.m(Unknown Source:116)<br> E AndroidRuntime:  at androidx.fragment.app.m.d0(Unknown Source:277)<br> E AndroidRuntime:  at androidx.fragment.app.m.b1(Unknown Source:84)<br> E AndroidRuntime:  at androidx.fragment.app.m.a0(Unknown Source:21)<br> E AndroidRuntime:  at androidx.fragment.app.m$g.run(Unknown Source:3)<br> E AndroidRuntime:  at android.os.Handler.handleCallback(Handler.java:942)<br> E AndroidRuntime:  at android.os.Handler.dispatchMessage(Handler.java:99)<br> E AndroidRuntime:  at android.os.Looper.loopOnce(Looper.java:226)<br> E AndroidRuntime:  at android.os.Looper.loop(Looper.java:313)<br> E AndroidRuntime:  at android.app.ActivityThread.main(ActivityThread.java:8762)<br> E AndroidRuntime:  at java.lang.reflect.Method.invoke(Native Method)<br> E AndroidRuntime:  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)<br> E AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)</pre><h3>Translating Obfuscated Symbols to Class Names and Methods</h3><p>To translate obfuscated symbols back to their original class names and methods, you have two options:</p><p><strong>Using the mapping.txt file</strong>:<br>When building your app, a mapping.txt file is generated at app/build/outputs/mapping/release. This file maps obfuscated symbols to their original names. For example:</p><pre>foxfoodreviews.wheretoeat.view.fragments.ReviewDetailsFragment -&gt; a9.g<br>void updateReview(boolean) -&gt; l2</pre><p>If you see a crash line like E AndroidRuntime: at a9.g.l2(Unknown Source:1097), you can map it back to E AndroidRuntime: at foxfoodreviews.wheretoeat.view.fragments.ReviewDetailsFragment.updateReview(Unknown Source:1097)</p><p><strong>Using Crashlytics</strong>:<br>When you integrate Crashlytics, the mapping.txt file is automatically uploaded as part of the process. This means that when a crash occurs, Crashlytics will automatically translate the obfuscated symbols back to the correct class and method names.</p><h3>Analyzing iOS Crashes Locally</h3><p>If the crash occurred recently and you have access to the device:</p><ol><li>In Xcode, go to <strong>Window &gt; Devices and Simulators</strong>.</li><li>Select <strong>Open Recent Logs</strong>.</li><li>Find the file that matches your app’s name, ending with .ips and the date the crash occurred.</li><li>Right-click on the file and choose <strong>Quick Look</strong> to view the details.</li></ol><p>crash example</p><pre>Thread 0 name:   Dispatch queue: com.apple.main-thread<br>Thread 0 Crashed:<br>0   libswiftCore.dylib                    0x19678e3c8 closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 228<br>1   libswiftCore.dylib                    0x19678e2a0 closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 331<br>2   libswiftCore.dylib                    0x19678dc2c _assertionFailure(_:_:file:line:flags:) + 183<br>3   Where2Eat                             0x1029d0830 ReviewDetailsViewController.updateReviewDescription(review:) + 3928<br>4   Where2Eat                             0x1029ce58c ReviewDetailsViewController.viewDidLoad() + 5400<br>5   Where2Eat                             0x1029cf564 @objc ReviewDetailsViewController.viewDidLoad() + 36<br>6   UIKitCore                             0x19a10d280 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83<br>7   UIKitCore                             0x19a10be48 -[UIViewController loadViewIfRequired] + 935<br>8   UIKitCore                             0x19a10ba80 -[UIViewController view] + 23<br>9   UIKitCore                             0x19a919af8 -[UINavigationController _startCustomTransition:] + 1359<br>10  UIKitCore                             0x19a1ae50c -[UINavigationController _startDeferredTransitionIfNeeded:] + 495<br>11  UIKitCore                             0x19a213304 -[UINavigationController __viewWillLayoutSubviews] + 95<br>12  UIKitCore                             0x19a4d52c0 -[UILayoutContainerView layoutSubviews] + 171<br>13  UIKit                                 0x23553af04 -[UILayoutContainerViewAccessibility layoutSubviews] + 59<br>14  UIKitCore                             0x19a0bea4c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1527<br>15  QuartzCore                            0x19951d3b4 CA::Layer::layout_if_needed(CA::Transaction*) + 503<br>16  QuartzCore                            0x19951cf38 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 147<br>17  QuartzCore                            0x1995780e0 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 463<br>18  QuartzCore                            0x1994ed028 CA::Transaction::commit() + 647<br>19  UIKitCore                             0x19a2752d0 _afterCACommitHandler + 83<br>20  CoreFoundation                        0x197e51658 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 35<br>21  CoreFoundation                        0x197e51414 __CFRunLoopDoObservers + 551<br>22  CoreFoundation                        0x197e8054c __CFRunLoopRun + 1027<br>23  CoreFoundation                        0x197e7fcd8 CFRunLoopRunSpecific + 607<br>24  GraphicsServices                      0x1dcd301a8 GSEventRunModal + 163<br>25  UIKitCore                             0x19a4b890c -[UIApplication _run] + 887<br>26  UIKitCore                             0x19a56c9d0 UIApplicationMain + 339<br>27  Where2Eat                             0x102a132a4 main + 64<br>28  dyld                                  0x1bb531e4c start + 2239</pre><h3>Class Names and Methods — impact of obfuscation</h3><p>When you upload your app to the store, the class and method names are converted into memory addresses. Here’s an example of what a crash report might look like after this conversion:</p><pre>0   Where2Eat                             0x100d423fc 0x100d30000 + 74748<br>1   Where2Eat                             0x100d41c44 0x100d30000 + 72772<br>2   Where2Eat                             0x100d40cd0 0x100d30000 + 68816<br>3   Where2Eat                             0x100d413a0 0x100d30000 + 70560<br>4   UIKitCore                             0x19a10d280 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83<br>5   UIKitCore                             0x19a10be48 -[UIViewController loadViewIfRequired] + 935<br>6   UIKitCore                             0x19a10ba80 -[UIViewController view] + 23<br>7   UIKitCore                             0x19a919af8 -[UINavigationController _startCustomTransition:] + 1359<br>8   UIKitCore                             0x19a1ae50c -[UINavigationController _startDeferredTransitionIfNeeded:] + 495<br>9   UIKitCore                             0x19a213304 -[UINavigationController __viewWillLayoutSubviews] + 95<br>10  UIKitCore                             0x19a4d52c0 -[UILayoutContainerView layoutSubviews] + 171<br>11  UIKit                                 0x23553af04 -[UILayoutContainerViewAccessibility layoutSubviews] + 59<br>12  UIKitCore                             0x19a0bea4c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1527<br>13  QuartzCore                            0x19951d3b4 CA::Layer::layout_if_needed(CA::Transaction*) + 503<br>14  QuartzCore                            0x19951cf38 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 147<br>15  QuartzCore                            0x1995780e0 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 463<br>16  QuartzCore                            0x1994ed028 CA::Transaction::commit() + 647<br>17  UIKitCore                             0x19a2752d0 _afterCACommitHandler + 83<br>18  CoreFoundation                        0x197e51658 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 35<br>19  CoreFoundation                        0x197e51414 __CFRunLoopDoObservers + 551<br>20  CoreFoundation                        0x197e8054c __CFRunLoopRun + 1027<br>21  CoreFoundation                        0x197e7fcd8 CFRunLoopRunSpecific + 607<br>22  GraphicsServices                      0x1dcd301a8 GSEventRunModal + 163<br>23  UIKitCore                             0x19a4b890c -[UIApplication _run] + 887<br>24  UIKitCore                             0x19a56c9d0 UIApplicationMain + 339<br>25  Where2Eat                             0x100d5c958 0x100d30000 + 182616<br>26  dyld                                  0x1bb531e4c start + 2239</pre><p>To translate memory addresses back to their corresponding class names and methods, you have two options:</p><p><strong>Using dSYM Files</strong>:<br>When you build or archive your app, dSYM files are generated for the app and all third-party dependencies. These files map the class and method names. To retrieve the necessary dSYM file:</p><ul><li>In Xcode, go to <strong>Window &gt; Organizer</strong>.</li><li>Find the archive for the app version that caused the crash, right-click the icon, and choose <strong>Show in Finder</strong>.</li><li>Right-click the file and select <strong>Show Package Contents</strong>.</li><li>Navigate to the dSYMs folder, where you&#39;ll find the dSYM files for the app and all third-party dependencies. You can copy these files to another directory.</li></ul><p>To translate the symbols in the crash log to class names and methods, use the atos command, which is part of the Xcode command line tools. Run the following command:</p><pre>atos -arch architecture -o /path/to/YourApp.dSYM/Contents/Resources/DWARF/YourApp -l loadAddress crashAddress</pre><p>For example, if you have the following crash line:</p><pre>0   Where2Eat                             0x100d423fc 0x100d30000 + 74748</pre><p>The load address is 0x100d30000, and the crash address is 0x100d423fc. The command would be:</p><pre>atos -arch arm64 -o Where2Eat.app.dSYM/Contents/Resources/DWARF/Where2Eat -l 0x100d30000 0x100d423fc</pre><p>The output will be:</p><pre>ReviewDetailsViewController.updateReviewDescription(review:) (in Where2Eat) (ReviewDetailsViewController.swift:167)</pre><p><strong>Using Crashlytics</strong>:<br>When you integrate Crashlytics, the dSYM file is automatically uploaded. This means that when a crash occurs, Crashlytics will automatically translate the addresses back to the correct class and method names.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c311a9476079" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Back to basics: choose your architecture — MVC vs MVP vs MVVM]]></title>
            <link>https://medium.com/@guylis/back-to-basics-choose-your-architecture-mvc-vs-mvp-vs-mvvm-c96ecc00b6ac?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/c96ecc00b6ac</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Sun, 28 May 2023 14:13:08 GMT</pubDate>
            <atom:updated>2023-05-28T14:13:08.129Z</atom:updated>
            <content:encoded><![CDATA[<h3>Back to basics: choose your architecture — MVC vs MVP vs MVVM</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*B9tAulu-e-Rg_c-CMt4RKQ.png" /></figure><p>Whenever we plan to write a new application or a feature, one of the questions that come to mind is which architecture to use.<br>The challenge being not only to choose an architectures, but also that there are many ways to implement each architectures and many languages to write them.</p><p>Here I will focus on:</p><ul><li>three common architectures.</li><li>a common implementation for each one along with code examples.</li><li>As a reference implementation, I will demonstrate using android with kotlin.</li></ul><h3>MVC — Model View Controller</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*xL1F9dF3hs6ZLjLuoCPmFQ.png" /></figure><p>As the name suggests, there are three entities here working together.</p><ul><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvc/model/MyModel.kt"><strong>The model</strong></a> — the data layer, responsible for managing the business logic and holding/handling data from the network/database.</li><li><a href="https://github.com/guylis/code_samples/tree/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvc/view"><strong>The view</strong></a> — the UI layer, a visualization of the data from the Model.</li><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvc/controller/MyController.kt"><strong>The controller</strong></a> — the logic layer, gets notified of the user’s behavior and updates the Model as needed.</li></ul><h4>MVP — Model View Presenter</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*trxf4DQKSbfA7aMbIGSpWw.png" /></figure><p>Similar to MVC, additionally addressing some problems related to unit testing and tight coupling between architecture components.</p><ul><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvp/model/MyModel.kt"><strong>The model</strong></a> — same as MVC.</li><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvp/view/CounterView.kt"><strong>The view</strong></a> — the activity acts as a view via interface when interacting with the presenter. Interactions will be with the presenter which is loosely coupled with it and not with the model.</li><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvp/presenter/CounterPresenter.kt"><strong>The presenter</strong></a> — the logic layer, behaves the same as the controller but is more generic, allows for better unit testing and makes changes to the app easier.</li></ul><h4>MVVM — Model View View-Model</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*CbMSRMGVeg_r3BOyBxV-OA.png" /></figure><p>This pattern has some similarities with the MVP design pattern, however, the drawbacks of the MVP pattern has been solved by MVVM. It suggests separating the data presentation logic (Views or UI) from the core business logic part of the application.</p><ul><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvvm/model/MyModel.kt"><strong>The Model</strong></a> — This layer is responsible for the abstraction of the data sources. Model and ViewModel work together to get and set the data.</li><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvvm/view/MVVMSampleActivity.kt"><strong>The View</strong></a> - The purpose of this layer is to inform the ViewModel about the user’s action. This layer observes the ViewModel and does not contain any kind of application logic.</li><li><a href="https://github.com/guylis/code_samples/blob/main/android/ArchitecturesSamplesActivity/app/src/main/java/com/guylis/architecturessamplesactivity/mvvm/viewModel/MyViewModel.kt"><strong>The ViewModel</strong></a> - It exposes those data streams which are relevant to the View. Moreover, it servers as a link between the Model and the View.</li></ul><p>Here’s a short summary of the implementation and references for each architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*sapuTKEBTJ0E5zEXvaZhUw.png" /></figure><ul><li>For MVC, an additional common implementation is for the activity to implement both the view and the controller.</li></ul><p>Here’s a short summary of the pros and cons:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNxHdW69fLLE-lB3fkhEHg.png" /></figure><p>See the <a href="https://github.com/guylis/code_samples/tree/main/android/ArchitecturesSamplesActivity">project</a> for examples of android implementations of the three architectures, in which there is a counter that is incremented and an input text that updates the screen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c96ecc00b6ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code reviews — tips and good practices for the reviewer]]></title>
            <link>https://medium.com/@guylis/code-reviews-tips-and-good-practices-for-the-reviewer-61eaf39ab7ab?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/61eaf39ab7ab</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 09:12:37 GMT</pubDate>
            <atom:updated>2023-03-16T09:12:37.947Z</atom:updated>
            <content:encoded><![CDATA[<h3>Code reviews — tips and good practices for the reviewer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*svHLlVKa2GBLqt3Z5a7D0A.jpeg" /></figure><h4>The problem</h4><p>Speaking from experience, I can say that one of the most disliked activity by developers is the code review process. <br>This is for a number of reasons.</p><ol><li><strong>Time</strong> — when you are going over someone else’s code, it’s hard to know how long it will take. I remember code reviews I had with over 150 modified classes, or ones that modified a class that had over 4,000 lines of code.</li><li><strong>Context switch</strong> — the task for a code review rarely comes when you have time for it, meaning you need to stop whatever it is you’re working on and make time for it.</li><li><strong>Difference of opinion</strong> — since there’s usually more than one solution to every problem, it’s hard to go over a solution you may not agree with its approach and comment on it.</li><li><strong>Code style</strong> — in most of the places I worked with including the current one, the lack of definitive code style makes it harder to review code in a style that is different than yours and regarding how much to comment on it in the code review.</li><li><strong>Lack of Documentation</strong> — when going over the code, there’s usually no <a href="http://www.cs.utsa.edu/~cs3443/uml/uml.html">UML/class diagram</a> or documentation added to it, meaning it’s up to you to understand the logic that was done.</li></ol><p>Despite this, I think that code review tasks are a substantial part of what makes a good developer a great one. It gives you insight to other developers way of thinking and being a part of coding tasks you do not have time to write it. Ultimately performing code reviews is a great way to increase your knowledge base, share your input and be able to assist other developers without actually writing the code yourself.</p><p>First, I’ll share some code guidelines for the code reviewer I use at my work and ones I see that others in the team use in order to make the code reviews be less of a nuisance and more of a jumping point to improve yourself as a developer.</p><h4>Guidelines</h4><ol><li><strong>Dedicated time</strong> — obviously there are varying lengths of code reviews, from ones that can take less than 30 minutes to ones that can take days (150 classes, remember). When working either in <a href="https://www.atlassian.com/agile/scrum/sprints">Sprints</a> or <a href="https://www.atlassian.com/agile/kanban#:~:text=What%20is%20kanban%3F,of%20work%20at%20any%20time.">Kanban</a>, you can approximate how long during a week you need to spend on code reviews (if you’re not sure, just write it down, during a month for every week and take the average time). Let’s say it’s 5 hours a week.<br>Put 1 hour every day at a time you think fits your schedule to do code reviews and use that hour for the code reviews. Obviously there are days when that duration can go longer or shorter, but it will enable you to have dedicated time for it during the week.</li><li><strong>Prerequisites</strong> — this might seem small but having a checklist of what is required to send a code review can make the process so much easier for the developer doing the review. This list can vary from one work place to another, but a couple of examples are adding the ticket requirement to the Pull request, running automation on the code, running tools like <a href="https://developer.android.com/studio/write/lint">linter</a> to fix synatx issues, performing internal testing, writing unit tests for it and running the code itself. One way to implement this is to add a default template to the code review with a checklist of what was done prior to sending it.</li><li><strong>Avoid Ping pong comments</strong> — I saw many cases when developers got into heated arguments in the code reviews that resulted from their way of thinking, their code style or sentiments on code that was initially written by them. Instead, the comments should be based in logic and not emotions and to give sound reasoning to your arguments. If you see that the comments turn into more of an argument, I suggest to set a short meeting to discuss those specifically.</li></ol><h4>Techniques</h4><p>Other than general guidelines, I also want to share techniques for the reviewer that will make the code review even better.</p><ol><li><strong>Go over the requirements</strong> — you’ll be surprised how often this is overlooked. In many cases due to duplicated requirements or ones that were modified since the original ones were written, the solution often strays from them and in some cases code was added that is unrelated to the requirements at all. This should be the starting point of the code review.</li><li><strong>Comment only on the changes in the code review</strong> — in so many times, I saw developers comment in the code review on changes unrelated to the pull request. This is often the reason the code review stretches beyond the estimated time. I know it’s tempting but even if you see code in the pull request that is wrong in your opinion, but unrelated to the changes the developer did in the pull request, do not comment it within the scope of the code review. Regarding how you can handle these issues, there are many options here I will not get into.</li><li><strong>Run the code</strong> — in many cases, it’s not enough to simply go over the code. Only when running it and looking at logs surrounding the flow, you will discover issues. In some cases, running the code can require a special configuration so this needs to be part of the code review handover.</li><li><strong>Refactor vs Code maintenance</strong> — the balance here is delicate and when going over the code, you need to think in which cases it was better for the developer to write duplicated code that won’t endanger the existing code and in which cases a refactor is the better way to go. This is never black and white, there are many shades of grey here that are affected by the time the developer has to approve the code, the way the code can be used in other usages and the dangers of regression.</li><li><strong>Logic over syntax</strong> — comments on code reviews usually differentiate between the code style and syntax of the code and the logic that the code implemented. Find the right balance here. I prefer taking the approach of writing only logic based comments and if there’s anything related to the syntax, I either reference our coding style definitions in the team or raise it in the developer meetings.</li><li><strong>Readability over efficiency</strong> — in some cases it’s better to write code that is longer if it’s more readable and will make it easier for other people to understand it and refactor it at a later time. I saw many cases where a super efficient code was written in a way that caused other developers confusion and later was refactored with bugs due to its implementation. Another option is to add comments to the code if there’s reason to believe the comment will help understand the implementation.</li></ol><h4>Conclusion</h4><p>Even though code reviews may seem exhausting, never-ending and hard for you to find the time for them or approximate how long they will take, when taking the right approach to them, it will be much easier to handle them.<br>You will see that the better you get, more people will come to you for assistance in reviewing their code, you will be in a great position to support your team members and for them to support you in return.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61eaf39ab7ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lists — the old way vs the new way with Android Compose]]></title>
            <link>https://medium.com/@guylis/lists-the-old-way-vs-the-new-way-with-android-compose-6376ac39f10f?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/6376ac39f10f</guid>
            <category><![CDATA[compose-ui]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 16:35:08 GMT</pubDate>
            <atom:updated>2023-02-16T16:35:08.151Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lists — the old way vs the new way with Android Compose</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-FcVtgzTlRh1trYEig3ow.jpeg" /></figure><p>For nearly 20 years (since 2008) when we had to add a list to our app for Android, we used a <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong></a>, which was later upgraded to a <a href="https://developer.android.com/develop/ui/views/layout/recyclerview?gclid=CjwKCAiA0JKfBhBIEiwAPhZXD4RANrU8pH1p-WrLAxRAlAO_BVY6EUKJw-KbPgSn38adVUhf3P34MxoCeIYQAvD_BwE&amp;gclsrc=aw.ds"><strong>RecyclerView</strong></a> (in 2014) as part of Material Design in the Android Support Libraries and later added as part of <a href="https://developer.android.com/jetpack/androidx"><strong>androidX</strong></a> (in 2018).</p><p>Then, in 2019 a new way of working with UI was announced in <a href="https://www.youtube.com/watch?v=VsStyq4Lzxo&amp;t=957s">Google IO</a> and 2 years later in 2021, Google released the first stable version of <a href="https://developer.android.com/jetpack/compose?gclid=CjwKCAiA0JKfBhBIEiwAPhZXD_rZC2MR8GzPenVuZWRlSxq5qXy2OGWBRwycLxAGt-XqL_x8RJjzixoCNv8QAvD_BwE&amp;gclsrc=aw.ds">Jetpack Compose</a>.<br>I won’t go into all the difference between working with compose and the old ways using xml, other than mentioning the 3 key advantages:</p><ul><li>less coding</li><li>one source of truth (as you will see in the example below)</li><li>getting new features/bug fixes</li></ul><p>In this post, I’ll first shortly go over the old way of implementing a list and then, the new way using compose (the examples will be in Kotlin and I won’t use the view binding API that already exists in the old method)</p><h3>The Old Way</h3><ol><li>Add to the xml representing the screen layout a recycledView element</li></ol><pre>    &lt;androidx.recyclerview.widget.RecyclerView<br>        android:id=&quot;@+id/recyclerview&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        tools:listitem=&quot;@layout/series_item&quot; /&gt;</pre><p>2. Create an XML representing an item in the list</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:orientation=&quot;horizontal&quot;<br>    tools:context=&quot;.MainActivity&quot;<br>    android:gravity=&quot;center&quot;&gt;<br><br>    &lt;ImageView<br>        android:id=&quot;@+id/imageview&quot;<br>        android:layout_width=&quot;150dp&quot;<br>        android:layout_height=&quot;150dp&quot; /&gt;<br><br>    &lt;RelativeLayout<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot; &gt;<br><br>        &lt;TextView<br>            android:id=&quot;@+id/title&quot;<br>            android:layout_width=&quot;wrap_content&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginStart=&quot;10dp&quot;<br>            android:layout_marginLeft=&quot;15dp&quot;<br>            android:text=&quot;Item&quot;<br>            android:textColor=&quot;@color/white&quot;<br>            android:textSize=&quot;20sp&quot;<br>            android:textStyle=&quot;bold&quot; /&gt;<br><br>        &lt;TextView<br>            android:id=&quot;@+id/description&quot;<br>            android:layout_below=&quot;@+id/title&quot;<br>            android:layout_width=&quot;wrap_content&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginStart=&quot;10dp&quot;<br>            android:layout_marginLeft=&quot;15dp&quot;<br>            android:text=&quot;Item&quot;<br>            android:textColor=&quot;@color/white&quot;<br>            android:textSize=&quot;14sp&quot;<br>             /&gt;<br>    &lt;/RelativeLayout&gt;<br><br><br><br>&lt;/LinearLayout&gt;</pre><p>3. In the code Create an Adapter class in charge of connecting the UI to the data</p><pre>class SeriesItemAdapter(private val list: List&lt;Series&gt;) : RecyclerView.Adapter&lt;SeriesItemAdapter.SeriesDataHolder&gt;() {<br><br><br>    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SeriesDataHolder {<br>        val view = LayoutInflater.from(parent.context)<br>            .inflate(R.layout.series_item, parent, false)<br><br>        return SeriesDataHolder(view)<br>    }<br><br>    override fun onBindViewHolder(holder: SeriesDataHolder, position: Int) {<br>        val series = list[position]<br><br>        holder.imageView.setImageResource(series.imageId)<br>        holder.titleView.text = series.title<br>        holder.descriptionView.text = series.description<br>    }<br><br>    override fun getItemCount(): Int {<br>        return list.size<br>    }<br><br>    class SeriesDataHolder(ItemView: View) : RecyclerView.ViewHolder(ItemView) {<br>        val imageView: ImageView = itemView.findViewById(R.id.imageview)<br>        val titleView: TextView = itemView.findViewById(R.id.title)<br>        val descriptionView: TextView = itemView.findViewById(R.id.description)<br>    }<br><br>}</pre><p>4. In the code of the activity load the xml list element, configure it and connect the adapter to it</p><pre>        val seriesList = findViewById&lt;RecyclerView&gt;(R.id.recyclerview)<br>        seriesList.layoutManager = LinearLayoutManager(this)<br>        val adapter = SeriesItemAdapter(SeriesDataProvider.seriesList)<br>        seriesList.adapter = adapter</pre><p>That’s it. In total, you have:</p><ul><li>2 xmls you need to configure for the list.</li><li>The place in the code you connect those xmls from.</li><li>An adapter class representing the data holder and binder.</li></ul><p>All in all, three source of truths plus a lot of code and configurations to maintain.</p><h3>The New Way</h3><ol><li>Use a LazyColumn composable for the list</li></ol><pre>@Composable<br>    fun SeriesList() {<br>        LazyColumn(<br>            modifier = Modifier.background(Color.Black)<br>        ) {<br>            items(<br>                items = SeriesDataProvider.seriesList,<br>                itemContent = {<br>                    Series(series = it)<br>                }<br>            )<br>        }<br>    }</pre><ol><li>Use Row &amp; Column composable for the item</li></ol><pre>        Row() {<br>            Image(<br>                modifier =  Modifier.size(150.dp).align(Alignment.CenterVertically),<br>                painter =  painterResource(id = series.imageId),<br>                contentDescription = &quot;&quot;)<br>            Column(<br>                modifier = Modifier<br>                .padding(16.dp)<br>                .align(Alignment.CenterVertically)<br>            ) {<br>                Text(color = Color.White, text = series.title, style = typography.h6)<br>                Text(color = Color.White,text = series.description, style = typography.caption)<br>            }<br>        }</pre><p>You can see both examples in the <a href="https://github.com/guylis/code_samples/tree/main/android/ListExample">project</a> here, plus a screenshot below of how it looks like in both implementations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JyJF2T1OuWd653KtcPziA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6376ac39f10f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Discover whether a view is visible on the screen — the iOS challenge]]></title>
            <link>https://medium.com/@guylis/discover-whether-a-view-is-visible-on-the-screen-the-ios-challenge-851b0f2b3342?source=rss-290527b69969------2</link>
            <guid isPermaLink="false">https://medium.com/p/851b0f2b3342</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[application]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Guy Lis]]></dc:creator>
            <pubDate>Sun, 27 Nov 2022 15:13:26 GMT</pubDate>
            <atom:updated>2022-11-27T15:13:26.484Z</atom:updated>
            <content:encoded><![CDATA[<h3>Discover whether a view is visible on the screen — the iOS challenge</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*nCl03xQoTqcDsX5djyy3bA.png" /></figure><p>One of the challenges when working on apps or SDKs is to handle code from third party sdks and the app itself.<br>I recently ran into an interesting problem — whether a view is visible on the screen throughout the application lifecycle.</p><p>Sounds simple enough, right? You would think that there’s API for it and one line will solve the problem.</p><h3>Foreground vs Background</h3><p>In iOS, when in the background, all app logic stops, so implementing a timer that runs at an interval to check whether a view is visible or not will stop working when the app goes to the background.</p><h3>When the app is in the foreground</h3><p>One way that mostly works is to check whether the view in question is in a window that currently has window focus, if not, another view controller is shown and focused on top of it.<br>(code examples below are in swift)</p><pre><strong>if</strong> !(view.window?.isKeyWindow ?? <strong>false</strong>) {<br>    // <em>view is not </em>visible<em><br></em>}</pre><p>In some cases the view controllers displaying on top of the view controller showing the view do not change the window focus of the view. This can occur for example when displaying a view controller and defining <a href="https://developer.apple.com/documentation/uikit/uimodalpresentationstyle">modalPresentationStyle</a> with type <a href="https://developer.apple.com/documentation/uikit/uimodalpresentationstyle/overfullscreen">overFullScreen</a>.<br>In this case the check above will not work.<br>The solution in this case can be to:</p><ol><li>find the matching view controller of the view</li><li>find the presenting view controller</li><li>compare them</li></ol><p>as you can see in the code below</p><h4>finding the view controlling matching the view</h4><pre>extension UIView {<br>    func findMatchingViewController() -&gt; UIViewController? {<br>        if let nextResponder = self.next as? UIViewController {<br>            return nextResponder<br>        } else if let nextResponder = self.next as? UIView {<br>            return nextResponder.findViewController()<br>        } else {<br>            return nil<br>        }<br>    }<br>}</pre><h4>finding the presenting view controller</h4><pre>extension UIWindow {<br>    func presentingViewController() -&gt; UIViewController? {<br>        var top = self.rootViewController<br>        while true {<br>            if let presented = top?.presentedViewController {<br>                top = presented<br>            } else if let nav = top as? UINavigationController {<br>                top = nav.visibleViewController<br>            } else if let tab = top as? UITabBarController {<br>                top = tab.selectedViewController<br>            } else {<br>                break<br>            }<br>        }<br>        return top<br>    }<br>}</pre><h4>check whether a view is visible using the logic above</h4><pre>let viewControllerMatchingView = label.findMatchingViewController()<br>let presentingViewController = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.presentingViewController()<br>       <br>if (viewControllerMatchingView != presentingViewController) {<br>   // view is not visible<br>}</pre><p>To see the logic above you can download the <a href="https://github.com/guylis/code_samples/tree/main/ios/CheckViewOnScreen">project</a></p><h3>Summary</h3><p>When checking for view visibility on a screen, it’s important to understand that the API that is available from apple does not cover all cases and additional logic in the code can check for other scenarios.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=851b0f2b3342" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>