3 ms·
As I think I said in a previous entry, I use line breaks to separate "logical" instructions, whatever length they have. This is very common with chains (like th
by TrianguloY 5y ago
As I think I said in a previous entry, I use line breaks to separate "logical" instructions, whatever length they have. This is very common with chains (like the typical split.filter.map.filter.join). This also helps with comments, because you can put a comment above the corresponding line of code. If the comment is long and involved multiples explanations, maybe you need to try to split the code into multiple lines, for example a function call where each parameter is something worth explaining. Other times the are a lot of syntactic useless code that is required only to wrap the important part (looking at you, Java) and often I split it so that the important part is the one on a separate line, something like:
// Get the ids from the data
var ids = object.stream().map(object->
object.getName() + object.getType()
).distinct().collect(Collectors.toList());
Word wrap is the one that automatically adapts the code to my screen, not the other way around.
- 3836293648 5y ago// Get the ids from the data var ids = object.stream() .map(object -> object.getName() + object.getType() ) .distinct() .collect(Collectors.toList());