<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kevin Swiber</title>
    <description>The latest articles on DEV Community by Kevin Swiber (@kevinswiber).</description>
    <link>https://dev.to/kevinswiber</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F434378%2F74d0cc45-3213-455b-9f9b-f2610b1963a0.jpg</url>
      <title>DEV Community: Kevin Swiber</title>
      <link>https://dev.to/kevinswiber</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kevinswiber"/>
    <language>en</language>
    <item>
      <title>Redefining the 3-Tier Architecture</title>
      <dc:creator>Kevin Swiber</dc:creator>
      <pubDate>Mon, 15 Nov 2021 18:06:56 +0000</pubDate>
      <link>https://dev.to/kevinswiber/redefining-the-3-tier-architecture-1al0</link>
      <guid>https://dev.to/kevinswiber/redefining-the-3-tier-architecture-1al0</guid>
      <description>&lt;p&gt;It's time to sit by the fire, grab some hot cider, and listen to a story. No, this isn't &lt;a href="https://en.wikipedia.org/wiki/Are_You_Afraid_of_the_Dark%3F"&gt;Are You Afraid of the Dark?&lt;/a&gt; fan fiction. On second thought... for some us, this &lt;em&gt;is&lt;/em&gt; a horror story. 👻 Don't worry. It ends on a good note, with some thoughts on how the API landscape has changed the way we design applications.&lt;/p&gt;

&lt;p&gt;Once upon a time, established software principles dictated a very simple model of delivering &lt;a href="https://www.irisclasson.com/2012/07/19/stupid-question-2-what-do-you-mean-by-lob-line-of-business-application/"&gt;line of business applications&lt;/a&gt;. We called it the 3-tier architecture, a self-describing little thing named before software vendors learned to influence human psychology with buzz words.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S0KuEt_l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swiber.dev/images/posts/how-we-reinvented-3-tier-architecture/3-tier-architecture.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S0KuEt_l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swiber.dev/images/posts/how-we-reinvented-3-tier-architecture/3-tier-architecture.svg" alt="A diagram of a 3-tier application architecture, including presentation, logic, and data." width="593" height="530"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;3-tier application architecture from the late 1900s.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It made sense, a logical separation of concerns — as we say in design pattern books — and it reflected a big change that was already underway.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Wait, how did we even get here?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's take a joyride in the technobabble time machine! Data and logic were once colocated, situated on specialized &lt;a href="https://www.ibm.com/docs/en/zos-basic-skills?topic=concepts-mainframe-hardware"&gt;mainframe hardware&lt;/a&gt;, living a blissful life ignoring network partitions... while solving other incredibly difficult problems associated with this architecture. User interfaces were text-based and delivered to the business user via simple teletype terminals. Programming languages — like &lt;a href="https://en.wikipedia.org/wiki/COBOL"&gt;COBOL&lt;/a&gt; — were run close to the data layer — often a relational database like &lt;a href="https://en.wikipedia.org/wiki/IBM_Db2_Family"&gt;DB2&lt;/a&gt;. This was really the start of the thin client pattern.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As time progressed, databases maintained the desire for single-machine consistency and availability. User interfaces were migrating from terminal emulators to more modern desktop (and eventually) Web experiences. This represented a conflict. How do we get mainframe data outside the terminal emulator? Part of this migration path involved moving logic out of the mainframe and into &lt;a href="https://en.wikipedia.org/wiki/Application_server"&gt;application servers&lt;/a&gt;, often with VT100 compatible terminal emulators connecting directly with programming language APIs via libraries.&lt;/p&gt;

&lt;p&gt;Okay, wait... isn't all of this very boring? Maybe. But that's a trait associated with line of business applications. &lt;strong&gt;Boring is a long-term survival strategy for software architecture.&lt;/strong&gt; 🙃&lt;/p&gt;

&lt;p&gt;Increasingly, logic had to move closer to the client and farther from the data. This brings us to the fundamental desire for the aforementioned 3-tier architecture.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Presentation tier&lt;/strong&gt; - Consumes logic produced by a Web or application server, carefully crafted to create the ugliest Web sites we've ever seen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logic tier&lt;/strong&gt; - That darn application server. It's really this tier that spawned a new breed of Business Process Management software and integration tooling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data tier&lt;/strong&gt; - Pick a favorite monolithic database: Oracle, MySQL, Microsoft SQL Server. Apologies if some of these names induce anxiety.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's hold on to our britches, because we're getting to the good part. &lt;em&gt;Everything has changed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Scrubbing the timeline a bit, skipping past some difficult years — SOAP vs. XML-RPC, MongoDB vs. CouchDB — let's look at some motivating aspects to the latest cool kid architectures. 😎&lt;/p&gt;

