Dev Diary Update #3 – Compartmentalizing Data

Today we learned the importance of compartmentalizing data manipulations.

Today was a doozy. What should have taken an hour or two to add into our code, ended up taking 5-6 hours and a ton of headaches.

Why was this the case?

Because we did not properly piecemeal our code in the context when pulling it from the server. Let us explain.

When we pull data from our servers, we grab the entire restaurant document. In the same function, we then manipulate it to only hold the necessary properties that should be used for the day.

For example, we do not need hours for a restaurant’s entire week, only the hours for that particular day to display for a user. That is one manipulation that happens on the backend as a user loads the app.

You get the idea. We manipulate the menus used, restaurant status, hours, etc.

Funny enough, If you do not pull the data in, and then manipulate it in a separate function, you end up having to strip out parts of your code to get your desired data for other new concepts and add ins.

As we build our app, we are constantly learning and refactoring our code. While tedious, it is vitally important to keep things clean and lightweight moving forward to our upcoming launch. Therefore, this was a necessary refactor for future success, but still painful.

Quick checklist of what we did today:

1) Added in logic for the cart to grab new restaurant data on a user re-opening the app after closed. This prevents users from filling a cart @ 7pm, closing the app, and then trying to place the same order @8:30 after reopening the app after the restaurant is already closed OR if the restaurant manually turns itself off. The user can still get their cart from their local data, but now our app knows the restaurant is closed and throws and error screen on the pay function. (Photo for reference in the post)

2) We also added a quantity button to the menu item screen. This will allow users to duplicate a menu item upon adding it to the cart. (Photos for reference in post)

Everyday is another step closer to our launch. Good things are coming. Thanks for sticking around.