4 ms·
Because then people like the ones tearing down their strawman "Java is verbose" would be closer to having a point. Annotations work really well: they are easy
by eitland 7y ago
Because then people like the ones tearing down their strawman "Java is verbose" would be closer to having a point.
Annotations work really well: they are easy to write, easy to write and typesafe enough.
- joshlemer 7y agoBut they are in my opinion really difficult to understand, test or customize. In the example above, the reified Option<boolean[]> can be passed around, transformed, inspected, invoked in tests, etc. The annotation approach weaves together the aggregate class (the overarching config class), the specific field of the class (`verbose`) and how that field should be parsed from command line arguments.
- eitland 7y agoOk. I can try to help: In this particular case, when you test you just set the field to what you want. In other cases where you actually want and need to test that the annotations works at runtime you use a test container (Arquillian was the big thing for integration testing JavaEE last time it was relevant to me, and since we are talking enterprise Java there's a fair chance that Arquillian will still work and maybe even still be the most popular solution.)
- mrkeen 7y agoI just cannot give any credence to annotations. @Transactional? @Stateless? @NotNull? In each case (and presumably many more) you can just go and write a unit test for each of these disproving them.