<?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 VasanthaKumar on Medium]]></title>
        <description><![CDATA[Stories by VasanthaKumar on Medium]]></description>
        <link>https://medium.com/@apvasanth03?source=rss-ffd441160683------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qfnOXLP9XhOHkAZl3HIcjA.jpeg</url>
            <title>Stories by VasanthaKumar on Medium</title>
            <link>https://medium.com/@apvasanth03?source=rss-ffd441160683------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:06:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@apvasanth03/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 API Layer Abstraction]]></title>
            <link>https://medium.com/@apvasanth03/android-api-layer-abstraction-53510c7f743d?source=rss-ffd441160683------2</link>
            <guid isPermaLink="false">https://medium.com/p/53510c7f743d</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[VasanthaKumar]]></dc:creator>
            <pubDate>Sun, 13 Nov 2016 19:27:14 GMT</pubDate>
            <atom:updated>2016-11-13T19:31:27.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*miU5lE9RHzimcVsNwiZCxQ.jpeg" /><figcaption>Android API Layer Abstraction</figcaption></figure><h3><strong>Abstraction</strong></h3><p>In software programming, it is always good practice to abstract all our third party dependencies.</p><p>Here the abstraction means, whenever we are going for any third party library it is always good practice to define the abstraction (interface), then implement it using third party library.</p><p>Inside our application always refer using abstraction (interface) and not using implementation.</p><p>Advantage is that, in future if we decide to change our third party library, we can easily write a new implementation for our defined abstraction. Hence inside our application only change we need to make is to instantiate the new implementation and assign it to our abstraction.</p><p>That’s it, we don’t need to make any more changes to our application, hence it is always good practice to abstract any third party dependencies.</p><h3>API Layer Abstraction</h3><p>In Android almost all the application will perform networking (api calls), for networking in android we have lot of good default and third party libraries (like DefaultHTTPClient, Volley, Retrofit etc). Hence it is good practice to abstract our Api Layer from actual implementation (third party library).</p><h4><strong>Abstraction (Interface), I use for my Api Layer.</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b91aad8d58f5ecb6b3734495b43df1a8/href">https://medium.com/media/b91aad8d58f5ecb6b3734495b43df1a8/href</a></iframe><p>Hence the abstraction covers most of the functionality that we expect from any HTTP client (functionality like GetRequest, PostRequest, PutRequest, PostRequest &amp; Cancel Request).</p><h3>API layer Implementation — Using Volley HTTP Client.</h3><p>I have implemented the Api layer abstraction using third party library - Volley.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/717880d76cc0224e3053cdc03d3c8517/href">https://medium.com/media/717880d76cc0224e3053cdc03d3c8517/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d475f5aefa1f7c6579c8676a5278f4a/href">https://medium.com/media/2d475f5aefa1f7c6579c8676a5278f4a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65b3cd2d819ac9c0fc00bedc5d168d57/href">https://medium.com/media/65b3cd2d819ac9c0fc00bedc5d168d57/href</a></iframe><h3>Usage</h3><p>Inside our application always refer using abstraction and not using implementation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9daec71bfcde0938a356511a85dc2ab1/href">https://medium.com/media/9daec71bfcde0938a356511a85dc2ab1/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a947e989a6b2c9e3c81a78caad7191ea/href">https://medium.com/media/a947e989a6b2c9e3c81a78caad7191ea/href</a></iframe><h3>Changing To New Third Party Library</h3><p>In future, if we decide to move to new library (for example Retrofit instead of Volley), then the changes that we need to make are,</p><p>Create a new implementation for our defined abstraction using new third party library (Retrofit).</p><p>Then make our abstraction to refer the new implementation.</p><pre>HttpClientApi mHttpRestApi = RetrofitHttpRestApiImpl.getInstance(this);</pre><p>That’s it, no more changes required in our application.</p><h3>GitHub Link</h3><p>Sample application has been hosted in Github,</p><p><a href="https://github.com/apvasanth03/Android-Http-Client-Abstraction">https://github.com/apvasanth03/Android-Http-Client-Abstraction</a></p><h3>Things To Do</h3><p>Currently our abstraction doesn’t support some functionality like MultiPart request, Image request etc, that needs to be added to our abstraction.</p><h3>Reference</h3><ol><li><a href="https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html">https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html</a></li><li><a href="https://developer.android.com/training/volley/index.html">https://developer.android.com/training/volley/index.html</a></li></ol><h4>Thanks</h4><p>Vasanth</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53510c7f743d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>