Effective APIs

Points to remember in order to build robust APIs. 1. Validate date exists, not just the format. Most date format validators only verify the structure of a date, but not the validity of the date itself. In other words, the date 1989-02-29 would pass validation even 1989 is not a leap year. Therefore, it’s a good idea to parse the date string into a date type and respond with a descriptive error in case an Exception is thrown.

Understanding WSDLs

I’ve integrated with a number of systems through SOAP Services. SOAP Services are described using WSDL files (Web Service Description Language). I felt it was worth taking the time to understand the structure of these files. I drew this diagram to summarise the structure: A WSDL is an XML file that defines one or more Services. Each service can have one or more endpoints, where each endpoint is a remote procedure call.

Why is this codebase such a mess?

When I first started working professionally as a Software Engineer (an Android developer, to be specific), I worked on a codebase that would read configurations from an XML file. I would say that 90% of the crashes in the app were because of the optimistic way the XML file was parsed. I asked my team lead, “Who wrote this? I’m always fixing this,” to which he replied, “He was a talented guy.

order_id PRIMARY KEY AUTO INCREMENT

Some time back, I had a system design interview. One of the questions that I was asked was: “How would you assign unique IDs in a distributed event processing system.” I proposed UUIDv7, however the interviewer didn’t agree. Then I suggested Snowflakes but nah, he didn’t like that either. After the interview, I did a deep dive in Distributed Sequencers and: 1. I discovered the correct answer is Vector Clocks.

The Tower upon the Lake

I write stories out of the bad dreams that I have. This is a story based on a dream that I had around 2008. Riding down the hill, it appeared as though the forest was ablaze as the dwindling sunlight fell on the autumn leaves. At some distance, he could see the lake, placid and shimmering. He made his way towards the lake, going off the beaten trail. Twigs and dried leaves crackled under his bicycle as he made his way down the muddy soil.

Worst.API.Ever

Back when I was developing Android applications, the worst REST API I ever had to consume had a response that looked something like this: [ [true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false], [false,false,false,false,true,true,true,true,true,true,true,true,true,true,true,true], [true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,true], [true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false], [], [false,false,false,false,false,false,false,false,false,false,false,false,false,false], [true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true], ] Allow me to explain: This API was used to retrieve available time slots in the upcoming week. Each nested array represents a day in the upcoming week. So for example: If today is Friday, then the array at index 0 represents Saturday.

Idempotency Keys

For the past 2 years, I’ve been working on the backend of a digital bank. One of the important concepts that I learned was about Idempotency Keys. In this article, I will discuss: What is Idempotency? Why is idempotency important in banking? What are idempotency keys? How are idempotency keys implemented? What is idempotency? An idempotent action is one that, if performed multiple times, produces the same output as if it were done once.

Distributed Microkernel Architecture

We were contracted to build an appointment booking system that enabled hauliers (truckers) to pick up containers assigned to them from a sea port. The tricky bit was that the contracting company operated a number of ports, and for legacy reasons, different ports had different strategies to assign a container to be picked up by a particular haulier. For example: in one port, you’d assign a haulier by entering their username.

The Ice Cream War

This is the story of the Ice Cream War that took place between my little brother and I when we were kids. I was born into a family of four brothers with myself in the middle, two elder ones and a younger one. The four of us grew up in Kuwait, a small country in the Middle East. Now as far as I’m concerned, Kuwait has one of the best Ice cream companies in the world: the Kuwait Danish Dairy or KDD for short.