|
Right Click|Format Document
done.
I don't care how your code is formatted. I'll just reformat it.
Real programmers use butterflies
|
|
|
|
|
Yeah, that usually works (unless you're not using VS).
However, this really messes up your source control because everything may have changed.
I have this with a customer of mine who uses an indentation of two spaces instead of the default.
Whenever he or I format a file our compare tools just show one big red square (deleted) followed by a big green square (added).
What the other actually changed will forever be a mystery...
Besides, I don't want to battle with coworkers over formatting.
We have much better things to do (like procrastinating on CP)
|
|
|
|
|
When I get unsatisfactorily formatted code, I'll do a "reformat run", and format every single document on a single check in to keep the source control churn to a minimum. It's a minor inconvenience. In practice I don't like your formatting. I don't like that person's formatting over there, either. I don't even like my formatting half the time. I'm picky*, but also lazy. So I just expect reformatting as part of the development process.
*And I get pickier when I'm on a team - at that point I'll go in and change my VS autoformatting settings to match the in house style.
Real programmers use butterflies
|
|
|
|
|
So the hideous "java standard" of
if (a == b) {
foo();
} else {
bar();
} can be rightly thrown in the bin to match C / C++ / C# styles:
if (a == b)
{
foo();
}
else
{
bar();
} or better
if (a == b)
{
foo();
}
else
{
bar();
} And make code written in any language consistent across a whole codebase.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I find myself styling my VBScript the same as SQL the same as Python, and after endless TypeScript start formatting C# with brackets on the same line and I start slipping into using expression-bodied properties.
Somedays I do wish there were just one language...
cheers
Chris Maunder
|
|
|
|
|
Yeah, but it would probably end up being QBasic, and then fragmenting from that ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Meanwhile I can go back and forth between same and new line opening { all day long as I switch between C#, and Java or Javascript.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
|
|
|
|
|
And then you apply your beloved C# style to Javascript and get some crazy bugs[^].
Just follow the language convention, or even better, use a lint/formatter to do it for you.
|
|
|
|
|
Or better, avoid Javascript altogether ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Your "better" reflects my view of how things should be formatted. I really dislike both the other alternatives you show.
Although I prefer languages that use words BEGIN and END (I first used Algol nearly 50 years ago) rather than { and } (which are less easy to see - although a modern IDE will highlight and should match them) they should be indented at the same level as the content of the bracketing. After all the block with the brackets is syntactically equivalent to a single line statement which would be indented.
|
|
|
|
|
That's why I use it: Indentation style (Whitesmiths) - Wikipedia[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|