Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TechDebt: Remove overloaded status enums. #143

Open
daltonfury42 opened this issue Apr 25, 2021 · 4 comments
Open

TechDebt: Remove overloaded status enums. #143

daltonfury42 opened this issue Apr 25, 2021 · 4 comments

Comments

@daltonfury42
Copy link
Collaborator

Our backend is very straightforward CRUD on two resources, queues and tokens. Both of them have two status fields, QueueStatus and TokenStatus.

These enums are a bit overloaded, a better approach would be remove them and have booleans, (isPaused, isRemoved) for queues, and (isRemoved, isNotified) for tokens.

@thehamzarocks
Copy link
Collaborator

thehamzarocks commented Apr 25, 2021 via email

@daltonfury42
Copy link
Collaborator Author

My reasoning was that "removing/deleting" and "pausing" are two different unrelated things, and should not be kept coupled. It could lead to bugs like you pause->delete->resume, and it would inadvertently lead to it getting undeleted, which might not be the intended outcome. Then we would have to handle it using if/else in code, as we are currently doing. (We could avoid a lot of bad if/else here).

Then we could have isPaused set via our PATCH request (here), and delete can be modeled as a DELETE request.

@thehamzarocks
Copy link
Collaborator

thehamzarocks commented Apr 25, 2021 via email

@daltonfury42
Copy link
Collaborator Author

daltonfury42 commented Apr 25, 2021

In this case, I was reading our code, and while counting the number of people currently in the queue, we were taking count of tokens where status = WAITING. We missed the people who were NOTIFIED. They are also in the queue and should have been counted.

So, same reasoning, if the token was notified or not, is independent of if the token is currently in the queue or not (DELETED vs ACTIVE).

You could say that we could have taken the count(status != DELETED), but still...

Also we might start sending SMS as notifications soon (if all goes well, 50% chance), and tomorrow if we want to count the number of SMSes that were send by the user etc, it's better to keep them as separate fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants