The problem with static
is not about threading, it's about global state and singletons.
One of the main reason for using MVP in GWT is to be able to test your presenters without the need for GWTTestCase
, because they wouldn't depend directly on GWT.create()
or JSNI, both requiring a browser environment to run (note that GWT.create()
is becoming usable in plain Java, and some projects such as gwt-mockito or gwt-test-utils use bytecode manipulation to make it run anyway). But even without MVP, that'd still be a problem:
Global states and singletons come in your way when testing:
- your tests are not isolated (they depend on global state, so two tests running at the same time share the same state and they're therefore not running in a controlled environment)
- you cannot use mocks/fakes/stubs or other test-doubles as the system-under-test directly uses singletons rather than depend on some objects passed by the environment (that one being different in tests and in production)
See http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/