While looking through the code and trying to give methods concrete contracts in javadoc I noticed that there are a lot of missing checks. For example. When starting a GameEngine you give an InitialState. After looking at the code I noticed that an if this state is null, it will result in a crash without a decent error message.
So I have two questions.
1. Do people approve if I add simple checks that check if the contract on on the state and parameters of a method are followed and throw a RuntimeException* if the contract of the method is broken? Ofcourse I also write an error to the logger before throwing the exception!
2. Is it ok to add the "assert" statement in private methods or methods that occur very often instead of throwing an exception?
* Not a RuntimeException itself, but various sub classes ofcourse! For example an IlligalArgumentException in the case of a null parameter where not allowed.
So I have two questions.
1. Do people approve if I add simple checks that check if the contract on on the state and parameters of a method are followed and throw a RuntimeException* if the contract of the method is broken? Ofcourse I also write an error to the logger before throwing the exception!
2. Is it ok to add the "assert" statement in private methods or methods that occur very often instead of throwing an exception?
* Not a RuntimeException itself, but various sub classes ofcourse! For example an IlligalArgumentException in the case of a null parameter where not allowed.