Rule of Thumb: Preconditions Should be Public

added by Paul Wheeler
6/23/2014 12:39:44 PM

3 Kicks, 75 Views

In software, it's common to have operations that only make sense when an object is in a particular state. A problem arises if whatever is calling this class has no way of checking for itself if the operations will succeed or fail. The only way to determine if an amount has already been guessed is to try to make that guess and fail, and the only way to know there isn't a winner is to fail at getting the winner. We have private preconditions on public methods.