The Java equivalent of your example is probably: @POST
public void doSomething(final Map<String, Object> thing) { ... }
So please stop trying to explain to me all the things that Java can't do concisely.Also you kinda missed my point about unit tests. Your test requires specialized flask-oriented objects (client, rv). Tests of the Java doSomething() can be written entirely without knowledge of the container; doSomething() is pure program logic. And the methods support refactoring. you picked something that java has libraries specifically catered toward I picked a basic REST service. I'd call that a pretty common use case. There should be minimal logic in the handler. You should defer most logic to a library function Again illustrating my point that well-written Java is more concise. You don't need to do this! The Java "handlers" I've shown are pure logic. There is no point in wrapping it with another layer. Sure, you probably could build a webapp framework that makes Python a lot more like Java. But so far nobody's done that. So Python programmers write wordy verbose flask apps with tons of validation and marshaling logic. It's tragic. |
More verbose than the Python.
>Sure, you probably could build a webapp framework that makes Python a lot more like Java
Not could, did. Literally just did, in 10 lines of code. Or there's flask-rest, which I linked.
>Again illustrating my point that well-written Java is more concise. You don't need to do this! The Java "handlers" I've shown are pure logic.
And flask-rest does that! If you're writing a restful service the more concise, better specialized tooling is readily available.
Now write the unmarshalling code and tell me Java is still more concise.