run(true);And then later on in the code I saw
run(false);At the time I wrote this, it was very clear what this meant, and I was saving myself time by having a single method where a flag would slightly alter the behavior. Reading this code several years later, it wasn't clear at all what it was doing. So how did I write it so it was easier to read? Instead of having the flag in the public method, just have two separate methods, and bury the flag in a private method. After refactoring, my code now looks like:
runAsynchronously();Internally, there is still a run method that takes a flag for running asynchronously, but the public API is now a lot easier to understand.