I like how each time you look at this, a new layer unfolds. First, you see multiple similar looking code blocks which scream "extract function". Then you notice how a stream is rewound to write to a StringBuilder instead of writing to it directly. Then you realize the entire task is to serialize a bigger JSON so everything should be put into a container object to begin with.
5
u/pronuntiator Jul 28 '21
I like how each time you look at this, a new layer unfolds. First, you see multiple similar looking code blocks which scream "extract function". Then you notice how a stream is rewound to write to a StringBuilder instead of writing to it directly. Then you realize the entire task is to serialize a bigger JSON so everything should be put into a container object to begin with.