<?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 Pamodzou Ndiaye on Medium]]></title>
        <description><![CDATA[Stories by Pamodzou Ndiaye on Medium]]></description>
        <link>https://medium.com/@pamodzoundiaye?source=rss-8f67201d154------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O7mOwfEzpVBfVO-PgrRGEA@2x.jpeg</url>
            <title>Stories by Pamodzou Ndiaye on Medium</title>
            <link>https://medium.com/@pamodzoundiaye?source=rss-8f67201d154------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 22:32:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pamodzoundiaye/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[Introspection as APIs Engine]]></title>
            <link>https://medium.com/@pamodzoundiaye/introspection-as-apis-engine-d8edfdec3733?source=rss-8f67201d154------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8edfdec3733</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[app-engine]]></category>
            <category><![CDATA[introspection]]></category>
            <category><![CDATA[reflections]]></category>
            <dc:creator><![CDATA[Pamodzou Ndiaye]]></dc:creator>
            <pubDate>Sat, 17 Mar 2018 16:12:49 GMT</pubDate>
            <atom:updated>2018-03-17T16:14:22.273Z</atom:updated>
            <content:encoded><![CDATA[<p>Application Programming Interfaces also known as APIs are a set of techniques, approaches, methods and protocols meant to expose services, so that different applications can communicate. And this concept makes of APIs a must when it comes down to designing modern applications.</p><p>However, writing APIs can become tedious, especially when the number of entities involved in services exposure is quite relevant. Introspection is the mechanism by which a program finds details about its most inner structure.</p><p>This paper tackles an approach of API design based upon the introspection concept and meant to reduce the huge and almost inevitable code redundancies.</p><p>Even thought the approach described here could be used to create various API types, we focus in this article on WEB APIs. First off, let me tell you what’s wrong with the classical way of making APIs; you used to organize meetings with the Client, collecting specifications you knew would inevitably change. You would start by writing the entities you identified with the client and for each of these entities, you would create a very minimalistic CRUD API as a first draft, before collecting more specific needs from the client.</p><p>This actually means a lot of work and we haven’t even come yet to the exasperating part where that very client who gave you all those specifications “changed his mind”. Clients hardly ever have a clear idea of what they want. So you end up writing again and again the same portion of code for different entities.</p><p>We propose in this article a workaround by using introspection; entities should be defined in the first place and the API is created at runtime by an engine which inspects entities. Instead of having a crud for each entity, we can keep a simple and easily readable engine which consists in a mere CRUD.</p><p>For the record, I designed this approach as a software engineer at Hubso for a client whose identity will remain unknown for very understandable reasons. Ever since then, the same approach has been used successfully in two other projects.</p><p>More practically, let’s dive into the code to show how this can be implemented. For this first tutorial, we will make an API for an app which keeps track of the begging phenomena evolution here in Senegal by using the Google App Engine platform. And we can assume without any loss of genericity that this approach remains feasible on whatever platform you are using.</p><p>We will need two classes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/134ce6c23f6199b2891c4037d5e4245f/href">https://medium.com/media/134ce6c23f6199b2891c4037d5e4245f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5324b4b28b05d3a89b3f24f1e0f4a47b/href">https://medium.com/media/5324b4b28b05d3a89b3f24f1e0f4a47b/href</a></iframe><p>Now, let’s make the API. As explained earlier, we will use introspection mechanism to inspect the two entities and provide services. We set a specific class for the database interactions named CrudService. It’s a common and good practice, nothing unusual.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/294b34c26620e319731eb9c0123a6682/href">https://medium.com/media/294b34c26620e319731eb9c0123a6682/href</a></iframe><p>And we’re done. The good part of it is that if we have another entity do add, let’s say Serigne.java, we don’t have to touch the beggingEvolutionAPI class again. At runtime, only the entities in the specified packages will have their services available.</p><p>To the best of our knowledge, such an approach has never been proposed, probably because reflection is known to be too costly in terms of performance. This performance cost has been largely discussed and experiments results show that using introspection lowers performance (https://blog.frankel.ch/performance-cost-of-reflection/).</p><p>However, an analysis of performances between an API built with this approach and another one built the classical way shows that the performance gap is insignificant, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*1LtD-hKGwG9jAT5hRM03Cw.png" /></figure><p>Using introspection as an engine for building APIs remains an open problem. One has to choose between maximizing performance and reducing redundancies. And we acknowledge that APIs aren’t all about CRUDs, though it seems like a good start for any backend developer. In future papers, we will add annotations to cover more specific needs to the current engine and we will design a code-generating tool following this specification.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8edfdec3733" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>