&lt;p&gt;From the perspective of a multi-tiered application architecture, our human-facing interfaces are being driven by APIs. Based on Postman's &lt;a href="https://www.postman.com/state-of-api/#key-findings"&gt;2021 State of the API Report&lt;/a&gt;, 49% of respondents said that &lt;strong&gt;more than half of the organization's development effort is spent on APIs&lt;/strong&gt;. This is astronomical and represents an evolution that's been steadily growing around us.&lt;/p&gt;

&lt;p&gt;We have arrived at a place of &lt;strong&gt;dumb connectors and smart components&lt;/strong&gt; with respect to business logic. We are just now ingesting the concept of API-First. There are benefits to putting &lt;a href="https://github.com/kevinswiber/siren"&gt;more smarts in the messages&lt;/a&gt;, but that's a different campfire story. 🏕🔥&lt;/p&gt;

&lt;p&gt;Application developers are now often specialized in front-end vs. back-end, with a few of us shifting contexts as full-stack developers. In retrospect, this was all inevitable. The success of the medium was indisputable. As a result, &lt;strong&gt;the Web got smarter&lt;/strong&gt;. And we all grew with it.&lt;/p&gt;

&lt;p&gt;So what do we do with all these line-of-business applications as we move forward into solving new century problems? Well, as it turns out, &lt;strong&gt;API Gateways are the new VT100 terminal emulators.&lt;/strong&gt; Let's look at how this all fits together, how we've redefined the 3-tier architecture.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Experience tier&lt;/strong&gt; - Thick clients are all the rage. While our slick, new Web apps don't contain &lt;em&gt;all&lt;/em&gt; the business logic, they often contain quite a bit. Decisions are now made in the browser.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration tier&lt;/strong&gt; - We are utilizing &lt;a href="https://gateways.fyi"&gt;API Gateways&lt;/a&gt; and iPaaS platforms to facilitate interaction between our new experience tier and the API data sources we've already built over the years. Experience APIs can be pieced together using façade and scatter-gather patterns in the gateway, backed by security, analytics, and message transformation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data source tier&lt;/strong&gt; - CRUD APIs, database connections, message queues... If it can be accessed over the network, it can be accessed by an API Gateway. The database has become an implementation detail. Microservices have fortified this as the new reality.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Logic is now a vertically-oriented concern.&lt;/strong&gt; Collaboration has never been more critical to achieving success in line-of-business applications. Here are some tips and tricks for how to manage this. &lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/kevinswiber" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lqNI7oF4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--ClDVTBHj--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/434378/74d0cc45-3213-455b-9f9b-f2610b1963a0.jpg" alt="kevinswiber"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/kevinswiber/5-developer-tips-for-surviving-api-first-32oh" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;5 Developer Tips for Surviving API-First&lt;/h2&gt;
      &lt;h3&gt;Kevin Swiber ・ Nov 11 ・ 5 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#api&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#architecture&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#apigateway&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;/blockquote&gt;

&lt;p&gt;We only see more exploration here, as folks look to federation, microservices, and even micro-frontends to achieve a sweet-spot of modularity and centralized data source access when crafting application experiences.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We can even &lt;a href="https://god.gw.postman.com/run-collection/15567703-afee4d2e-ed1f-4d56-b2c0-aacea79eaa18?action=collection%2Ffork&amp;amp;collection-url=entityId%3D15567703-afee4d2e-ed1f-4d56-b2c0-aacea79eaa18%26entityType%3Dcollection%26workspaceId%3De9bb1adb-2f2e-4ace-a482-38c570d65275"&gt;create micro-frontends in Postman&lt;/a&gt; now.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Does this resonate? It does for a lot of folks. Again, we are in a time of migration. How long will it last? Well, the VT100 emulators and mainframes are &lt;em&gt;still&lt;/em&gt; around, all these years later.&lt;/p&gt;

&lt;p&gt;Transient technology, as it turns out, may never die. 🧟&lt;/p&gt;

