I've been going through and editing some answers and questions recently for readability of code sections. I realize there's a number of ways developers like to format the code blocks, especially when it comes to the use of brackets (i.e. {..}
). I've read a number of coding standards throughout my career and it seems that - in general - most prefer to avoid the need to use horizontal scroll bars as it becomes difficult to follow.
Is there a rule of thumb for editing out horizontal scroll bars? I don't want to be stepping on toes if someone feels their answer was "more readable" as they posted it. Here's an example:
var someVariable = SomeMethodWithLotsOfArguments(argumentNumberOne, someObject.AndItsProperty, lastArgument);
vs.
var someVariable = SomeMethodWithLotsOfArguments(
argumentNumberOne, someObject.AndItsProperty, lastArgument
);
Or the use of property initializers (in C#):
var someNewObject = new SomeObject { PropertyA = someValue, AnotherProperty = anObject.WithProperty };
vs.
var someNewObject = new SomeObject {
PropertyA = someValue,
AnotherProperty = anObject.WithProperty
};
In my humble opinion, the latter in each example is more readable and so I would make the edit for clarity.
EDIT: Found Why do people not split long lines when posting code here? after posting, which is similar but doesn't address whether there is a guideline to follow.