الجمعة، 17 أكتوبر 2014

Tester-Doer Pattern

The Tester-Doer pattern divides a call to a method that might throw exception into two parts:
1- Tester: Performs a test for the state that can cause the Doer to throw an exception.
           The test is inserted just before the code that throws the exception, thereby guarding against the exception
2- Doer: Is the actual method which we are going to call, this method should reveal what Exceptions it might throw if the passed state (e.g, Parameters) is not applicable for it.
This pattern is used to avoid performance problems which are raised from calling the method which is throw exceptions in common scenarios.