Here’s my code:
deleteStuffFromDb(); // void method
deleteStuffFromCache();
deleteStuffFromDb() is an interface method with the return type, void.
Ideally, the first method would return a value (Success/Failure). This return value would determine whether the second method executes.
I could modify the interface since it gets called by 2 classes. However, there’s still the risk that, as an O&M developer without a full picture of the system, I could break something.
How do you propose that I determine whether this void deleteStuffFromDb()’s execution determines the deleteStuffFromCache()’s execution.
Here are some ways I’ve thought:
- put a try/catch around deleteStuffFromDb(), throwing an exception for an error case. If the catch() is encountered, then don’t execute the deleteStuffFromCache().
- put the logic of the deleteStuffFromCache() into the method, deleteStuffFromDb(), and allow/disallow its execution within this method
- …?
Please give me your thoughts and reasons for your choice.
Thanks.
If the full picture of the system is that it is only used in two places, you should certainly change them both. A full recompile and system test will reveal whether anything else is broken.