这样做的优势在于,此类环境更为灵活,整个系统的各个部分之间并不存在紧密耦合。
The advantage of this is that such environments are more flexible, without tight coupling between various parts of the overall system.
当然,不建议这么做,但是这提供了最大的灵活性。
Of course, this isn't recommended, but it does offer ultimate flexibility.
这么做的好处包括灵活性、保持应用程序易于维护、代码重用和更好的性能。
The benefits of doing so include flexibility, keeping maintenance of the application easy as it grows, code reuse, and better performance.
That goes back to that idea of sort of discipline coding. It's easy to have assumptions about what you think are going to come into the program when you writ it. If you really know what they are use them as search, but if you think there's going to be some flexibility, you want to prevent the user getting trapped in a bad spot, and exceptions as a consequence are a good thing to use.
这又回到了规范编码的想法上来了,在你写代码的时候考虑,什么会进入你的代码的思考是简单的,如果你真的知道,他们是用他们来做搜索的,而你希望有一定的灵活性,你想要阻止用户,陷入一个艰难的境地,那么异常是非常实用的。
应用推荐