<?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 Darren Atherton on Medium]]></title>
        <description><![CDATA[Stories by Darren Atherton on Medium]]></description>
        <link>https://medium.com/@DarrenAtherton?source=rss-b5cff2d71679------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*HruEAaqLQh5or4HEwjWvoQ.jpeg</url>
            <title>Stories by Darren Atherton on Medium</title>
            <link>https://medium.com/@DarrenAtherton?source=rss-b5cff2d71679------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 13:39:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@DarrenAtherton/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[Android Feature Development at Babylon Health — Part 2: From Designs to Architecture]]></title>
            <link>https://medium.com/babylon-engineering/android-feature-development-at-babylon-health-part-2-from-designs-to-architecture-d392dbeeb1ec?source=rss-b5cff2d71679------2</link>
            <guid isPermaLink="false">https://medium.com/p/d392dbeeb1ec</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Darren Atherton]]></dc:creator>
            <pubDate>Tue, 01 Sep 2020 10:35:59 GMT</pubDate>
            <atom:updated>2020-09-01T10:36:57.195Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android Feature Development at Babylon Health — Part 2: From Designs to Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EKfxHLYgXZ-EIbGbu6vEZg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jamessutton_photography?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">James Sutton</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This article is part 2 of a series on feature development at <a href="https://www.babylonhealth.com/">Babylon Health</a>, describing my thoughts from the design stage all the way to feature completion. In <a href="https://medium.com/babylon-engineering/android-feature-development-at-babylon-health-part-1-thinking-about-the-problem-d1b68521350c">part 1</a>, we discussed the tools we use at Babylon to manage and track our feature work. We then discussed how I begin to approach problems, including how I analyse designs and try to come up with an appropriate solution by asking questions, both to myself and to the team.</p><p>Part 1 was largely focused on the designs of the UI/UX of the feature. In this part, I will show how I started to approach a solution by thinking about how to translate our designs into software architecture. This includes asking myself more questions but this time focused on the technical implementation aspect rather than the UI designs.</p><h3>Asking the Technical Questions</h3><p>Once I’m sure that I have the answers to the design-related questions in the <a href="https://medium.com/babylon-engineering/android-feature-development-at-babylon-health-part-1-thinking-about-the-problem-d1b68521350c">previous article</a>, I start to form a mental image of how I will translate those designs into actual classes and functions. This comes with its own set of topics to run through. For example:</p><ul><li><em>How do I ensure consistency with the current app architecture?</em></li><li><em>How will everything fit together, e.g. when I need to reference my new code from the existing code, or vice-versa?</em></li><li><em>How will I maintain the project’s current coding conventions for design patterns (both in our presentation layer and SDK) and overall architecture?</em></li></ul><h3>Feature Architecture</h3><p>The first topic that usually crosses my mind when figuring out how to implement some design is how the code would appear visually in terms of architecture. I start to think about which classes I will need to create and how they will all fit together. One technique that helps me to determine these classes is to try to visualise the architecture in my mind. If it helps, you could also sketch out a quick diagram of how you think each class should interact and reference each other.</p><p>At Babylon, we have a guideline that all new features which involve UI should use the <strong>Model-View-Intent (MVI)</strong> pattern (also known as unidirectional data flow as popularised by <a href="https://redux.js.org/basics/data-flow/">Redux</a>) and Kotlin. Legacy features continue to use <strong>Model-View-Presenter (MVP)</strong> and Java until there is a need to rewrite the feature. The library that we use to enforce the MVI design pattern is called <a href="https://github.com/babylonhealth/orbit-mvi">Orbit</a>, which was created and open-sourced here at Babylon. For this article, I am going to assume some prior knowledge of MVI. However, if you would like to learn more about it and how we implement it at Babylon, then I would recommend our <a href="https://github.com/babylonhealth/orbit-mvi/#overview">overview</a> as well as this great <a href="https://medium.com/babylon-engineering/introducing-orbit-mvi-for-kotlin-and-android-62491f4e3234">article</a> by my colleague <a href="https://twitter.com/TheAngroid">Mikolaj Leszczynski</a>.</p><h4>The Feature We Are Developing</h4><p>To refresh our memory on what we are developing, <strong>Figure 1</strong> below shows the design for the phone widget from the previous article:</p><figure><img alt="Figure 1: Original phone widget design" src="https://cdn-images-1.medium.com/max/1024/0*b6uQuDhPzRdB4I1X.png" /><figcaption>Figure 1: Original phone widget design (designed by <a href="https://twitter.com/daniel_spagnolo">Daniel Spagnolo</a>)</figcaption></figure><p>Approaching this new feature, I started to visualise how I would represent this using MVI with Orbit. An orbit consists of several classes:</p><ul><li><strong>Actions: </strong>typically representing the user’s behaviours as events. For example, ClickCountryFlagAction represents when the user is selecting a new country. Creating a list of actions requires thinking about how the user will interact with our screen and what events may be generated asynchronously, such as API call results.</li><li><strong>Transformers: </strong>takes actions and transforms them into new events, typically after fetching some data or performing some business logic. For example, fetching a list of countries to choose from an API after a button click. Writing a transformer allows us to think about which data you will need and when to load it.</li><li><strong>State: </strong>holds the data shown on screen (a UI model). For example, storing the list of countries and currently selected country. Defining state is usually straightforward as they are usually a 1–1 mapping with what you see on screen.</li><li><strong>Reducers</strong>: Takes transformers events or user actions and updates the State. Defining reducers forces us to think about the different states a screen can be in. For example, under what conditions would the user reach an error state?</li><li><strong>Middleware:</strong> Wires the above classes together — listens for events and routes them to transformers and reducers. Persisted across process deaths inside a ViewModel. Defining a middleware allows you to think about how the screen should behave — given action <strong><em>x</em></strong>, behaviours <strong><em>y</em></strong> and <strong><em>z</em></strong> should take place sequentially. For example, “when the user clicks on a country, log some analytics, update the state and navigate to the previous screen”.</li><li><strong>Renderer</strong>: Optionally, we have a Renderer class to render more complex lists of <a href="https://github.com/lisawray/groupie/blob/master/library/src/main/java/com/xwray/groupie/Item.java">Item</a> (an abstraction of RecyclerView.ViewHolder) based on our State. Again, this allows us to clearly define the different states that a screen can be in, thinking about how a loading screen, error screen or content screen should look.</li></ul><p>At Babylon, we also have an internal Android Studio plugin which generates the above classes (and related test classes) for an orbit.</p><p>Given the design, I identified that I would need two orbits — we typically create one orbit stack (middleware, transformers, reducers and state classes) per screen. The output of an orbit is the State to be rendered on screen. This is how I imagined the feature would look like when translated into our architecture (and the resulting code was very close to this):</p><figure><img alt="Figure 2: Phone widget architecture defined as two orbits" src="https://cdn-images-1.medium.com/max/1024/1*555pXJ4eKMK5DRGD1gi3NA.png" /><figcaption>Figure 2: Phone widget architecture defined as two orbits</figcaption></figure><p>In <strong>Figure 2</strong> above, we can see that I represented both the phone widget itself and the country code picker screen that it opens as two separate orbits. They are two separate pieces of UI, however, one of the widgets/screens is never used without the other, which couples them together. Upon observing this fact, I considered that the two screens could somehow share an orbit (and therefore share a State). However, I decided that they were sufficiently complex enough on their own to require their own orbit and State. This turned out to be a good decision because it helped me to delegate only a single responsibility to each class and place screen-specific business logic in the appropriate place while keeping each State object simple.</p><p>Considering that the two components are combined as one feature, the next logical step in my thinking was <strong>how should our two orbits communicate?</strong> I wanted the phone widget to also be able to react to country code picker state updates and side effects. One use case I had in mind was for the phone widget to know when the user had selected a country code on the picker screen so that it could update itself accordingly (by updating the country flag and phone code displayed). To solve this, I had both the phone widget and country code picker keep a reference to the country picker ViewModel and had both listen for updates. When the country code picker receives a new state and event, the phone widget will also be aware of it.</p><h3>Consider How Your Code Will Be Used</h3><p>Knowing how you will integrate your new feature into your existing app is important, though highly app-specific. While many features can be considered standalone or only to be used once, features such as our phone widget are intended to be used in multiple places. As a result, it can be crucial that we consider the surrounding context of our features through the lens of interoperability and reusability.</p><p>Having some knowledge about <strong>how</strong> your feature will be integrated is useful as it can influence its design and help shape its public API. Remember, there is a difference between knowing about its environment and actually <a href="https://blog.ndepend.com/programming-coupling/">tightly-coupling</a> your software to its surroundings. The intention here is to make it reusable and easy integrate, rather than change your feature to only suit the surrounding software.</p><p>A good way of knowing if your code will be tightly-coupled is if you have written logic which depends on the outer surrounding. For example, if our phone widget needed to ‘reach out’ to a surrounding (specific) Activity to find something out, it would be considered tightly-coupled and not reusable. We are looking to have widgets which don’t require this type of code since we want to be able to render them anywhere.</p><p>Since most of the screens in the <a href="https://play.google.com/store/apps/details?id=com.babylon">Babylon Health app</a> are implemented as a RecyclerView with a list of Groupie Item, this determines how we now design our widgets. I had the prior knowledge that the entire phone component would need to be resolved to an Item in the sign-up screen RecyclerView and other potential screens (with a RecyclerView). This helped to shape the phone widget API because all we needed was a render() function which returns an Item to expose to our Activity, Fragment or View.</p><p>In the example below, we can see how we design our widgets to emit a new state when it is ready to be re-rendered. We then have a render function which takes that state and returns an Item to be included in whichever screen we are currently displaying:</p><pre>class PhoneWidget {<br><br>    fun connect(<br>        activity: Activity,<br>        stateConsumer: (PhoneWidgetState) -&gt; Unit<br>    ) {<br>        // Initialises ViewModels with stateConsumer listener<br>    }<br><br>    fun render(<br>        state: PhoneWidgetState<br>    ): List&lt;Item&gt; {}<br>}<br><br>class SignUpActivity {<br><br>    override fun onStart() {<br>        super.onStart()<br>        phoneWidget.connect(<br>            activity = this,<br>            stateConsumer = ::phoneWidgetStateConsumer<br>        )<br>    }<br><br>    private fun phoneWidgetStateConsumer(<br>        phoneWidgetState: PhoneWidgetState<br>    ) {<br>        phoneWidgetSection.update(<br>            phoneWidget.render(state = phoneWidgetState)<br>        )<br>    }<br>}</pre><p>This pattern is very effective — what we essentially have is a list of self-sufficient components that are just being rendered by a parent list. By self-sufficient, I mean that they manage their own business logic, fetch their own data from the data layer, specify <strong>how</strong> to be rendered and are decoupled from their host. This also promotes reusability which is already paying off, as this phone component has now been used in multiple places inside the app with minimal ‘glue’ code required to integrate it.</p><h3>Consistency vs Suitability</h3><p>One of the benefits of enforcing the same MVI pattern everywhere is <strong>consistency</strong>. If we know that we implement all of our UI features using the same patterns, then that immediately gives us confidence in both debugging existing features and implementing new features. Consistent architecture across the codebase serves as documentation for future features. It gives me a wealth of code to use as a reference for my own feature. If I am tasked with debugging another developer’s work, I am immediately familiar with the flow of data and the general structure of the feature.</p><p>Now, there is an argument to make that you should always pick the <strong>most suitable</strong> design pattern for your specific task. To some extent, I agree with this — some features are much simpler than others and may benefit from a design pattern involving less code. However, I have also witnessed the benefits that consistency gives when you have a large team and lots of features. The familiarity that it provides to both new and existing developers has been invaluable.</p><p>An example of this is in the presentation layer of our codebase — as mentioned earlier in the article, legacy features use the MVP pattern while newer features use MVI. Typically, MVI in our codebase involves the creation of many classes required by an orbit. Now let’s say we wanted to introduce a new (simple) feature which has only one piece of logic and fetches one piece of data. Is the same design pattern (MVI) always the correct tool here?</p><p>There is no doubt that some features could be implemented in a simpler form if we choose a different pattern for each feature. This would certainly result in some features being much smaller, but what do we lose? There is a certain shared understanding that the team gains from being <strong>consistent</strong>.</p><p>Since we have a specific way of implementing features/screens, this gives us many benefits such as:</p><ul><li>More focused PR reviews so that the reviewers can focus on the business logic with less ‘noise’ from the structure.</li><li>Easier transitions between different features for developers since they are all structured similarly.</li><li>Common expectations for testing, such as how to test features, which files to create and naming conventions.</li><li>Smoother onboarding of new team members as there is only one presentation layer pattern to understand.</li></ul><h3>Conclusion</h3><p>Translating your designs into a suitable architecture can seem like a complex task. However, the process can be made smoother by visualising/drawing the feature out, referencing existing feature code, considering the surrounding context and agreeing on project conventions for developing features.</p><p>When it comes to conventions, we could make an argument for both <strong>consistency</strong> and <strong>suitability</strong>. What is most important is that it is agreed upon by your team as a shared understanding of how to write code is ultimately more important, especially when working on larger projects.</p><p>In the next part, we will continue planning our implementation by exploring how we can take our designs and translate them into code, so stay tuned!</p><p><em>At Babylon, we believe it’s possible to put an accessible and affordable health service in the hands of every person on earth. The technology we use is at the heart and soul of that mission. Babylon is a Healthcare Platform, currently providing online consultations via in-app video and phone calls, AI-assisted Triage and Predictive Health Assistance.</em></p><p><em>If you are interested in helping us build the future of healthcare, please find our open roles </em><a href="https://jobs.lever.co/babylonhealth?lever-via=tczkkcpY3l"><em>here</em></a><em>.</em></p><p>Follow Babylon Engineering on Twitter <a href="https://twitter.com/babylon_eng">@Babylon_Eng</a> and the author of this article <a href="https://twitter.com/darrenatherton">@DarrenAtherton</a>.</p><figure><img alt="Babylon Engineering logo" src="https://cdn-images-1.medium.com/max/303/1*U30VdyTHVTBeTEK75mGLMw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d392dbeeb1ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/babylon-engineering/android-feature-development-at-babylon-health-part-2-from-designs-to-architecture-d392dbeeb1ec">Android Feature Development at Babylon Health — Part 2: From Designs to Architecture</a> was originally published in <a href="https://medium.com/babylon-engineering">Babylon Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Feature Development at Babylon Health — Part 1: Thinking About the Problem]]></title>
            <link>https://medium.com/babylon-engineering/android-feature-development-at-babylon-health-part-1-thinking-about-the-problem-d1b68521350c?source=rss-b5cff2d71679------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1b68521350c</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Darren Atherton]]></dc:creator>
            <pubDate>Mon, 02 Mar 2020 08:01:01 GMT</pubDate>
            <atom:updated>2020-03-02T08:01:01.323Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android Feature Development at Babylon Health — Part 1: Thinking About the Problem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EKfxHLYgXZ-EIbGbu6vEZg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jamessutton_photography?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">James Sutton</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In the Android community, there are a lot of great technical articles out there which provide a detailed walkthrough of how to accomplish some task on the platform. They are invaluable to the community — I am very thankful for them and really enjoy reading them! One type of article which I feel does not get written enough is the type which not only shares how to implement something, but also shares the developers thought process along the way.</p><p>In my opinion, there is something fascinating about reading how developers think when trying to implement a solution. Sometimes we implement solutions that just work right away, while other times we implement solutions that do not. We have to iterate on the latter until we get them right.</p><blockquote>“It is about the journey, not the destination.”</blockquote><p>In programming, the above quote is not strictly true — the destination (the solution) and its correctness absolutely matter. However, I appreciate the sentiment of the quote because I am often more interested in hearing about the journey that the engineer went through in terms of their thought process while working on their solution. I enjoy knowing how they planned an implementation of a solution, what the first iteration of the solution they came up with was, how it evolved over time, what the final solution was and the decisions they had to make in-between. Not only is this process just fascinating to read, it also helps me to think about my own development process. It influences how I gather my thoughts and how I translate those thoughts into a usable, testable implementation.</p><p>In this series, I am going to walk through a feature I have been working on at <a href="https://www.babylonhealth.com/">Babylon Health</a>, while describing some of the shared processes/systems we have at the company, how I planned and implemented a solution and some of the technical decisions I made along the way. Sometimes, feature development can take twists and turns throughout the process and this article intends to show the evolution of a feature from start to finish.</p><h3>Starting to Think About the Problem</h3><p>At Babylon Health, every piece of work that we do on the <a href="https://play.google.com/store/apps/details?id=com.babylon">Android app</a>, whether it is a feature or a bug fix, is accounted for on <a href="https://www.atlassian.com/software/jira">Jira</a>. Generally, each <a href="https://medium.com/productmanagement101/spotify-squad-framework-part-i-8f74bcfcd761">squad</a> (a small, autonomous cross-functional team) has its own Jira board. There is also a shared Android board for tech debt and various other tasks that are unrelated to our squad work. A list of our current squads can be found <a href="https://github.com/babylonhealth/android-playbook">here</a>.</p><p>So when starting a new piece of squad work, the squad Jira board is the first place I look. It is the shared source of truth for the team and the place that is most likely to contain any information I need from relevant colleagues such as designers and testers. Now, because the task I am going to talk about included UI elements, Jira is the place where I would find links to any designs and diagrams of any screens or flows I needed to reference in order to carry out the upcoming task.</p><p>At Babylon Health, we keep all of our designs for the app on <a href="https://zeplin.io/">Zeplin</a> and use <a href="https://miro.com/">Miro</a> for whiteboarding our UX design and screen-to-screen flows (though at the time of writing, we are currently moving towards using <a href="https://www.figma.com/">Figma</a>). The great thing about Zeplin is that Android is a first-class citizen on the platform — it allows you to specify dimensions in DP, define assets, colours, text styles and even has support for Android XML layout code.</p><p>Upon picking up a new task/story on Jira, I make sure to look clearly at the issue name, description (checking for a clearly-defined set of <a href="https://www.productplan.com/glossary/acceptance-criteria">acceptance criteria</a>) and check that all necessary attachments are present on the issue (such as designs). I also look at the issue reporter (creator) and think of any other relevant stakeholders who may be able to provide more input should I need it.</p><h3>Question Time</h3><p>Once I have checked that most of the usual information is available, I try to quickly generate as many questions as I can for myself to answer before starting the piece of work. In my experience, this helps to minimise the chance of missing or changing requirements later down the line while also forcing me to think about any possible scenarios we may have missed in the design phase. UX or behavioural questions can drastically effect the way in which I would implement certain features. It is especially important to find answers to these early (e.g. so that I know which Android components I should use to create certain behaviours).</p><p>Some examples of the design or behavioural related questions I try to ask myself are:</p><ul><li><em>What are the different states our UI can be in (such as loading, content, error)? Do we have designs for each of these? How do we transition from one state to another?</em></li><li><em>If the issue contains multiple screens, do I know exactly how to navigate from one screen to the next? What happens when we interact with the controls (such as buttons) on screen?</em></li><li><em>Does this have any overlap with or is it similar to any past work? Are there any reusable components we can utilise?</em></li></ul><p>Before I describe the next phase of my thought process, I would like to point out that at Babylon, we implement each of our screens as a RecyclerView with a <a href="https://github.com/lisawray/groupie">Groupie</a> adapter on Android project. We use our own design system which consists of a number of useful UI elements such as buttons, cards and other views. You can read more about this design system <a href="https://medium.com/babylon-engineering/android-implementation-of-a-design-system-19c3fdf50bbb">here</a> or by watching this <a href="https://www.youtube.com/watch?v=UE4YUi04RMs">talk</a> by my colleague <a href="https://twitter.com/maxmzzn">Maxime Mazzone</a>.</p><h3>What Are We Developing?</h3><p>Now that we have discussed some of the general design questions I ask myself in order to plan and implement a ticket, we will discuss some issues which were specific to the feature I was implementing. You can find a sample of the designs I was given for this ticket in <strong>Figure 1</strong> below:</p><figure><img alt="Figure 1: Original phone widget design" src="https://cdn-images-1.medium.com/max/1024/1*9epjL85mYq10-I7BrdIiag.png" /><figcaption>Figure 1: Original phone widget design (designed by <a href="https://twitter.com/daniel_spagnolo">Daniel Spagnolo</a>)</figcaption></figure><p>To give you some context, the designs in <strong>Figure 1</strong> above are for an upcoming reusable, multi-screen feature called the ‘phone widget’. This was designed so that users can enter a phone number and choose from a list of <a href="https://en.wikipedia.org/wiki/List_of_country_calling_codes">country calling code</a> prefixes (e.g. ‘+44’ for the United Kingdom), with the flag icon also representing the specified country code.</p><p>Some of the behaviour/intended UX that I knew of was:</p><ul><li>When the user taps on the country code area, this opens the country code picker screen, which has two sections. The first section displays the user’s current country code (see ‘current location’ in the above design). The second section allows them to select a new country code from a list.</li><li>The first instance of each letter of the alphabet in the country code picker list should contain a header (e.g. ‘U’ for ‘United Kingdom).</li><li>The user can click the search icon to search by country name for their chosen country.</li><li>Once the user has selected a country code, the country code picker screen is closed and the phone widget is updated with the new country flag and prefix text.</li></ul><h3>Asking the Right Questions</h3><p>So the above design looks like it would be effective — it looks like it is easy to use and communicates its intent and expectations clearly (and now that it has been implemented, I can say that it did work well — a great job by our designer <a href="https://twitter.com/daniel_spagnolo">Daniel Spagnolo</a>!). However, upon seeing the initial designs (and quickly working through the general questions from earlier in the article), I still had many questions floating around in my head and some aspects I needed clarification on. Questions are a positive thing — it ensures that everybody on the team is on the same page in terms of intended design and behaviour. Asking the right questions allows both the developer and the designer to not only meet in the middle in terms of expected functionality, but may also uncover any behaviours that either party has forgotten about early on. Here are some examples of the feature-specific questions I asked our design team:</p><blockquote><strong>Question 1</strong> — “On Android, we don’t seem to have the concept of a divider between every item in a list as seen in the designs. Should I implement it without the dividers?”</blockquote><figure><img alt="Figure 2: Original dividers on country code picker screen" src="https://cdn-images-1.medium.com/max/468/1*5n28YCFzw0WSDVq6ywU3lQ.png" /><figcaption>Figure 2: Original dividers</figcaption></figure><p>As you can see in <strong>Figure 2</strong> above, the original designs for the country code picker screen had a grey divider between every row. We then consulted our existing Android design components and reviewing the <a href="https://material.io/components/dividers/#types">Material Design guidelines on dividers</a> which state <em>“Don’t use dividers to separate individual items”</em>. As a result, we updated the original design to remove the dividers and moved on — an easy fix and now we’re all on the same page about our design language going forward.</p><blockquote><strong>Question 2</strong> — “Should the country code picker screen be a bottom sheet? As this follows convention with some other parts of the project.”</blockquote><p>The reason I asked this question was because the original design of the country code picker screen (see <strong>Figure 1</strong>) looks as though it is a full-screen activity. I had noticed that other, similar picker screens had been implemented as bottom sheets in the project. This caused some dissonance in my mind and I decided to ask the question because consistency in our app is important. Luckily I did, because the picker <em>was</em> in fact intended to be implemented as a bottom sheet (Fragment). Asking questions like these not only affect the design, but also the implementation (e.g. we are now designing our code around a BottomSheetFragment rather than an Activity) which saves even more time later on!</p><blockquote><strong>Question 3</strong> — “When the user hits the search icon, should the ‘current location’ section be hidden or kept in the list?”</blockquote><figure><img alt="Figure 3: country code picker in search state" src="https://cdn-images-1.medium.com/max/472/1*-zzyKf-CFu5-2Ftzfzvnog.png" /><figcaption>Figure 3: country code picker in search state</figcaption></figure><p>The third question was related to the behaviour of the country code picker screen when the user is searching for a country. After viewing the original design (as seen in <strong>Figure 3</strong> above), I noticed that the ‘current location’ section was missing. Now, this could easily have been a mistake or something omitted from the design. However, after speaking with the design team, I learned that the ‘current location’ section should disappear when the user clicks the ‘search’ icon (which makes a lot of sense — we want our search results to be front and centre as they are the most important thing in that moment). These are the types of UX or behavioural aspects of design that can often be missed when viewing static design images. As Google say when referencing Material Design, <em>“motion provides meaning”</em>. This sentiment can be applied to static design images because we often miss the subtleties and interactions with components (for example, how they should react and change due to some user action). In this case, it is always better to ask!</p><blockquote><strong>Question 4</strong> — “ Is the ‘current location’ section on the country code picker intended to be ‘sticky’? So if we scroll through the countries in the list, the ‘current location’ section stays visible?”</blockquote><p>To me, it wasn’t immediately clear from the designs (see <strong>Figure 1</strong>) which of the following was correct:</p><ul><li>The scrollable list of countries was supposed to be part of the same list as the ‘current location’ section (meaning that all content scrolls at once).</li><li>The scrollable list of countries was separate (and the current location should be ‘stuck’ to the top of the screen while the countries scrolled independently).</li></ul><p>While this wouldn’t influence the implementation time too much, it is still good to iron out these details before starting to code. It turned out that the ‘current location’ section would not be sticky and that everything would be in the same list. This made the implementation even quicker as each section is just another Groupie section in the adapter.</p><blockquote><strong>Question 5</strong> — “Do we have any existing components for this pattern of showing a capital letter header for the first instance of each letter in the alphabet? I’m not sure if this pattern is already used somewhere in the app.”</blockquote><p>In <strong>Figure 1</strong>, you can see how we use a header for the first instance of each letter of the alphabet (the ‘U’ next to the ‘United Kingdom’). I had a feeling I’d seen this pattern once before in the app but couldn’t picture where I’d seen it. After some discussion with the team on Slack, I found that it was used once on one of the registration screens, albeit in a slightly different form (the previous version used sticky headers, whereas my version would not be sticky and scroll off screen with the rest of the row). Due to this difference in functionality, I would need to plan how to implement this as part of our existing design system using Groupie Item rows.</p><p>In this case, while it was good to find out where the pattern was used previously, asking this question didn’t really help us with our implementation due to the difference in behaviour. That is just the nature of asking these questions — some of them will turn out to be incredibly useful while others may lead to a dead end. Yet they will all still result in some intangible benefits such as increased knowledge of the codebase and shared knowledge across the team. One lesson we can take away from this question is that if you’re in doubt, just ask your team — there is bound to be somebody with a more historical view of the codebase than yourself and somebody who can likely point you in the right direction.</p><h3>Conclusion</h3><p>In this article, we have discussed some of the ways in which asking questions can help your thought process when approaching the development of a feature while learning about some of the tools we use here at Babylon Health to help us with that journey.</p><p>While we have described a number of considerations we need to process, don’t feel overwhelmed as you can imagine how most of the decisions and questions stated in the article happen almost instantaneously in your mind once you gain an understanding of the feature you are implementing. There is also such a thing as asking <em>too many</em> questions — <a href="https://en.wikipedia.org/wiki/Analysis_paralysis">analysis paralysis</a> is a real issue and can massively stall your progress if you’re not careful, so it is important to be thorough but efficient when working through this part of your process. Plan without overthinking everything.</p><p>Another thing to remember is that every piece of work is different. While the ideas in this article provide an effective framework for thinking about starting your work, there is no need to stick to it rigidly. Adapt and use parts of it accordingly depending on what you are implementing — just remember: always ask questions if you are unsure of anything.</p><p>In the next article, we will continue planning our implementation by taking the ideas and questions from above and start to translate them into a technical solution, so stay tuned!</p><p><em>At Babylon we believe it’s possible to put an accessible and affordable health service in the hands of every person on earth. The technology we use is at the heart and soul of that mission. Babylon is a Healthcare Platform, currently providing online consultations via in-app video and phone calls, AI-assisted Triage and Predictive Health Assistance.</em></p><p><em>If you are interested in helping us build the future of healthcare, please find our open roles </em><a href="https://jobs.lever.co/babylonhealth?lever-via=tczkkcpY3l"><em>here</em></a><em>.</em></p><p>Follow Babylon Engineering on Twitter <a href="https://twitter.com/babylon_eng">@Babylon_Eng</a> and the author of this article <a href="https://twitter.com/darrenatherton">@DarrenAtherton</a>.</p><figure><img alt="Babylon Engineering logo" src="https://cdn-images-1.medium.com/max/303/1*U30VdyTHVTBeTEK75mGLMw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1b68521350c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/babylon-engineering/android-feature-development-at-babylon-health-part-1-thinking-about-the-problem-d1b68521350c">Android Feature Development at Babylon Health — Part 1: Thinking About the Problem</a> was originally published in <a href="https://medium.com/babylon-engineering">Babylon Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intro to Data Classes in Kotlin]]></title>
            <link>https://medium.com/@DarrenAtherton/intro-to-data-classes-in-kotlin-7f956d54365c?source=rss-b5cff2d71679------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f956d54365c</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Darren Atherton]]></dc:creator>
            <pubDate>Thu, 03 Nov 2016 23:10:09 GMT</pubDate>
            <atom:updated>2016-11-04T10:10:43.937Z</atom:updated>
            <content:encoded><![CDATA[<h4>Eliminate boilerplate and and easily destructure data.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yqao-3WILjEfZRi9LNUmow.jpeg" /></figure><h4>Tired of writing (or generating) lengthy, boilerplate code for objects which do nothing but store data?</h4><p>Well, <a href="https://kotlinlang.org/">Kotlin</a> has the solution for you!</p><p>Almost every software project we create has a number of classes which exist solely to store data/state but have almost no actual functionality in terms of operations. In more complex apps, this number can be rather high (applications which feature a <a href="http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/"><strong>clean architecture</strong></a> approach often have 2–3 times as many due to a separation of entities between layers).</p><p>These generally contain the same concepts every time:</p><ul><li>A constructor</li><li>Fields to store data</li><li>Getter and setter functions</li><li>hashCode(), equals() and toString() functions</li></ul><h3>Example — Storing Video Game Data</h3><p>If we wanted to store some data about a video game in Java, we would usually create a class similar to this:</p><pre>public class VideoGame {<br><br>    private String name;<br>    private String publisher;<br>    private int reviewScore;<br><br>    public VideoGame(String name, String publisher, int reviewScore) {<br>        this.name = name;<br>        this.publisher = publisher;<br>        this.reviewScore = reviewScore;<br>    }<br><br>    public String getName() {<br>        return name;<br>    }<br><br>    public void setName(String name) {<br>        this.name = name;<br>    }<br><br>    public String getPublisher() {<br>        return publisher;<br>    }<br><br>    public void setPublisher(String publisher) {<br>        this.publisher = publisher;<br>    }<br><br>    public int getReviewScore() {<br>        return reviewScore;<br>    }<br><br>    public void setReviewScore(int reviewScore) {<br>        this.reviewScore = reviewScore;<br>    }<br><br>    @Override<br>    public boolean equals(Object o) {<br>        if (this == o) return true;<br>        if (o == null || getClass() != o.getClass()) return false;<br><br>        VideoGame that = (VideoGame) o;<br><br>        if (reviewScore != that.reviewScore)<br>            return false;<br>        if (name != null ? !name.equals(that.name) :<br>                that.name != null) {<br>            return false;<br>        }<br>        return publisher != null ?<br>                publisher.equals(that.publisher) :<br>                that.publisher == null;<br><br>    }<br><br>    @Override<br>    public int hashCode() {<br>        int result = name != null ? name.hashCode() : 0;<br>        result = 31 * result + (publisher != null ?<br>                publisher.hashCode() : 0);<br>        result = 31 * result + reviewScore;<br>        return result;<br>    }<br><br>    @Override<br>    public String toString() {<br>        return &quot;VideoGame{&quot; +<br>                &quot;name=&#39;&quot; + name + &#39;\&#39;&#39; +<br>                &quot;, publisher=&#39;&quot; + publisher + &#39;\&#39;&#39; +<br>                &quot;, reviewScore=&quot; + reviewScore +<br>                &#39;}&#39;;<br>    }<br>}</pre><p>That’s a lot of code just to store 3 fields of data for a video game!</p><h3>Data Classes in Kotlin</h3><p>Fortunately for us, the above code is no longer necessary in Kotlin due to the useful <a href="https://kotlinlang.org/docs/reference/data-classes.html">data class</a> concept provided by the language. A data class is a class in Kotlin created to encapsulate all of the above functionality in a succinct manner.</p><p>To recreate the <strong>VideoGame</strong> class in Kotlin, we can simply write:</p><pre>data class VideoGame(val name: String, val publisher: String, var reviewScore: Int)</pre><p>Much better!</p><p>When we specify the <strong>data </strong>keyword in our class definition, Kotlin automatically generates field accessors, hashCode(), equals(), toString(), as well as the useful copy() and componentN() functions (more on these later).</p><p>Any of the functions above which are manually defined by us in the class will not be generated.</p><h4>Creating an Instance of a Data Class</h4><p>Data classes are instantiated in the same manner as a standard class:</p><pre>val game: VideoGame = VideoGame(&quot;Gears of War&quot;, &quot;Epic Games&quot;, 8)</pre><p>We can now access the members of <em>game:</em></p><pre><em>print</em>(game.name) // &quot;Gears of War&quot;<br><em>print</em>(game.publisher) // &quot;Epic Games&quot;<br><em>print</em>(game.reviewScore) // 8<br>game.reviewScore = 7</pre><p>and print the contents of the class:</p><pre>print(game.toString())<br>// prints <br>// &quot;Game(name=Gears Of War, publisher=Epic Games, reviewScore=7)&quot;</pre><h4>Visibility Modifiers</h4><p>We can control the visibility modifiers of the getters/setters generated by providing them in the constructor:</p><pre>data class VideoGame(private val name: String, val publisher: String, private var reviewScore: Int</pre><h4>Read-Only Fields</h4><p>If we only wish to expose getters and not setters, we just provide <strong>val</strong> instead of <strong>var</strong> for each field (<strong>val</strong> properties are Kotlin’s equivalent of <strong>final</strong> in Java). In the below example, <em>name</em> and <em>reviewScore</em> have read/write access, while publisher is read-only<em>:</em></p><pre>data class VideoGame(var name: String, val publisher: String, private var reviewScore: Int</pre><h4>copy() Function</h4><p>Since our data classes are <strong>immutable</strong>, we must create a copy if we wish to change some data. We are also able to specify if we only wish to change specific attributes for the new copy. For example, if we wish to change the review score of a game, this can be done by writing:</p><pre>val game: VideoGame = VideoGame(&quot;Gears of War&quot;, &quot;Epic Games&quot;, 8)</pre><pre>val betterGame = game.copy(reviewScore = 10)</pre><h4>Destructuring Declarations</h4><p>This is the name of the syntax provided by Kotlin which allows us to map an object into individual fields. This is where the componentN() functions stated above come into play.</p><p>For each property we specify for our data class (in our video game example we have 3), Kotlin will generate a componentN() function which maps to that property, where ’N’ represents the properties order in the definition. So in our case, we have the following:</p><pre>game.component1() // name<br>game.component2() // publisher<br>game.component3() // reviewScore</pre><p>These generated functions allow us to use destructuring declarations to do some cool things:</p><p>We can destructure an object to create three <strong>val</strong> properties at once:</p><pre>val game: VideoGame = VideoGame(&quot;Gears of War&quot;, &quot;Epic Games&quot;, 8)</pre><pre>val (theName, thePublisher, theReviewScore) = game</pre><pre>// val theName == &quot;Gears of War&quot;<br>// val thePublisher == &quot;Epic Games&quot;<br>// val theReviewScore == 8</pre><p>We can also destructure data directly from a function:</p><pre>// function which returns a new video game<br>fun getNamePublisherAndReviewScore() = VideoGame(&quot;Street Fighter&quot;, &quot;Capcom&quot;, 10)</pre><pre>val (anotherName, anotherYear, anotherReviewScore) = <em>getNamePublisherAndReviewScore</em>()</pre><pre>// anotherName == &quot;Street Fighter&quot;<br>// anotherYear == &quot;Capcom&quot;<br>// anotherReviewScore == 10</pre><p>In fact, destructuring declarations can be used in most cases where the right hand side of the declaration can be broken down into <em>componentN()</em> functions.</p><p>We can destructure data directly inside a loop through maps/collections:</p><pre>val listOfGame: List&lt;VideoGame&gt; = <em>listOf</em>(game, betterGame)</pre><pre>for ((gameName, gamePublisher, gameScore) in listOfGame) {</pre><pre>    <em>print</em>(gameName) // print the gameName<br>    // do something else with the gamePublisher<br>    // share the gameScore<br>}</pre><p>This is very useful when dealing with key/value stores (from the Kotlin documentation):</p><pre>for ((key, value) in map) {<br>    // do something with the key and the value<br>}</pre><h4>Some Built-in Data Classes</h4><p>Kotlin also has the built-in data classes <em>Pair</em> and <em>Triple</em> for common operations:</p><pre>val pair: Pair&lt;Int, String&gt; = Pair(10, &quot;Ten&quot;)<br>val triple: Triple&lt;Int, String, Boolean&gt; = Triple(1, &quot;One&quot;, true)</pre><p>Although as the docs state, in most cases it is usually better to create your own data class (even if it has 2 or 3 attributes) which has a more descriptive/relevant name for your use case.</p><h4>Rules for Creating Data Classes</h4><p>The <a href="https://kotlinlang.org/docs/reference/data-classes.html">Kotlin documentation on data classes</a> notes that there are some basic restrictions in order to maintain consistency/behaviour of generated code:</p><ul><li><em>The primary constructor needs to have at least one parameter;</em></li><li><em>All primary constructor parameters need to be marked as </em><em>val or </em><em>var;</em></li><li><em>Data classes cannot be abstract, open, sealed or inner;</em></li><li><em>Data classes may not extend other classes (but may implement interfaces).</em></li></ul><h3>Conclusion</h3><p>Like most other aspects of Kotlin, data classes aim to reduce the amount of boilerplate code you write in your project (and do so to great effect!).</p><p>To learn more, please visit the <a href="https://kotlinlang.org/docs/reference/data-classes.html">Data Classes</a> and <a href="https://kotlinlang.org/docs/reference/multi-declarations.html">Destructuring Declarations</a> pages in the official Kotlin Documentation.</p><p>If you are an Android developer like myself or even just interested in Kotlin, please feel free to get in touch via Twitter:</p><p><a href="https://twitter.com/DarrenAtherton">https://twitter.com/DarrenAtherton</a></p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f956d54365c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>