</description>
      <category>api</category>
      <category>productivity</category>
      <category>architecture</category>
      <category>apigateway</category>
    </item>
    <item>
      <title>5 Developer Tips for Surviving API-First</title>
      <dc:creator>Kevin Swiber</dc:creator>
      <pubDate>Thu, 11 Nov 2021 20:33:43 +0000</pubDate>
      <link>https://dev.to/kevinswiber/5-developer-tips-for-surviving-api-first-32oh</link>
      <guid>https://dev.to/kevinswiber/5-developer-tips-for-surviving-api-first-32oh</guid>
      <description>&lt;p&gt;The world of API-First has swept developer marketing by storm. With so much information scattered around the Internet — and managers inquiring about the &lt;em&gt;API-First roadmap&lt;/em&gt; — a lot of pressure is being applied to squeeze out a reasonable strategy. We're all familiar with that &lt;a href="https://youtu.be/hIP7mHRog4o"&gt;Jeff Bezos memo&lt;/a&gt;. Paraphrased:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;API all the things or get pelted with rotten tomatoes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And now this mega-rich guy is &lt;a href="https://youtu.be/bx_CdBcRexc"&gt;taking William Shatner to space&lt;/a&gt;. Clearly, it's time to get serious. A lot of us may be thinking, wow, okay, this memo came out in 2002. According to &lt;a href="https://insights.stackoverflow.com/survey/2021#demographics-age-prof"&gt;StackOverflow's 2021 Developer Survey&lt;/a&gt;, a large number of professional developers were between the ages of 6 and 15 at this time. Y'all were playing with Bratz dolls or looking up GTA: Vice City cheat codes while APIs were being mandated from on high. Don't bring this up to your manager.&lt;/p&gt;

&lt;p&gt;Instead, communicate a strategy using these 5 tips!&lt;/p&gt;

&lt;h2&gt;
  
  
  Know your audience
&lt;/h2&gt;

&lt;p&gt;The first key step in any software project is to &lt;strong&gt;find the stakeholders&lt;/strong&gt;. These are the folks — both business and technical — who will set the game board, make the rules, and let you know if your team is actually winning. Once established, here is a sample of the questions to ask 🕵️:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What do we feel a successful API-First strategy enables?&lt;/li&gt;
&lt;li&gt;Which of those benefits is most impactful?&lt;/li&gt;
&lt;li&gt;What's motivating an API-First strategy &lt;em&gt;today&lt;/em&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When business stakeholders answer questions, we do not interject with a correction we believe is more &lt;strong&gt;technically correct&lt;/strong&gt;. Let's take this up with our developer compatriots when ironing out the details. This keeps us all out of trouble. 🙏&lt;/p&gt;

&lt;p&gt;It may be too early to know in the beginning, but a question to plant in everyone's mind is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How do we measure success when moving to an API-First strategy?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's not leave ourselves out of the equation! As members of the development team, our insight is important here, as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Speak the language
&lt;/h2&gt;

&lt;p&gt;Sometimes, we just nod and smile when we don't understand each other. And maybe that's fine if we're video chatting during the awkward networking phase of our favorite virtual API conference. When it comes to building software, &lt;strong&gt;finding a common vocabulary is a productivity hack&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://en.wikipedia.org/wiki/Domain-driven_design"&gt;Domain-Driven Design&lt;/a&gt;, this is known as the Ubiquitous Language. Domain experts know more about how the business functions, and this creates &lt;a href="https://en.wikipedia.org/wiki/Information_asymmetry"&gt;information asymmetry&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;According to Eric Evans:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Translation blunts communication and makes knowledge crunching anemic.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When we're building APIs, we should be mindful of this common language.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Should the property be called &lt;em&gt;state&lt;/em&gt; or &lt;em&gt;status&lt;/em&gt;?&lt;/li&gt;
&lt;li&gt;Is it a &lt;em&gt;soft_delete&lt;/em&gt; or an &lt;em&gt;eviction&lt;/em&gt;?&lt;/li&gt;
&lt;li&gt;Is it a &lt;em&gt;retrospective&lt;/em&gt; or a &lt;em&gt;harbinger_of_death&lt;/em&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As we go through this exercise, we will often run into undefined behavior. This is a great opportunity to work together and &lt;strong&gt;discover if any &lt;em&gt;shadow processes&lt;/em&gt; exist in the business today&lt;/strong&gt;. Then we can effectively model those workarounds in the API. Beep boop. 🤖&lt;/p&gt;

&lt;h2&gt;
  
  
  Understand the building blocks
&lt;/h2&gt;

&lt;p&gt;Distributed systems are hard. When we spend time weighing the options, we take a proactive approach to architecture. It takes a lot of practice before we can speed-run our way to victory.&lt;/p&gt;

&lt;p&gt;Single Page Apps (SPAs) and APIs are everywhere. They're the de facto standard for new applications. We could just slap together a quick API to turn SQL query results into a JSON payload. Ship it! 🙈&lt;/p&gt;

&lt;p&gt;There are more than a couple of elephants hidden in this labyrinth.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which component owns &lt;strong&gt;application state&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;What are the trade-offs related to &lt;strong&gt;storage, compute, and data transfer&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;What are our API &lt;strong&gt;consumer use cases&lt;/strong&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SPAs are &lt;a href="https://en.wikipedia.org/wiki/Rich_client"&gt;thick clients&lt;/a&gt; in a client-server architecture. A common approach is to let the API act as a thin layer over data storage while moving compute to the Web browser and taking on more costs for for data transfer.&lt;/p&gt;

