Designing APIs With Customers in Mind
In order to ensure that you set your APIs correctly, you need to think like a designer and start with the customer in mind.
Join the DZone community and get the full member experience.Join For Free
it turns out that the apis between services may be the most important thing in the whole system. to ensure that you set your apis right, you need to think like a designer and start with the customer in mind.
why microservices matter
to understand how we use microservices, it helps to think about why we got interested in them in the first place. like many companies, new relic started with a single monolithic app. as the company grew, the app grew. by 2010 this app had been broken up into a handful of coarse-grained services. the company continued to grow. soon, the two main services had too much code and served too many masters. engineering teams were stepping on each other’s toes when submitting features. maintenance costs were high. small problems could rapidly become big problems.
we wanted clear ownership boundaries, a system that was simpler to understand, explicit interfaces, reduced maintenance costs, and improved safety. while these things were achievable through several approaches, a move to microservices seemed to offer the most promise. so in early 2014 we launched a major effort to break apart the monolith.
bumps in the road
ultimately, we were able to make it work, but there were some big (and unnecessary) bumps along the way. our tooling didn’t really support our developers, who it turned out were eager to start building services. where we expected dozens, we got hundreds. and the services those developers built didn’t really support other developers. their apis were awkward to use and integrating with them often required lots of hands-on collaboration.
these two failings shared a common theme: they were both failures of design, not of execution. both the tooling and service developers fell into the trap of “inside-out” design. they built solutions based on what they wanted to give people, not what they wanted people to be able to accomplish with them. the services were shaped around the developers’ internal data models and the tools were built as thin wrappers around technologies.
a three-step design process
we were able to make things better by applying the same design process that we use for our customer-facing software to our internal software and tools. that design process can be summed up in three steps:
- what problem is the user trying to solve?
- how will they use “the product” to solve it?
- test your assumptions with real users.
by following those three steps and practicing “outside-in” design, we started to again design our apis before building our services.
how to design better interfaces
don’t panic! this isn’t some kind of big up-front design exercise. the idea is that those apis are going to be the most expensive thing to fix later, so let’s start iterating on them first before getting too deep into what the service or tool will actually do. there are a couple of good tricks that i’ve found for doing this:
- write the docs first. this puts you in the mindset of a user instead of an author. it’s also much cheaper to argue about and change documentation than it is to discover your usability problems after the implementation is done.
- try your apis early by just writing client code that isn’t hooked up to anything, or by using a simple server to stub the api.
design secrets from the experts
we also took a few techniques directly from our design team:
- run ux experiments. here is where internal tools and services have a huge advantage over externally facing products. your users work at the same company, so go watch them. ask them to think out loud while they are working and see how they attempt to interact with your api. resist the urge to help them. your users aren’t stupid, so if they can’t figure it out on their own, your job isn’t done.
- remember that great artists steal from others. what are the current interfaces you enjoy using? build your systems using the same principles. this has the added advantage of creating a system that will be immediately familiar to others.
- give people who use your services or tools an easy way to provide feedback. no matter how open your organization is, if you don’t reach out and open an explicit channel for feedback, people will wait until they have a big problem before they bring up any issues.
you’ll still need to use your good judgment, but by taking the ux of your tool or service seriously and applying a few of these tricks, you can build better interfaces. and if you get a better interface, a lot of other things will get easier. remember, just because you’re not pushing pixels doesn’t mean you’re not a designer.
Published at DZone with permission of Nic Benders, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.