on
New Project, Callback Hell
I have been working a couple of days on my new project, which is to solve a realistic business problem.
This is a server app/API for a Coffee Shop, which sells monthly coffee memberships.
For a single montly payment, the customer gets free coffee up to the following limits:
- Max 5 drinks per day
- One redemption in any 30 minutes.
Given this is a very simple problem to solve; I have already ran into issues with complexity called callback-hell.
Promises
I learned about how promises work, as I knew this can make the source code more easy to read and maintain.
The prescribed course tutorials use callbacks entirely. I realised that I will have to restructure my code to use Promises to keep it more maintainable.
Mongoose Models
In order to keep my code clean, I needed to implement many virtual fields to my Mongoose models. I also learned how these are (and are not) populated when Mongoose returns queried data.
Making my project more simple
I have rescoped and redefined the MVP several times during this project to keep to my budget and schedule. However, I do want to keep and implement the business rules (requirements) that I set for myself and the final project.