<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>API Design on Andrew Bancroft</title>
    <link>https://www.andrewcbancroft.com/tags/api-design/</link>
    <description>Recent content about iOS development with Swift in API Design  from Andrew Bancroft.</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 25 Apr 2017 13:35:04 +0000</lastBuildDate>
    
        <atom:link href="https://www.andrewcbancroft.com/tags/api-design/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Every Developer is an API Designer</title>
      <link>https://www.andrewcbancroft.com/2017/04/25/every-developer-api-designer/</link>
      <pubDate>Tue, 25 Apr 2017 13:35:04 +0000</pubDate>
      
      <guid>https://www.andrewcbancroft.com/2017/04/25/every-developer-api-designer/</guid>
      <description>&lt;p&gt;Every function; every class; every struct and enum and protocol is an API.&lt;/p&gt;
&lt;h1 id=&#34;you-8212-are-an-api-designer&#34;&gt;YOU — are an API designer&lt;/h1&gt;
&lt;p&gt;As developers, we move into and out of the role of &amp;ldquo;API Designer” &lt;em&gt;constantly&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Have you ever thought about that? &lt;em&gt;You&lt;/em&gt; are an API designer! You create Application Programming Interfaces &lt;em&gt;all the time&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I believe that everything we create has design built in, whether we&amp;rsquo;ve thought much about it or not.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t know why that thought changed my mindset so much, but it did. Maybe it&amp;rsquo;s because I always associated APIs with massive frameworks, standard libraries, and 3rd party code modules. It&amp;rsquo;s as if I thought there was a special class of developer that did that work, and all my job entailed was putting the jigsaw puzzle together.&lt;/p&gt;
&lt;p&gt;But when you and I design and create Types of any kind, be they data structures or functions, we ourselves, as &amp;ldquo;regular developers”, are in the business of creating APIs. We&amp;rsquo;re building ways for ourselves and others to &amp;ldquo;connect” to and interact with our code… to interface with it and &lt;em&gt;use&lt;/em&gt; it in order to perform work.&lt;/p&gt;
&lt;p&gt;You may be building these things for your team to use, or you may be building them for the future [you] to use. The fact is, we slip in and out of consuming &lt;em&gt;and creating&lt;/em&gt; APIs all the time.&lt;/p&gt;
&lt;h1 id=&#34;being-mindful-of-shifting-roles&#34;&gt;Being mindful of shifting roles&lt;/h1&gt;
&lt;p&gt;It&amp;rsquo;s been helpful for me to recognize when I shift in and out of each role, because creating an API applies a different aspect of the programming mind than consuming an API does.&lt;/p&gt;
&lt;p&gt;When you &lt;em&gt;create&lt;/em&gt; an API, you&amp;rsquo;ve got to be super conscious of your decisions. Types matter. Names matter. Inputs, outputs, dependencies and the like all matter when you&amp;rsquo;re creating an API. &lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Because other people (or you!) will have to deal with what you create in a direct way. Sure, everyone might be concerned about the implementation and whether or not it has bugs or not. But they&amp;rsquo;ll be &lt;em&gt;most&lt;/em&gt; concerned about how to use the thing… the API… to get work done.&lt;/p&gt;
&lt;p&gt;When we drop out of the mode of designing and creating APIs into API &lt;em&gt;consumer&lt;/em&gt; mode, we experience the ramifications of our API designs directly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&amp;ldquo;Why is this property named &lt;em&gt;that&lt;/em&gt;??”&lt;/li&gt;
&lt;li&gt;&amp;ldquo;Does this function really need &lt;em&gt;all these parameters&lt;/em&gt;?”&lt;/li&gt;
&lt;li&gt;&amp;ldquo;This function returns &lt;em&gt;what&lt;/em&gt;?”&lt;/li&gt;
&lt;li&gt;&amp;ldquo;I wish this concept was represented as a ___ instead of a ___…”&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you&amp;rsquo;re cognizant of what you&amp;rsquo;re doing with respect to creating and consuming APIs, it&amp;rsquo;s a huge help to your team and to [future you].&lt;/p&gt;
&lt;h1 id=&#34;apis-and-team-mates&#34;&gt;APIs and team mates&lt;/h1&gt;
&lt;p&gt;I was working with a teammate, and we were having a discussion about the Type of a property in a class we were building together.&lt;/p&gt;
&lt;p&gt;The original API was a property of Type &lt;code&gt;String&lt;/code&gt;, and the name of the property was &lt;code&gt;FieldNames&lt;/code&gt;. I thought to myself, &amp;ldquo;Huh… FieldName&lt;strong&gt;s&lt;/strong&gt;… plural… Why is this Typed as a &lt;code&gt;String&lt;/code&gt;? Either the name should be singular, or the Type should be switched out.”&lt;/p&gt;
&lt;p&gt;We ended up switching that out to a Type that conveyed the idea of being able to store multiple things in that property.&lt;/p&gt;
&lt;p&gt;The point? Something as small as the letter &lt;code&gt;s&lt;/code&gt; and the Type of a property made a head-scratching difference in my understanding of the API. I didn&amp;rsquo;t know how to use it until I asked. And that&amp;rsquo;s a tiny bit dangerous if the person who built it isn&amp;rsquo;t there to ask, anymore, right?&lt;/p&gt;
&lt;h1 id=&#34;1-takeaway&#34;&gt;#1 Takeaway&lt;/h1&gt;
&lt;p&gt;The number one takeway I want you to glean is this: Whether you realize it or not, if you&amp;rsquo;re in the software development business, you&amp;rsquo;re in the API design business. For me that meant becoming super conscious of the kind of code I&amp;rsquo;m writing, depending on which role I&amp;rsquo;m in as the keystrokes flow. Maybe this realization will impact you as well!&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>