|
Mind bleach, I need mind bleach!!!
"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
|
|
|
|
|
For some reason - maybe it's my editor? - but lately I've been dropping a lot of { open braces after if (K&R style for me in C/C++) and it rains absolute mayhem down on my source code. My editor lights up like a $5 {expletive, use your imagination}, and of course nothing compiles. It's also just the sort of thing your brain will fill in for you automatically if it's not there while scanning code. Thanks brain!
To err is human. Fortune favors the monsters.
|
|
|
|
|
Yeah, with K&R your brain will register the harmful semicolon. But I for instance always use Allman style with any language.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
Single Step Debugger wrote: always use Allman style with any language.
If you can: GO forces you to use K&R style. Allman is a syntax error
Mircea
|
|
|
|
|
I always use braces, even when not required. It future proofs for later maintenance.
There was a great article supporting the always use braces approach, but I can’t remember the exact format used.
The article had extensive test cases around merging changes from multiple branches and showed how braces protected correct merging.
I have tried googling it, but with no luck. I guess I could just Chat GPT to provide the answer now? And if I do not like the answer then I will ask Chat GPT to write a white paper proving that my preferred brace style is superior and force my team to adopt it.
|
|
|
|
|
I *was* using braces. I'm talking about typing:
if(foo!=nullptr)
printf("foo valid\n");
}
Like that.
To err is human. Fortune favors the monsters.
|
|
|
|
|
At least it is a syntax error. That is a scenario where you can ask the editor to re-format for you and then compare with pre-format to see what shifted/indented unexpectedly.
Like you said, the indentation will trick you into not noticing the missing {.
The one that bit me was
if ()
foo();
and I added prefoo(); ahead of foo(); without adding braces.
“It was a setup, I tell you, wiseguy”
|
|
|
|
|
This is why I *always* use braces after an if is there is only one line of code ...
if(expression == true) {
doSomething();
}
Then later when reviewing my code, I decide to tidy it up because it looks nicer ...
if(expression == true) doSomething();
Third time around I add one line of code and spend the rest of the day trying to figure out why nothing works.
Nothing succeeds like a budgie without teeth.
To err is human, to arr is pirate.
|
|
|
|
|
Yeah, that's not a fun bug. Fortunately for me, the number of times that has happened to me I can count on one hand.
To err is human. Fortune favors the monsters.
|
|
|
|
|
That closing curly kicks my OCD right where it hurts.
|
|
|
|
|
|
Single Step Debugger wrote: Better than a semicolon at the end of an "if" statement.
That's a fun one. Back in my college days, a fellow student (much older than the rest of us, I think he decided to go back to college in his 40s) had the habit of leaving his system logged in, with his editor running...so whenever he took a break to (typically) go pick something up at the cafeteria, we'd do things like adding a bunch of spaces after a for loop and then a semi-colon (so it's off-screen and not visible), so his code read:
for ( int i = 0; i < someLimit; i++ ) ; <-- not visible without scrolling horizontally
{
}
We did it many times, but he never learned to lock his workstation...fool me once...
Poor guy. He was already struggling, and we made him waste a lot of his time on things like this...
Gaetan, wherever you are, I hope you still had a successful and rewarding career... ![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
That's so evil! I like it!
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
All students had some storage on a Novell network... I forget the details - either all storage was accessible by all by default, or we could create shares accessible to anyone or whoever we wanted to share with.
That was back in the DOS days where you didn't have a GUI to multi-select files/folders and delete them in a single operation. You could delete files in bulk at a command prompt using wildcards, but only in a given folder - not recursively - you then had to navigate to a different folder and repeat.
I knew people were poking around and taking stuff from each other, and running random EXEs they found (!), so I created a small program with an intriguing filename, such as, I don't know, "decodepwds.exe" that identified the user's home folder, and generated in it a hierarchy of folders with extended-ASCII names until the file system started reporting errors (there was probably a quota policy in place). Since you couldn't recursively delete folders in bulk, you were stuck with these folders with names that were difficult to type in...I had heard of people having no choice but to go to the IT admin and asking to get their account reset because they had run out of space, and had no idea how to delete all that crap. The IT guy had no clue where this was coming from, since the origin of said files/folders didn't get logged anywhere - and the owner of the files was the person running the EXE, so they couldn't blame someone else.
That's probably the worst I had ever done.
Sad thing is, even today, people would run a random EXE they found somewhere if the filename was interesting enough.
|
|
|
|
|
Didn't your compiler warn you about a 'possibly unintended empty statement' or something like that?
(Or have you disabled that error message?)
|
|
|
|
|
Huge legacy project 5+ million ROC - tons of warnings.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
You make it sound like "Yeah, the compiler gave me a warning, but I didn't read the warning".
If that is the case: YAFIYGI
|
|
|
|
|
Sounds like You've never worked on a big project. A lot of warnings are generated from the environment, not necessarily a bad code. That's why now we have systems like SonarCloud/SonarSource. Also, as I said it wasn't my code. I happened to be the development manager in charge. If you start hunting urgent production bug with building the project and analyzing low-level warnings, this is bad news for your employers.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
If you are "the development manager in charge", I am surprised that spending half a day, as you told, chasing this bug was your responsibility. But then again, I know nothing about your company.
If this really was your coworkers code, I guess he should have looked at the warning pertaining to his code. If you think that "This is a big system, so neither I as the development manager in charge, nor the developers responsible for a specific module, need to read the warnings - we'll rather complain in network forums about how nasty such bugs are", then I think you got what you deserved.
I have been working on big systems, and I have been responsible for the processing of warnings and errors, suppressing those that are considered 'noise', reporting the significant ones to the developer. I would never, ever, have classified 'Unexpected empty statement' as insignificant noise. I am not familiar with SonarCloud/SonarSource (I just checked the Wikipedia article; that is my first encounter with them). If this system is not capable of drawing your attention to unexpected empty statements, but let it drown in 'a lot of warning generated from the environment, not necessarily a bad code', then I would consider other tools.
I have been working with Coverity; it looks to me as if SonarSource is in the same business. With Coverity, you can indicate for almost any warning that 'This is noise - don't bother me with it'. But you are explicitly presented with every issue at least once, until you say 'Don't bother me with that issue any more'. You may also tell Coverity: "Never bother me with such silly details as unexpected empty statements - they're probably perfectly fine, good code!" In either case: You asked for it. You got it.
Your story does not suggest that SonarSource is a viable alternative to Coverity.
|
|
|
|
|
|
I found myself (in the old days) putting periods at the end of
COBOL comments... but that was OK.
|
|
|
|
|
Hi,
The company I work for has changed to using a secure pin over passwords as part of the Windows Hello routine.
I for one think PIN over Password is dodgy, no longer can I use B008IeS! as a password (I didn't but shipped something where I forgot to change it, whole other story!). View from the informed is this to make smart phone users happy (I am using a proper PC with a Proper Keyboard) or something else??
Glenn
|
|
|
|
|
Good news: just under where you enter the PIN there is an option to enter a password or a PIN.
|
|
|
|
|
Yes, but the change came some time ago.
|
|
|
|
|
Have they just changed the log on procedure at all or just give the password a new set of clothes?
|
|
|
|