Refactor everything

Recently I added a new feature to Makro. I decided to make it based on a feedback I received which said that there’s a lot of duplicate foods in the database. Since I do not have time to go through everything I wanted my users to be able to edit and/or delete (duplicate) foods themselves. But at the same time I did not want to enable mass deleting all of the foods added or trolling in general.

To solve this problem I made it so that the users can edit or delete foods freely but every change that is made is sent to me for approval before anything happens. Oh, and I added a section where the users can ad translations for foods, too. Now everyone is able to contribute to the development of Makro if they want to. And while I did that, I noticed that there isn’t actually that many duplicate foods in the database which is great.

After I was done adding the functionality for those aforementioned things I had to add the approval/disapproval functionality to the admin pane. I did not look forward to it. And why is that? Truth to be told, I have been quite lazy with the admin pane. Everything is on one page and on top of each other so every time I open the page, tons of requests are sent to backend to fetch all the needed data.

It wasn’t by any stretch of the imagination optimal or elegant solution but it worked good enough for my needs. I didn’t really care about it that much just because, well, the only person using that page is me since I’m the only admin. The result was that I dreaded adding any new features to the page at all.

Refactor. Refactor everything.

It was time. Actually, it was way past time. I really did not look forward to the task I had to do. It was going to be tedious, frustrating and really boring but it had to be done. I’ll spare you the super boring details of it but in the end I ended up with one parent component that had navigation and 11 children. One of those rascals was a so-called data-list -component which every other kid used to display the data. It took me quite a while to get all done but I am happy that I did it. Now it is more elegant and works pretty much like the profile page for users and it does not send multiple request to fetch everything since most of the time the data is not needed.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *