Last week, I left at the approval on an alternate branch that I was working on. That got approved and I continued more work on it this week.
What was the whole idea of an alternate branch?
I was using helper functions to reuse certain SQL queries easy. Not small ones — large ones with multiple tables that were pretty complex to understand at the first glance.
The basic idea was that it became too difficult for a new developer looking at the API for the first time to understand what was going on!
That is why I had to eliminate all such unnecessary functions — and create all API calls using two basic functions —
create_SQL_clause. This way, a new developer had to understand the use of only these two functions to start creating APIs.
Thus started the task of elimination of those functions.
Next, I revisited the boilerplate class because there had been updates since I last modified it.
Now, it contains everything that you need to know to start writing APIs. You can just copy the boilerplate directory and start working. Inline comments explain what the code does, why it is needed and how to do it.
Thirdly, I started working on a new branch
api_merge. Why? Short answer — to merge redundant classes.
Consider the following URLs.
GET /api/courses GET /api/courses/1
Ideally, these two functions perform the task of retrieving data from the same table
AT_courses. However, I was doing the task through two different classes —
CourseDetails. Why? Firstly, the old way meant I was doing these things through helper functions — so I didn't really understand what was going on as it appeared to be single line function calls to the helper functions. Secondly, different URL structures meant different classes to me — until I saw the bigger picture. The subtle differences could be removed with just a few lines of code.
So, I worked the rest of the week on merging such functions together. The eventual difference in code on the branch can be viewed here.
Just four more weeks left now. I am happy with the progress.