javascript
javascript copied to clipboard
Practice exercise 'bank account', too many throws
I've noticed that there are a lot "error" cases in this exercise. IMO these two tests are superfluous : "close already closed account throws error" and "open already opened account throws error".
Indeed, IMO there is no functional problem with closing an already closed account. In a real world, I try to go by the "Define errors out of existence" principle from "A Philosophy of Software Design" by John Ousterhout. In this chapter, the author points out that throwing errors unnecessarily increase the complexity of the software. We shouldn't be throwing errors if there is no real problem.