As a client to any API, you may be concentrating on a specific API endpoint and the documented request body and parameters. An important consideration though is looking for headers and other parameters that may be documented as being accepted across the entire API.

For instance, one very important header (which is not standardized) is an idempotency header. While RESTful APIs have conventions for dealing with idempotency, the practical reality is that many APIs today rely on an idempotency header, especially APIs involving payments or other forms of transactions. Each API also deals with idempotency slightly differently, but the general theory is that a request with the same idempotency header value should only be processed once. If the request was already processed, usually a cached response is returned. Some APIs require that the request body must be the same, so the specific details vary between APIs. See the PayPal documentation for examples.

It is easy to miss the general API details in the documentation. However, in order to have a successful API integration, it is critical to use parameters like the idempotency header when available.

One of the “early mistakes” that any programmer makes is creating an infinite loop. Maybe a condition was not correctly set in a while loop. Or maybe some unexpected overflow condition occurred in a for loop.

Infinite loops have always had a bad cognitation for me. However, infinite loops are effectively the backbone of any long-running program. Whether it be apps with a user interface or a server side program, they all effectively use infinite loops to process incoming data.

Consumer apps use loops which listen for any UI interfaction among other data sources. Server side programs can use loops to listen for incoming events such as a new connection and then process data based on those events. Once the event has been processed, the loop starts again and waits for the next event.

Of course, in the technical definition, the run/event loops are not infinite because there are some loop termination conditions (whether it be a process signal or other flag). However, in practice, the expectation is that the programs run in a loop until a user wants to terminate the entire program.

When a programmer encounters an infinite loop the first time, s/he may think of it as something to avoid, but in practice, infinite loops are one of the core building blocks.

One (perhaps obvious) thing I’ve practiced over the years is to write code where every variable and method has the most private access control possible. As I iterate over the code and refactor pieces, I keep trying to limit access to data. In effect, limiting access helps with encapsulation.

Once I’ve iterated over the code several times, I find that the public methods usually leads to a good API. With some refinement, the public methods become public interfaces/protocols which eventually other modules consume.