A question for people with strong opinions on code-formatting.
Which of these styles do you prefer?
(Poll in next post.)
A question for people with strong opinions on code-formatting.
Which of these styles do you prefer?
(Poll in next post.)
@Edent I prefer colon-aligned because it's more visually pleasing, and I will die on this hill.
@Edent Value aligned is a reasonable choice if you have a code formatter that does it for you, otherwise left aligned.
@Edent I picked left aligned, BUT the way Xcode aligned Obj-C method arguments on the colon was indisputably correct for that context and I kinda wish it did it for Swift.
Is this a troll? No language I have ever seen recommends a space between the colon and the key in it's default style guide.
All the languages I use would recommend:
```
{
"lorem": "ipsum",
"dolor": "sit amet",
"consectetur": "adipiscing elit"
}
```
@Edent
"Centered on separator" might be the most cursed thing I've seen since "we don't allow unnecessary semicolons in our codebase".
@Edent Context is key.
I will almost always default to left aligned.
But there are occasions when having a lot of key pairs makes value aligned easier to read.
@Edent I like value aligned, but i hate when there's a really long name that pushes everything way out into the void
@Edent left aligned generally.
value aligned only when the entries are all closely related such that it makes sense to compare values to each other (e.g. “sampledMin”, “sampledMax”, “sampledMean”)
@Edent it really does not matter, there are guaranteed to be bigger fires to fight elsewhere 🙈
@Edent left-aligned, but without the space to the immediate left of the colon.
Largely because if you fire up Editor X with default settings and format the file, that's what it'll do and I don't fight defaults – because as @knotnicky says, there are bigger fights elsewhere.
@Edent strong preference for left aligned. It’s what an auto-formatter will do, and means that when you add key of a different length the diff doesn’t suddenly show your actual new value and a bunch of unrelated changes to the surrounding lines.
@Edent There is no call (IMO) for LTR text to ever be right aligned. Aligning separators makes for easier maintenance by presenting values in a tabular format that is easy for a new pair of eyes to ingest at a glance (easier than having to read and parse each line).
@rgarner @Edent @knotnicky This, plus amending any alignment other than a left alignment becomes a right royal PITA if you have to add items with longer keys / properties to the hash / object / dict (delete as applicable).
@gilesdring @rgarner @Edent @knotnicky "centered on separator" looks nice but it has Premature Optimisation energy, like one day it'll all break because you have a key that's too long or something