| |
| Recipe 9.15: Placing Preconditions on Method Arguments |
Last Updated: Sep 8, 2003
Status: Draft
|
|
|
|
How important is this problem to you?
(Login to Vote)
5.00 Rating, 1 Vote
|
|
How acceptable is the proposed solution?
(Login to Vote)
0.00 Rating, 0 Votes
|
|
Problem:
   
You want perform validity checking on an argument to your method, for example, to perform bounds checking on the argument. You want the validity check to be part of the method interface, so that it is performed regardless of the method implementation.
Solution:
Discussion:
(Example: arg = n percent, so assert 0 <= n <= 100)
(I'd probably rather associate multiple preconditions with the method itself, since that's more powerful and would make this obselete?)
|
|