&lt;p&gt;Thinking about our consumer use cases, we can make a decision on which properties and trade-offs make the most sense. Where we give control, we give complexity. If we want to delegate much of the control to the thick client, we can look at a solution like &lt;a href="https://graphql.org/"&gt;GraphQL&lt;/a&gt;. The trade-off is pushing query and mutation decisions to every client application. If we want to centralize that complexity on the server side, we can look at patterns such as &lt;a href="https://docs.microsoft.com/en-us/azure/architecture/patterns/materialized-view"&gt;materialized views&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Whatever decisions we make, let's make them deliberately. Documenting these motivations, system capabilities, and trade-offs can give us a cheat code for the next API-First project. And yes, by the time you're done reading this sentence, the documentation is already out of date. We're still working on that one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plan for next steps
&lt;/h2&gt;

&lt;p&gt;Whew. We did it! Spot bonuses all around! jk jk... No matter how fast or slow we move when building software, one thing is always certain: we got it wrong. Either we missed a requirement or the business needs changed or legislation was introduced or... or... The list is never-ending.&lt;/p&gt;

&lt;p&gt;Some of us use humor as a defense mechanism. Here are a few ways we can protect our systems without therapy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are our &lt;strong&gt;scalability&lt;/strong&gt; vectors?&lt;/li&gt;
&lt;li&gt;Where can we find &lt;strong&gt;performance&lt;/strong&gt; opportunities?&lt;/li&gt;
&lt;li&gt;How can our APIs &lt;strong&gt;evolve&lt;/strong&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTTP is the most successful protocol of its kind. Let's steal from it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use the network&lt;/strong&gt;. Communications move through several network layers. We can take advantage of this, often transparently. &lt;a href="https://gateways.fyi"&gt;API Gateways&lt;/a&gt; are proxies that apply security, message transformation, custom routing, and more to centralize policy management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure out a caching strategy&lt;/strong&gt;. This isn't just part of a terrible whiteboard interview to optimize a search algorithm. HTTP allows caching at the client, the server, and intermediaries. Bust out that &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control"&gt;Cache-Control&lt;/a&gt; header! It's a quick performance win.&lt;/p&gt;

&lt;p&gt;API evolution is a big topic. For now, it's good to remember that most JSON parsers are forgiving by default. &lt;strong&gt;It's easier to add a field than to remove one&lt;/strong&gt;. We can take advantage of this. There are also various deprecation signals to evaluate, such as the &lt;a href="https://datatracker.ietf.org/doc/html/rfc8594"&gt;Sunset header&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design with intention
&lt;/h2&gt;

&lt;p&gt;There's always room for exploration and improvement, so let's do it collaboratively.&lt;/p&gt;

&lt;p&gt;API definitions offer a great medium for discussion (not just automation).&lt;/p&gt;

&lt;p&gt;Rapid protyping of APIs is only getting better. We can author an OpenAPI definition, generate a mock server, collaborate on design, and start the next iteration &lt;a href="https://apis.how/blueprints/new-api-using-the-openapi-specification/"&gt;all within the same tool&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Examples of Postman collections generated from API description formats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.postman.com/postman/workspace/lgbtq-pride/collection/10354132-7c3c2d3e-ef2f-4c8b-89c2-8506a325cecc"&gt;Generated from a GraphQL schema&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.postman.com/postman/workspace/restaurant/collection/12959542-b0d9f34f-763e-47c8-902c-517850bb9697"&gt;Generated from an OpenAPI definition&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Success emerges from a combination of many disciplines working together to solve problems and create opportunities. We should &lt;strong&gt;make intention explicit&lt;/strong&gt;. Look to processes like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Event_storming"&gt;Event storming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Value-stream_mapping"&gt;Value-stream mapping&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://apis.how/"&gt;API Lifecycle Blueprints&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The term &lt;em&gt;API-First&lt;/em&gt; can have different meanings to different people. Don't go into the API-First strategy unarmed! To recap:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Know your audience.&lt;/li&gt;
&lt;li&gt;Speak the language.&lt;/li&gt;
&lt;li&gt;Understand the building blocks.&lt;/li&gt;
&lt;li&gt;Plan for next steps.&lt;/li&gt;
&lt;li&gt;Design with intention.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Follow these 5 tips, and you'll be the next person to take a trip on that CEO's weird-looking rocket! 🚀✨&lt;/p&gt;

</description>
      <category>api</category>
      <category>productivity</category>
      <category>architecture</category>
      <category>apigateway</category>
    </item>
  </channel>
</rss>
