Contents

The software industry as a whole contains a lot of people doing a lot of different things, but for every developer working on new embedded firmware, there’s about ten building the linchpin of modern software – CRUD apps that serve requests over HTTP. A lot of these apps are backed by MVC frameworks like Ruby on Rails or ASP.NET, and backed by ACID-compliant relational databases like Postgres or SQL Server.

Sharp edges in production can lead to all kinds of unexpected cases during the execution of an HTTP request – client disconnects, application bugs that fail a request midway through, and timeouts are all extraordinary conditions that will occur regularly given enough request volume. Databases can protect applications against integrity problems with their transactions, and it’s worth taking a little time to think about how to make best use of them.

There’s a surprising symmetry between an HTTP request and a database’s transaction. Just like the transaction, an HTTP request is a transactional unit of work – it’s got a clear beginning, end, and result. The client generally expects a request to execute atomically and will behave as if it will (although that of course varies based on implementation). Here we’ll look at an example service to see how HTTP requests and transactions apply nicely to one another.

I’m going to make the case that for a common idempotent HTTP request, requests should map to backend transactions at 1:1. For every request, all operations are committed or aborted as part of a single transaction within it.

At first glance requiring idempotency may sound like a sizeable caveat, but in many APIs operations can be made to be idempotent by massaging endpoint verbs and behavior, and moving non-idempotent operations like network calls to background jobs.

Some APIs can’t be made idempotent and those will need a little extra consideration. We’ll look at what to do about them in more detail later as a follow up to this article.

Let’s build a simple test service with a single “create user” endpoint. A client hits it with an
email
parameter, and the endpoint responds with status
201 Created
to signal that the user’s been created. The endpoint is also idempotent so that if a client hits the endpoint again with the same parameter, it responds with status
200 OK
to signal that everything is still fine.

Brain Talk

Your brain is your greatest resource—use it by design to help you achievehealth, happiness, and success!

—Arlene R. Taylor PhD

Q. What do you mean by “affirmation” and how is it powerful?

A. According to the dictionary, the word
affirm
means to validate and to state positively. Practically, this defines a nurturing communications style; one in which you talk to yourself and to others in a positive manner. In general, “positives” are more powerful than “negatives.” Positives are a one-step process that creates a picture that you want the brain to follow. Negatives, on the other hand, require a two-step process. Words such as
don’t
are meant to convey
do the opposite of the picture that was just created in the brain.
This is often difficult for a mature brain to figure out and may be virtually impossible for the immature brain to compute.

Some have said that by the time the average child reaches adulthood, most have heard between seven and nine negative comments for every positive. Consequently, it is no wonder that many people have no idea how to practice the art of affirmation successfully. In fact, they tend to reinforce unhelpful behaviors by speaking in a negative style (e.g., don’t, can’t, won’t, shouldn’t).

If your parents and other caregivers learned the art and science of affirmation from their ancestors, they likely would role model to the next generation. If not, they likely did not because you can only teach what you know.

In order to successfully validate and encourage others, you need to begin with you—because people tend to speak to and treat others in the same way they speak to and treat themselves. With some informed effort, you can learn how to speak to yourself confidently in a positive communication style; you can incorporate affirmation into your life on a daily basis; and learn to pass along the gift to others.

My brain’s opinion is that developing and consistently implementing an affirming communication style is absolutely essential. All human beings thrive with encouragement. The consistent use of affirmations is a practical and empowering way to encourage yourself and others.