|
Funny enough, for JavaScript it's the exact opposite for #3. My peeve would be not using 1TBS for JavaScript/Typescript. There's actually a technical reason why, but now it's just so ingrained. And it's easy to spot a JavaScript rookie vs a pro if they try and format it like C#.
Totally agree about the empty catch blocks though. Even in JS.
Jeremy Falcon
|
|
|
|
|
Agreed with the opening brace placement in JS/TS vs C#. I've done very little JS, but this is something I've quickly adopted, despite doing the opposite in C#. If I see an opening brace on a line on its own in JS, it just looks wrong to me.
Somehow I can manage do the context switch in C# as if it was second nature, which is just as well, otherwise I'd really get stuck on this sort of thing.
Coding standards are weird. It's just as well there's so many of them.............
|
|
|
|
|
dandy72 wrote: Somehow I can manage do the context switch in C# as if it was second nature That's a sign of a good coder actually. Like with JS, there's a technical reason. Being able to let go of things (if there's a good reason) is a good thing. Like for instance, I love camel case. But, I doubt that would fly in Rust.
dandy72 wrote: Coding standards are weird. It's just as well there's so many of them............. Preach.
Jeremy Falcon
|
|
|
|
|
You would hate my use of On Error Resume Next. This implicitely sets the code as
try {
statement1
} catch {}
try {
statement2
} catch {}
etc.
There are some places where this construct is perfectly fine, but only in short modules. Oh, and I don't use the other On Error statements. Try Catch Finally is far better.
|
|
|
|
|
Kevin Marois wrote: What bugs you when you see someone else's code?
1. "Hungarian" variable names
2. TAB instead of spaces
3. TAB instead of spaces
...
100. Did I mention "TAB instead of spaces"?
Mircea
|
|
|
|
|
Item 1 is just evil.
Item 2 - it's xaml. It's not code
Item 3 - I prefer braces to be on the line below, but it's just habit. damned if I know where I picked up on that. I just don't think the opening brace on the same line is clear. But that is my preference. I know other folks that go BSC if the brace is under the if...
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
charlieg wrote: Item 3 - I prefer braces to be on the line below, but it's just habit. damned if I know where I picked up on that. I just don't think the opening brace on the same line is clear. But that is my preference. I know other folks that go BSC if the brace is under the if... Except in JavaScript (I realize the OP is C#... just saying) there's a legit reason to not use a new line for the brace.
Jeremy Falcon
|
|
|
|
|
Clicked on the link, read what was said there and pondered for a minute.
I've decided that is one of the dumber language decisions I've ever seen.
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
I’m begging you for the benefit of everyone, don’t be STUPID.
|
|
|
|
|
MarkTJohnson wrote: I've decided that is one of the dumber language decisions I've ever seen. People that dismiss JavaScript really just don't know it. Yes, it started off quickly/rushed, but it's come a long way. It's different. It's both functional and OOP. Nothing more. Nothing less. I think it's a great language, minus a few little quirks... which most languages have.
It started off being web centric, so it has historic "issues" from that like ASI. Most web languages are script kiddie friendly, but JavaScript/ECMAScript has come a long, long way. I can promise you that most issues with the language is more so due to it being popular and 99% of people really knowing nothing about it.
Not to mention, it's fast. Really fast, thanks to the optimizations over the years. Of course, not Rust/C++/C# fast... but it's one of the fastest scripting languages out there.
Jeremy Falcon
|
|
|
|
|
Replying/preaching 6 times in one these types of threads - interesting.
Trying to defend javascript - priceless.
|
|
|
|
|
Slacker007 wrote: Trying to defend javascript - priceless. Always man.
Jeremy Falcon
|
|
|
|
|
Jeremy Quixote, I presume?
Software Zen: delete this;
|
|
|
|
|
Hopefully he will post again but I didn't think he was saying JavaScript was dumb but rather the justification given in the link was dumb for the specific code construct.
|
|
|
|
|
MarkTJohnson wrote: Clicked on the link, read what was said there and pondered for a minute.
I've decided that is one of the dumber language decisions I've ever seen. Dumb decisions pretty much defines JavaScript. The only thing I can think of that JavaScript missed is use of indents to define blocks as in Python.
|
|
|
|
|
1.2.3.YES
Give me coffee to change the things I can and wine for those I can not!
PartsBin an Electronics Part Organizer - An updated version available! JaxCoder.com
Latest Article: Simon Says, A Child's Game
|
|
|
|
|
Use of literal values annoys me a lot. Especially when that hard-coded value needs to be changed.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
That's a good one. Especially if that literal is used more than once...
Jeremy Falcon
|
|
|
|
|
Rick York wrote: Especially when that hard-coded value needs to be changed.
All code will need to change. That is just a fact of life.
But coding for all possible futures just leads to code that is hard to understand and maintain in all futures.
|
|
|
|
|
That was remarkably non sequitur.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
Kevin Marois wrote: I just can stand it when someone doesn't use braces in IF statements: For me, that's acceptable... as long as the rest of the code is formatted well. Especially for stuff that's terse in nature like if (!blah) return; at the start of a routine. But it would have to be something short and simple.
Kevin Marois wrote: What bugs you when you see someone else's code? If we harken back to the first point... when folks don't use spacing properly. Code should read like text. And in English we have paragraphs. When I see large code files with no blank lines... I mean... what?
function checkout(goodsPrice, shipmentPrice, taxes) {
const total = goodsPrice + shipmentPrice + taxes;
const para = document.createElement("p");
para.textContent = `Total price is ${total}`;
document.body.appendChild(para);
}
function checkout(goodsPrice, shipmentPrice, taxes) {
const total = goodsPrice + shipmentPrice + taxes;
const para = document.createElement("p");
para.textContent = `Total price is ${total}`;
document.body.appendChild(para);
}
Jeremy Falcon
|
|
|
|
|
At least in C/C++ putting the opening bracket on the same line as a function definition
int f(int x) {
} But that's OK in classes - particularly if its a one-liner
class C {
int x;
int f(int n) { return x*n; }
{;
Keep Calm and Carry On
|
|
|
|
|
It's not exactly code, but comment boxes in the form of complete rectangles. The pinheads who originally drew them presumably believed that other people adding comments in the box would bother to keep its right-hand border nicely aligned. Not to mention that many of those comments provided a revision history for even the most trivial changes when, even in 1981, we had a source code management system that provided a full history, so that you could see who made each change, why, and get a diff between whichever versions you wanted.
|
|
|
|
|
But where is that VCS today? The source probably is still here. It feels so good to look at the header in a file originally committed into Jedi VCS years later checked in into an SVN repo with no option to keep the history to see where our journey began.
|
|
|
|
|
It was a proprietary VCS that is still in use. Some former colleagues are still using it, and some of my commits would probably still be there over 20 years later! Once released software had been proven for long enough, most of the history in that release would be deleted to free up storage space, which was at more of a premium back then. Code ownership was part of the culture, so one thing it supported was ownership of each code file by a user group, so that only members of the group could "open" a file for a commit. A file in the OPEN state also served as a warning so that anyone working on a private copy could consult with the developer changing the code to avoid merge conflicts.
modified 31-May-23 6:58am.
|
|
|
|
|
Greg Utas wrote: The pinheads who originally drew them presumably
Well to be fair I wasn't a pinhead when I did that very long ago. Just inexperienced.
Greg Utas wrote: most trivial changes when, even in 1981, we had a source code management system that provided a full history
There are two comments for that one.
One it is just so cool the first time one figures out source control macros. Who can't resist using the one that inserts the change history?
Two been a while but it was after the year 2000 when a company I interviewed for, when I asked what source control system they were using, the interviewer explained that they had been considering putting one of those in place so my experience would fit well with that.
|
|
|
|