In my previous post, I mentioned that I don’t like this code, that it lacked an important *ities, and I asked what was the problem with it.
The answer is that it isn’t easily debuggable. Consider the case where we have a support call from a user “I am in France but I see courses that are running in Australia”.
How do you debug something like that, and how can you work with the user on that.
In this case, adding something like this is enough to make the system much nicer to work with under those scenarios:
This is an internal detail, never expose externally (until this blog post, obviously), but it allows us to override what the system is doing. We can actually pretend to be another user and see what is going on. Without the need of actual debugging any code. That means that you can try things out, in production. It means that you don’t have to work hard to replicate a production environment, get all of the production data and so on.
Thinking like that is important, it drastically reduces your support burden over time.