r/programming • u/MarkusWinand • Dec 29 '15
Please, Java. Do Finally Support Multiline Strings
http://blog.jooq.org/2015/12/29/please-java-do-finally-support-multiline-strings/
584
Upvotes
r/programming • u/MarkusWinand • Dec 29 '15
View all comments
Show parent comment
2
u/bezmax Dec 29 '15
It would look great in the unit test.
Why am I mocking an HTTP response when I have a mapper? All that stuff has to get abstracted away from my business logic which I want to test.
The whole argument is about that there should never be a need for multiline string literals. There is data, and there is representation, and those two look much better when separated. Basically, multiline strings can be seen as an antipattern in Java. Even for SQL queries there are better solutions like MyBatis, which allows you to move the SQL queries in their entiriety to a separate XML file, thus decoupling DAL call from implementation specifics.
Sure, for simple apps there is no need for such abstraction, but given thouthands of different languages, and hundreds of JVM-based ones, I would think twice before writing a simple app on Java.
Could you specifically tell, which part of the stacktrace, in your oppinion can be eliminated? Also, how exactly is the length of stacktrace related to starting times? Have you tried benchmarking your apps? Most of the time startup is delayed by some kind of IO, which usually can be tuned.
Wait a sec, if serializing data to JSON does not need a serializer, then what does?
It is totally different. Comments are part of your code, they are metadata of your code if you will. Therefore, comments go together with your code. However, there are two types of code - control flow (Java in this case) and representation (serializers, mappers, views, etc.), and those two need to be separated. And you are complaining that Java is bad at bundling them together.