<?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 Vincent Nyanga on Medium]]></title>
        <description><![CDATA[Stories by Vincent Nyanga on Medium]]></description>
        <link>https://medium.com/@vince.nyanga?source=rss-6351e3ede1db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HEDF9GJY3hW3LgeI.</url>
            <title>Stories by Vincent Nyanga on Medium</title>
            <link>https://medium.com/@vince.nyanga?source=rss-6351e3ede1db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 04:02:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vince.nyanga/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[Mocking objects in Python]]></title>
            <link>https://medium.com/vinarah/mocking-objects-in-python-fc1e75c3612a?source=rss-6351e3ede1db------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc1e75c3612a</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Vincent Nyanga]]></dc:creator>
            <pubDate>Tue, 24 Apr 2018 07:02:32 GMT</pubDate>
            <atom:updated>2018-04-24T07:02:32.894Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the past 18 months I have been doing a lot of Python programming in my side projects as well as at work. In all my projects I always find myself needing to mock certain objects to ensure that my tests are independent of external frameworks or APIs —something that is almost unavoidable.</p><h4>Enter the Mock library</h4><p>Since I come from an Android background, mocking objects has been part of my development life with <em>Mockito </em>the go-to library. When I started serious Python development (self-taught) I wanted something similar to <em>Mockito </em>where I could replace certain parts of my system with mock objects during tests and I found it in the <a href="https://docs.python.org/3/library/unittest.mock.html"><em>mock </em></a>library. In this post I will talk about how I have used this library in my projects.</p><h4>What does it do?</h4><p>The <em>mock </em>library is used to replace parts of a system under test with mock objects and make asserts on how they are used. It helps avoid creating stubs in your test suite — something that can be a pain and time consuming. With this library you can make assertions about which methods were called and the attributes that they were called with. You can also specify the return values or exceptions to be thrown by certain actions.</p><p>This library is available in the Python 3 standard library in the <em>unittest </em>module. If you’re using Python 2 you need to install it by running the following command.</p><pre>pip install mock</pre><p>For more in-depth information about this library please read the <a href="https://docs.python.org/3/library/unittest.mock.html">docs</a>.</p><h4>Let’s look at an example</h4><p>In this example I will use a simple class that takes in an image and uses an external API to find matching faces in the image. Here is the class that we will be using in our examples:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ba8e2423fb0e1755380e5f648fa0d4c/href">https://medium.com/media/3ba8e2423fb0e1755380e5f648fa0d4c/href</a></iframe><p>When testing this class we will need to replace the <em>api </em>and <em>response_gateway </em>with mock objects so that we test the class independent of any external entities. Let’s see how the <em>mock </em>library can be used.</p><h4>Making assertions on method calls</h4><p>The <em>process_request </em>method makes calls to the <em>api </em>as well as the <em>response_gateway</em>. We need to ensure that these calls are made, and with the correct arguments. Here is how we can do it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a2b3037c3ff45e85445fa440be7e50e/href">https://medium.com/media/3a2b3037c3ff45e85445fa440be7e50e/href</a></iframe><p>In the example above we have used the mock library to assert that the method <em>find_matching_faces()</em> in our mock <em>api </em>was called once with the correct arguments. We also asserted that <em>handle_response()</em> was called in the mock <em>response_gateway</em>.</p><h4>Setting return value</h4><p>Sometimes you need to test a return value for a method inside your mock object. Here is how it can be done:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89cd4ba2c277b11b7d6cd3c4324c4da1/href">https://medium.com/media/89cd4ba2c277b11b7d6cd3c4324c4da1/href</a></iframe><p>In the above example we have set the return value for the method <em>find_matching_faces </em>and made assertions to check if we get the desired response.</p><h4>Raising exceptions</h4><p>Sometimes you may want to test how your system handles exceptions. With the <em>mock </em>library you can configure the method under test to raise an exception as shown in the example below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7590593aa22ccd184f7694f2284c49c2/href">https://medium.com/media/7590593aa22ccd184f7694f2284c49c2/href</a></iframe><p>Now the <em>find_matching_faces()</em> method in our mock object will raise an exception.</p><h4>Mocking methods</h4><p>In the examples above we have been mocking entire objects. What if we would like to use a real object but just mock a certain method inside that object? This can be useful if you want to test certain logic inside your class except for certain components. The <em>mock </em>library makes this possible through the <em>patch </em>decorator/context manager. This replaces the object or method specified with a mock or another object during the test and restores it when the test is done. Below is an example of how that can be done.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ee338a8f2dc4b2f7332b9c94fb7b2a7/href">https://medium.com/media/1ee338a8f2dc4b2f7332b9c94fb7b2a7/href</a></iframe><p>In the example above we have mocked out the <em>process_request()</em> method inside <em>SearchFacesInteractor </em>and set its return object. We can also make the method raise an exception by setting the <em>side_effect.</em></p><h3>Conclusion</h3><p>In this post I spoke about how the <em>mock </em>library can be used to mock objects and methods during tests. There is so much more one can do with this library. Check out the documentation for more. As a self-taught Python programmer, my code may not be well written. Please bear with me :).</p><p>Once again, thanks a million times for taking time to read.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc1e75c3612a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vinarah/mocking-objects-in-python-fc1e75c3612a">Mocking objects in Python</a> was originally published in <a href="https://medium.com/vinarah">vinarah</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Architecture Example C#]]></title>
            <link>https://medium.com/vinarah/clean-architecture-example-c-5990bd4ac8?source=rss-6351e3ede1db------2</link>
            <guid isPermaLink="false">https://medium.com/p/5990bd4ac8</guid>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Vincent Nyanga]]></dc:creator>
            <pubDate>Tue, 10 Apr 2018 06:45:24 GMT</pubDate>
            <atom:updated>2018-04-10T06:45:24.740Z</atom:updated>
            <content:encoded><![CDATA[<p>When I was still in university I failed a job interview because I did not know the architecture I was using in my project (embarrassing). Since that day I decided to learn about different software architectures and use them in all my projects.</p><p>Uncle Bob’s <a href="https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html">clean architecture</a> is one of the architectures that I’ve come across and I fell in love with it. The reason why I like it is that it helps create software that is testable, independent of frameworks, UI or databases. It also enforces a rule that source code dependencies point inwards (see image below). This means that something in the inner layer cannot know about something in the outer layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*B7LkQDyDqLN3rRSrNYkETA.jpeg" /><figcaption>Clean Architecture, Courtesy: Uncle Bob</figcaption></figure><p>For detailed explanation of the clean architecture check out this <a href="https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html">post</a> by Uncle Bob.</p><h3>Let’s build something</h3><p>We are going to create a simple .Net console application that shows the weather of a given location. The complete source code is available on <a href="https://github.com/vince-nyanga/CleanArchitectureExample">GitHub</a>.</p><p>The application has three layers — domain, data and presentation layers. The image below shows how the layers depend on each other. A layer can only know about a layer below it as shown by the arrows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*E_cnDk6Pdiz5-OjD3nuGPQ.png" /><figcaption>The three layers used in the weather app.</figcaption></figure><h4>Domain Layer</h4><p>This is the bottom layer in our application. It contains the entities, use cases and interfaces. Code in this layer is as abstract and generic as possible. I simply defines how the application should work. More ‘meat’ will be added in layers above.</p><h4>Entities</h4><p>These are the blocks that build our application and are not affected by any external forces, that is, external changes won’t change them. In our weather app we only have one entity — WeatherEntity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef0dc587674c85cdd80c10252a4b3bf3/href">https://medium.com/media/ef0dc587674c85cdd80c10252a4b3bf3/href</a></iframe><h4>Use cases</h4><p>These are application specific business rules. Each use case (aka interactor) implements a single business use case in our system, for instance, get weather for a location. In the weather application all use cases implement a base interface IRequestHandler</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bcf67836aecf6dac16d581f5639c54da/href">https://medium.com/media/bcf67836aecf6dac16d581f5639c54da/href</a></iframe><p>Now we create out use case that gets the weather for a given location.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95c6a4196157b2fef12ca9b0b7f2c8e3/href">https://medium.com/media/95c6a4196157b2fef12ca9b0b7f2c8e3/href</a></iframe><h4>Interfaces</h4><p>The interfaces in our domain layer include the repository from which our application data will be loaded. It’s just a simple interface with one method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af6da45354501c8e9999b5ef98b8d320/href">https://medium.com/media/af6da45354501c8e9999b5ef98b8d320/href</a></iframe><p>The use of an interface ensures that our code is testable and also that our domain layer is independent of any implementation of the repository. The code extract below shows how handy interfaces are when writing tests.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/537599a168dad6c9f2c76fdbff118122/href">https://medium.com/media/537599a168dad6c9f2c76fdbff118122/href</a></iframe><h4>Data layer</h4><p>This layer is responsible for handling our application data. It contains implementations of the data interfaces defined in the domain layer. The data layer may also have entities specific to it as determined by the data providers used as seen in this example. Let’s create the implementation of our repository.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f089f37275f09b3b59d302d4b82e7d3c/href">https://medium.com/media/f089f37275f09b3b59d302d4b82e7d3c/href</a></iframe><h4>Mappers</h4><p>You may have noticed that our weather repository takes in an IMapper interface. This is a simple interface that maps one object to another. The reason behind the use of this interface is that the data we get in the data layer may not look anything close to the entities defined in the domain layer. This then means we will have to convert the data we get into our domain entities. In our case we get our weather data from <a href="https://openweathermap.org/">openweathermap</a> and it comes back as a completely different object from our domain entity hence the need for a mapper.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abfc514e42e39ba00fa83c2bf3cf0278/href">https://medium.com/media/abfc514e42e39ba00fa83c2bf3cf0278/href</a></iframe><h4>Presentation layer</h4><p>This is the upper most layer in out application. It is responsible wiring everything together as well as interact with the user. In this layer we initialize and hook up all the objects. We will use dependency injection using NInject. Note this layer may have an architecture of its own (MVP, MVC, MVVM etc.). Since everything is decoupled the presentation layer can be a mobile app, web app or anything really without us changing anything in the layers below it. In this case it is a simple console application.</p><p>Let’s create a module for our dependency injection.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01d4d8ce938563157e37a39ee1e10edb/href">https://medium.com/media/01d4d8ce938563157e37a39ee1e10edb/href</a></iframe><p>Let’s get the weather :)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf3e2834ccd5c982b0c855ccfecea498/href">https://medium.com/media/cf3e2834ccd5c982b0c855ccfecea498/href</a></iframe><h3>Summary</h3><p>In this post we have created a simple console application that gets the weather for a given city using The Clean Architecture. This architecture has many advantages including building software that is testable and independent of frameworks.</p><p>The complete source code is available on <a href="https://github.com/vince-nyanga/CleanArchitectureExample">GitHub</a>. Once again, thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5990bd4ac8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vinarah/clean-architecture-example-c-5990bd4ac8">Clean Architecture Example C#</a> was originally published in <a href="https://medium.com/vinarah">vinarah</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Firestore By Example]]></title>
            <link>https://medium.com/vinarah/cloud-firestore-by-example-f87a1608b6a2?source=rss-6351e3ede1db------2</link>
            <guid isPermaLink="false">https://medium.com/p/f87a1608b6a2</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[cloud-firestore]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vincent Nyanga]]></dc:creator>
            <pubDate>Wed, 04 Oct 2017 12:04:11 GMT</pubDate>
            <atom:updated>2018-04-04T07:50:41.659Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>Firebase has released a NoSQL database called <strong>Cloud Firestore</strong>. This is a flexible, scalable database for mobile, web and server development that has many capabilities which include, among others:</p><ul><li><strong><em>Flexibility</em></strong>: the database supports storage of flexible, hierarchical data structures. Data is stored in documents that are organised in collections. A document can also contain sub-collections.</li><li><strong><em>Expressive querying</em></strong>: <strong>Cloud Firestore </strong>supports multiple, chained filters and also a combination of filtering and sorting — something that is hard to do with the Realtime database.</li></ul><p>Other features include real-time updates, offline support and ability to scale. For detailed information about the database visit the <a href="https://firebase.google.com/docs/firestore/">Firebase website</a>.</p><h4>Example</h4><p>We are going to create a simple Todo list app (I love todo lists :) ) that stores data in the <strong>Cloud Firestore </strong>database. The app allows a user to add, update, delete as well as view a list of tasks. The end product should look like this:</p><figure><img alt="ezgif.com-video-to-gif (1)" src="https://cdn-images-1.medium.com/max/600/0*fKRZciaO2Y9Pd2tT.gif" /></figure><p>I will assume that you have knowledge of creating an Android project as well as connecting it to a Firebase project. In this post I will add code snippets that are related to <strong>Cloud Firestore</strong>. If you want the complete project check it out on my <a href="https://github.com/vince-nyanga/cloud-firestore-sample">github</a>.</p><p>After you have created your project and connected it to a Firebase project add the Cloud Firestore sdk to your build.gradle file:</p><pre>implementation &quot;com.google.firebase:firebase-firestore:11.4.0&quot;</pre><h4>Repository class</h4><p>Let’s create a class FirestoreRepository.kt in which we will implement our CRUD operations on the <strong>Cloud Firestore</strong> database.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dee3f1908ad0817ffad0dacb72069d5/href">https://medium.com/media/4dee3f1908ad0817ffad0dacb72069d5/href</a></iframe><h4>ViewModel</h4><p>Let’s create a View Model MainViewModel.kt that will our UI will use to interact with the repository class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e808f662310505ee77379ffc1be4ada/href">https://medium.com/media/2e808f662310505ee77379ffc1be4ada/href</a></iframe><h4>MainActivity</h4><p>Let’s add the following code to our MainActivity.kt and wire everything together:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb1bf430ed08bac18fa39fe85591e142/href">https://medium.com/media/bb1bf430ed08bac18fa39fe85591e142/href</a></iframe><h4>Conclusion</h4><p>In this post I created a simple Todo list app that makes use of Firebase’s new <strong>Cloud Firestore </strong>database to demonstrate how you can add, read, update and delete data to the database. Check out the complete project on <a href="https://github.com/vince-nyanga/cloud-firestore-sample">github</a>. Once again thanks for taking your time to read this post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f87a1608b6a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vinarah/cloud-firestore-by-example-f87a1608b6a2">Cloud Firestore By Example</a> was originally published in <a href="https://medium.com/vinarah">vinarah</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A look into the AAC Paging Library]]></title>
            <link>https://medium.com/vinarah/a-look-into-the-aac-paging-library-f0127e89415d?source=rss-6351e3ede1db------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0127e89415d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[architecture-components]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Vincent Nyanga]]></dc:creator>
            <pubDate>Mon, 18 Sep 2017 22:19:16 GMT</pubDate>
            <atom:updated>2018-04-04T08:07:21.228Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>Imagine you have data set that contains 10 000 items that you need to display in your application. Loading all these items before rendering them on the screen may take time affecting both performance and user experience. Thanks to the <strong>Paging Library </strong>this problem can now be avoided.</p><h4>What does the Paging library do?</h4><p>The paging library enables the application to gradually load information from a data source without straining the device or waiting for a long time for all the data to be loaded. Information is load in small portions (pages) at a time.</p><h4>What does it consist of?</h4><p>The library consists of a couple of the following classes among others:</p><h4><strong>DataSource</strong></h4><p>This class is used to define a data source you need to pull paged data from. I has the following subclasses one of which you need to extend depending on how you need to access your data:</p><ul><li><strong>KeyedDataSource</strong> is used if you need to use data from item N to fetch item N+1.</li><li><strong>TiledDataSource</strong> is used if you need to fetch pages of data from any location in your data store, for instance getting 50 items starting from location 20.</li></ul><p>The Room persistence library can create the DataSource class automatically as shown in the example below.</p><p><strong>PagedList</strong></p><p>This is the class that loads from a DataSource and you can configure how much data is loaded at a time and how much should be prefetched:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e5092096052e4499ffa6e05d737fe47/href">https://medium.com/media/1e5092096052e4499ffa6e05d737fe47/href</a></iframe><p><strong>PagedListAdapter</strong></p><p>This class implements the RecyclerView.Adapter and is used to present data from a PagedList . When a new page of data is loaded, it signals the RecyclerView that new data has arrived and the RecyclerView deals with the data accordingly. It uses a background thread to compute changes from one PagedList to the next using DiffUtil.</p><p>LivePagedListProvider</p><p>This class generates LiveData&lt;PagedList&gt; from the DataSource . Again, the Room persistence library can generate it for you:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ea644b8743bbc073ecf7bfc6d931ca4/href">https://medium.com/media/2ea644b8743bbc073ecf7bfc6d931ca4/href</a></iframe><p>Let’s create a simple app that displays a list of users using the Paging library. Check out the project on <a href="https://github.com/vince-nyanga/paging-library-example">github </a>if you want to see the whole project.</p><h4>Add dependencies</h4><p>Add the following dependencies to your app build.gradle file:</p><pre><br>implementation “com.android.support:appcompat-v7:26.1.0”<br>implementation “android.arch.persistence.room:runtime:1.0.0-alpha9–1”<br>implementation “android.arch.lifecycle:runtime:1.0.0-alpha9–1”<br>implementation “android.arch.lifecycle:extensions:1.0.0-alpha9–1”<br>implementation “android.arch.paging:runtime:$paging_version”<br>kapt “android.arch.persistence.room:compiler:1.0.0-alpha9–1”<br></pre><h4>Create the Entity</h4><p>Let’s create our User entity:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b54cde6f24128ce017c437be9c9991a7/href">https://medium.com/media/b54cde6f24128ce017c437be9c9991a7/href</a></iframe><p><strong>UserDao</strong></p><p>Let’s a data access object for our user entity:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e067ef7ada3d4c8f7daa5fa31b7186/href">https://medium.com/media/25e067ef7ada3d4c8f7daa5fa31b7186/href</a></iframe><p>As you can see our getUsers() function returns LivePagedListProvider. This class generates a LiveData&amp;lt;PagedList&amp;gt; as explained above.</p><h4>Create the User adapter</h4><p>Let’s create a PagedListAdapter that we will use to load our PagedList into the RecyclerView. Note the DiffCallback that will be used to compute changes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/634ceefdf6cbdfa031fed5e9ce971693/href">https://medium.com/media/634ceefdf6cbdfa031fed5e9ce971693/href</a></iframe><h4>Create the ViewModel</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88da5d23b76297331614c3d05545890f/href">https://medium.com/media/88da5d23b76297331614c3d05545890f/href</a></iframe><p>In our MainActivity we will subscribe to the user list:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c44c70e9d5c897883176432cffb2e696/href">https://medium.com/media/c44c70e9d5c897883176432cffb2e696/href</a></iframe><h4>Page Size</h4><p>When creating a PagedList you need to set the page size. What size should you use? After playing around the page size in the sample app I found out that if the page size does not fill at least a screen worth of content, say 2, for a brief moment I would see the first two items followed by nulls. So the page size should be a value that fills at least screen worth of content on a large device to avoid the user seeing null items.</p><h4>Placeholders</h4><p>If you enable placeholders in your PagedList it will report the full size of the list with some items as nulls depending on your page size.</p><h4>Conclusion</h4><p>In this post I took a look at the Paging Library, the classes that make up the library and a sample app that uses the library. Once again thanks for taking your time to read.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0127e89415d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vinarah/a-look-into-the-aac-paging-library-f0127e89415d">A look into the AAC Paging Library</a> was originally published in <a href="https://medium.com/vinarah">vinarah</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Instant Apps — Theory]]></title>
            <link>https://medium.com/vinarah/android-instant-apps-theory-1185f7343d08?source=rss-6351e3ede1db------2</link>
            <guid isPermaLink="false">https://medium.com/p/1185f7343d08</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vincent Nyanga]]></dc:creator>
            <pubDate>Fri, 07 Jul 2017 13:41:29 GMT</pubDate>
            <atom:updated>2018-04-04T07:29:14.168Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>As you may know Android Instant Apps are now open to all developers. This is the news people like me have been waiting for for a very long time. In this post I am going to talk about the theory behind Android Instant Apps as I understand it.</p><h4>What is an Android Instant App?</h4><p>An Android Instant App is an application that can run on a device without the user having to install it first. It is launched in response to a user launching a URL. What basically happens is that the user launches a URL and instead of the phone opening the URL in a browser, a native Android app is launched and the user can use it enjoying all the features of a native app. For instance, a user opens a link <a href="https://my-mock-re-app/practice."><em>https://my-mock-re-app/practice.</em></a><em> </em>If there is an Instant App on the app store for that URL and the user’s device supports Instant Apps then the Instant App is launched and the user can start a practice session. This has the following advantages, among others:</p><ul><li>Users can have a look at the features of an app before they make a decision to install it.</li><li>Users can share stuff from the app with their friends and they (friends) can enjoy the same experience without the need to have the app installed on their device. For example a user of <a href="https://play.google.com/store/apps/details?id=me.vincenyanga.regulatoryexam">Regulatory Exam Practice</a> wants their friend to take a quick practice session. They will just send the friend a URL that matches an instant app and when the friend launches the URL a native app will be launched where they can have a practice session.</li></ul><p>Android Instant Apps provides users with a great experience.</p><h4>What happens under the hood?</h4><p>So what happens when a user launches a URL on their device? When the user launches a URL Google Play checks to see if there is an instant app matching that URL. If there is an instant app matching Google Play then sends the necessary code files to the device so the device can run the app. The flow chart below shows the process as I understand it.</p><figure><img alt="flowchart" src="https://cdn-images-1.medium.com/max/742/0*pFX7ha0EYAb1KS-o.png" /></figure><h4>Features as building blocks</h4><p>An Instant App is a made up of <strong>features</strong>. A feature is module that applies <strong>com.android.feature </strong>and behaves differently in different circumstances:</p><ul><li>When it’s consumed by a normal application (<strong>com.android.application</strong>) during the build process, it produces an aar file and works just like any other library.</li><li>When it’s consumed by an Instant App it generates an Instant app APK.</li></ul><p>For instance, a map app can allow users to navigate, search for nearby points of interest or share current location. All these actions are features that make up the app. Now let’s say, for example, the user launches this URL: <a href="https://instant-app.com/navigate/">https://instant-app.com/navigate/.</a> The navigation feature is sent to the device and the user will start navigating to their destination. The same applies for <a href="https://instant-app.com/search/">https://instant-app.com/search/</a> and <a href="https://instant-app.com/share/">https://instant-app.com/share/.</a></p><h4>Base Feature</h4><p>Each Instant App <strong>must </strong>have <strong>one </strong>(and only one) base feature. This feature is sent to the device with the feature requested by the user. It should contain all the shared resources and code that all the other features use like styles. In our map app example, the Instant app will consist of four features — <em>base-feature</em>, <em>navigation-feature</em>, <em>search-feature</em> and <em>share-feature. </em>So when the user requests the navigation feature APK two feature APKs are sent; the base feature and the navigation feature.</p><h4>What else to know about features</h4><p>The following are what developers need to know when they create features for their apps:</p><ul><li>A feature APK should be less than 4MB so you should make them as small as possible</li><li>A feature should have at least one Activity</li><li>An Activity in a feature cannot launch another Activity. Instead it has to request a URL corresponding to that Activity</li><li>Instant App cannot launch Activity in another feature. The same process as above has to be taken</li></ul><h4>Summary</h4><p>In this post I spoke about Android Instant Apps — what they are as well as how they work. In the next post we are gonna convert an existing app to an Instant App and maybe create one from scratch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1185f7343d08" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vinarah/android-instant-apps-theory-1185f7343d08">Android Instant Apps — Theory</a> was originally published in <a href="https://medium.com/vinarah">vinarah</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>