There are several questions in StackOverflow that discuss when to use the assert statement or throw an exception. (Examples here , here , here , here and here .
However, I came to the conclusion that the generally accepted wisdom of assert-versus-throw is based on the assumption that you are working in the JVM. In the GWT universe, where your Java is transliterated into JavaScript and works in a browser context, the set of compromises is different from the others: statements are always compiled when launched in the browser and everything that reduces the size of your JavaScript less is a victory, especially if the web application should run on a mobile the phone. However, make sure they run in DevMode, so they have a utility during development.
So my questions are: did anyone think of a set of best practice rules that determine how to use the assert statement in GWT? I had members of my team who ask me: βSince the statement is compiled, does it make sense to have them?β, And I would like to get a good answer for them.
Also, does anyone have an idea of ββthe philosophy that GWT developers at Google have on this subject? Looking at the source code for GWT, they often use it.
java assert gwt design-by-contract
pohl
source share