Coding Pet Peeves
-
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
People who go against the editor's defaults X| I'm currently working on a project where the developer uses two spaces instead of the default four. So now, whenever I change a file and I save it, Visual Studio reformats the entire file to have four spaces. We're now working with editorconfig files... Same for curly braces on the same line, seen it before and Visual Studio just keeps trying to correct me. At one time I've even seen a project where curly braces and semi-colons were always aligned to the end of a line, like on column 800 or something :~ How the :elephant: does someone think "let's mess up the VS settings before starting to write code!" and then go all out of his way to have such an unnatural coding style X|
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
-
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.Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
-
Slacker007 wrote:
Trying to defend javascript - priceless.
:laugh: :laugh: :laugh: Always man.
Jeremy Falcon
Jeremy Quixote, I presume? :-D
Software Zen:
delete this;
-
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
-
I would take offense to #1 and #2, but not #3. I use the K&R style of bracing. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
I agree
-
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
Quite happy about `if` one-liners, religious about #3. And only comment that which is not obvious.
Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.
-
People who go against the editor's defaults X| I'm currently working on a project where the developer uses two spaces instead of the default four. So now, whenever I change a file and I save it, Visual Studio reformats the entire file to have four spaces. We're now working with editorconfig files... Same for curly braces on the same line, seen it before and Visual Studio just keeps trying to correct me. At one time I've even seen a project where curly braces and semi-colons were always aligned to the end of a line, like on column 800 or something :~ How the :elephant: does someone think "let's mess up the VS settings before starting to write code!" and then go all out of his way to have such an unnatural coding style X|
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
I prefer the two-space indent over four because it saves screen space. Visual Studio has a lot of useful windows surrounding the text editor. Using two-space indents allows more text to be seen. Some of my colleagues and I have used two as the default since the Turbo Pascal days when we only had 80 columns to work with. Seeing a file formatted with four spaces after all these years just seems wasteful. My code uses has increased the use of shorter functions over the years so running off the screen is not as much of a problem as it was when I started.
-
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
I don't the understand the hate for #3. From the other comments I appear to be in the minority. Mostly because it saves vertical space and still provides a well defined block for the conditional statement.
-
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
-
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:
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. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
It really annoys me when people don't respect the coding style they encounter while changing someone else's code. It's even worse when they run a reformatter that changes the entire file to their preferred style. I think a bunch of the style quirks like #3 came from a time where the number of lines in the file made navigation arduous. I'm looking at you ed.
Cheers, Mike Fidler "I intend to live forever - so far, so good." Steven Wright "I almost had a psychic girlfriend but she left me before we met." Also Steven Wright "I'm addicted to placebos. I could quit, but it wouldn't matter." Steven Wright yet again.
-
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
-
#3 most definitely, #1 less so. Empty 'catch' blocks, ran into that fairly recently...:mad::mad::mad:
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
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.
-
It really annoys me when people don't respect the coding style they encounter while changing someone else's code. It's even worse when they run a reformatter that changes the entire file to their preferred style. I think a bunch of the style quirks like #3 came from a time where the number of lines in the file made navigation arduous. I'm looking at you ed.
Cheers, Mike Fidler "I intend to live forever - so far, so good." Steven Wright "I almost had a psychic girlfriend but she left me before we met." Also Steven Wright "I'm addicted to placebos. I could quit, but it wouldn't matter." Steven Wright yet again.
MikeTheFid wrote:
I think a bunch of the style quirks like #3 came from a time where the number of lines in the file made navigation arduous. I'm looking at you ed.
Not sure if it's true or just an internet legend, but I've read that the opening brace on the previous line style first gained popularity when the layout person at the publisher for what became a very influential book made the change to reduce the page count.
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
-
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
return func_0(func_1(func_2(func_3())));
i may have lost a job because during interview the coder showing me his code showed me code like this and i told him i thought it was terrible . probably a good thing i didn't get it . there was a lit cigarette dangling from his mouth and i hate cigarettes . -
1. I just can stand it when someone doesn't use braces in IF statements:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) Console.WriteLine("line1") ; Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
2. XAML where the code is all on one line! (This is all on one line!)
3. First brace not on a new line:
static void Main(string[] args)
{
bool isTrue = false;if (isTrue) { Console.WriteLine("line1"); } Console.WriteLine("line2"); Console.WriteLine("line3"); Console.ReadLine();
}
What bugs you when you see someone else's code?
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
Kevin Marois wrote:
What bugs you when you see someone else's code?
What bugs me is when someone insists their coding style is 'better' and thus makes it a formal coding standard for the company. Having spent more than than a decade neck deep in formal process standards including studying actual formal research I know that coding style guides have zero measurable impact on any objective quality metric. The most common refrain is that it is more 'readable'. I spent quite a bit of time trying to find any research at all that actually objectively measured that. I found one single study which was based on marketing material (not code) which only showed that more than 4 type faces was not a good idea.
-
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
-
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?"
-
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.
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.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.