In javaFx, we see the following statement in the initialize method of each generated controller class, for each control with fxid.
assert type != null : "fx:id=\"type\" was not injected: check your FXML file 'FinancialReport.fxml'.";
I can understand that the statement is there to ensure that, at the time this fxml is loaded the control with this fx:id is present in the fxml layout file, if the control is not present it throws an exceptions and quits the fxml loading process.
But then referring to this, I learned that assertions are not recommended to be used in production code. Again studying this tutorial, it seems that assertions are useful, especially when debugging (however, not to be used to validate the arguments of public methods).
I need more knowledge of the following :
- Is it fine to use assertions for input validation and such purposes, in production code?
- Can we do something else then the usual behavior when the Boolean expression turns false, like some alternative method call or something (an example would be nice).