I mostly program in PHP; there is absolutely nothing wrong with it per se. Honestly I can create things within a few hours that would cost a few days in a stricter language. I know the code is not that awesome, but that was not the goal. The goal was to try something out without wasting immense time & resources on making it “perfect”.
So back to the API
I created an APP
So recently I wanted to try to create a mobile app for Android & IOS. Obviously (or not?) I used Xamarin and started on this little project in C#. Now my skillset in C# is not that great, I’m really a beginner there. Yet I struggled big time with my own API. C# is so much stricter than PHP and behaves differently code-wise. Not only I had to change my mindset to program in it, I also realised my API was truly shit to work with.
Why my API was shit.
This story continous by all sorts of non-logic things. When I “designed” aka binge programmed the API it all seemed pretty easy and logical but no. Seriously no. I realised this and had 2 options
A: Try to force working with it anyways, making some dodgy code to be able to parse & work with the responses
B: Rewrite the API.
Well I chose A. Not because I was lazy but I wanted to find out how shit my API was and how to deal with it. I ended up with around 50 lines of code on the App side (C# thingy) and it sort of worked. I could somewhat decently parse the JSON responses and use it in the app. Yet it was not great. Every next logic part in my app was effected by the bad data setup.
So I actually rewrote my API. Changed the app code and I ended up with around ~5-7 lines that did the same as those 50 lines before. Not only that but every other logic part followed after the requests was easier. The data was way better usable, specially in a somewhat stricter language and ‘better’ architecture.
So.. what is there to be learned
If you ever make an API for commercial use; or an API that is actually getting used -alot- by other developers: Use it yourself first. Create a decent application that uses your API and rewrite everything that is NOT logical. Rewriting some parts hardly take any time, but you will save others a shitload not having to use your quirky API.
Even if you think your API is decent, logical and easy to use. Use it yourself.
Nothing motivates more to rewrite your API if you ragequit on the quirkiness of its requests & output.