top | item 38204006

(no title)

innocenat | 2 years ago

If it isn't just a b c d e but longer variable name or function call, then I imagine it wouldn't be as clear.

discuss

order

kmoser|2 years ago

This. An extreme example, where I think my solution works best, is SQL statements that are hundreds of lines long. No sane developer would put that all on one line.

FlyingAvatar|2 years ago

Ahh, I think your example would have communicated the benefit of what you were sharing more clearly with longer variable names. For single word variables, though, it feels needlessly verbose.

To answer your earlier question about object definitions, in cases where the objects are small, I do think more concise (single line) notation can be more readable. An example, though not a great one because it's data more than it's code:

  items: [
    { type: "a", quantity: "12", price: 123.45 },
    { type: "b", quantity: "7", price: 456.78 },
    { type: "c", quantity: "3", price: 9.00 },
  ]
If the number of properties exceeds say 3, or the names of them are complex, I would lean toward the longer form.