|
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!
|
|
|
|