- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Everybody is a peer. Otherwise your bladder would burst.
Admin
TRWTF is of course the leader with no peer review. "Leaders" often don't realize that things like that not only are good for code quality, but also strengthen - not weaken - the team and your position in it, allowing you to show - not tell - everyone that while yes, you make the final decisions, you are open to constructive criticism delivered in good form. Let them comment on your code to your face in review (or similar setting), or have them laugh at it behind your back, there's no other choice, because - while it's hard to believe and maybe painful - you're not as infallible as you think.
Admin
The correct way is to define an extension method named something like "In" which has multiple overloads and does equality internally, with inlining attribute: "v".In("a", "b")
Admin
@Mr. TA - Yes. And the
In
extension method should return anEnum
likeSo the calling code can learn (just in case it cares) which of the arguments matched. When defining the Enum it's important to ensure you have spelling errors, inconsistent casing, inconsistent use of underscores, and most of all, make the default / no-match value be at the the end, not the the beginning to stymie future non-breaking changes.
Once this Enum is in place you can improve the supervisor's code to read
There; that's so much better! ;)
Admin
You are on the right track but not quite there yet. Why define an enum when you can simply return a string like "frist", etc.? Also, like I said many times before, your code lacks NoSQL, data bricks and big insight lake.
Admin
I actually went through a phase where I made that mistake - being the "senior dev" with everyone else being junior, I didn't get my code reviewed by anyone, and assumed that all other senior devs had the same setup. I realized my mistake when I finally looked at what another senior dev on a mini-team within my team, who also hadn't had his code reviewed, had done. We're still picking up the pieces from that. And since then, everybody, without exception, gets their code reviewed.
Admin
I was going to hire WTFGuy, but Mr. TA makes a good point about not including NoSQL and the rest.
Admin
I would be more concerned about this WTFery if the else block reported "invalid report name". The original code is already forgiving of invalid names (it defaults them to UI3), and the revised code just picks a different incorrect UI in the case that the invalid name happens to be a substring of a valid name. In practice, variables like this don't usually get filled in arbitrarily, so such coincidences are unlikely.
Admin
report.spName = "thisReport"
report.ui = LoadUI1
report.ui()
Admin
Lol it's all good until someone names a report "eport, thatR"
Admin
Tell that to Amazon.
Admin
At first I thought this was the worst frist comment ever, but then I remembered that urine is #1
Admin
I have fond memories of working on a program where a certain function was called with a string parameter that it compared against "Stock", "Item", and several other values I forget to control processing. ("Stock" meant "addition or adjustment to inventory" and "Item" meant "sale", but that's another story.) We had a bug where a program that called this function wasn't working correctly. I spent hours studying the code and stepping through it trying to figure out the error, before the lightning bolt suddenly hit me that they had called it with parameter value "stock". Not "Stock", but "stock". There was, of course, no checking for invalid values, so it just fell through to the "else" (or out the bottom) in every test. (I won't even get in to discussing the logic flow.)
Admin
"WHY IS thirdReport2 SHOWING UI2?!?!?!?! IT'S SUPPOSED TO SHOW UI1! YOU IDIOTS!" (says the team leader)
Admin
I have two words for you: automated testing.
Admin
Agreed! Everyone’s code should be reviewed.
The real challenge though is getting Junior devs to do a real code review. I have a strong suspicion (mostly based on the amount of time taken for a review) that the junior devs’ reviews go through a very short checklist:
Sometimes, I don’t even think they bother checking point 2 if it passes the check on point 1...
Admin
To ensure code quality, all automated tests must be written by the Leader.
Admin
What no rules engine?
Admin
For more reports and greater leadership, code quality has been standardized. We are sorry.
Admin
The best person to review the most senior developer's work is the most junior team member.
Admin
This. OMG this.
Though, to be perfectly blunt, when I can get them to check point 2 on anybody's code, including their own, it's usually a good day.
I mean, I think they do it a little, but assertions along the lines of, "I fixed so many compile errors, I hoped that was enough" have been made by several of them, and I feel like it's likely that the only reason I haven't heard it from all of them is the rest understand those claims are just as bad as they sound. The compiler never cares how many compiler errors they fixed, it only cares if there are any compiler errors left.
Admin
My team lead would commit his code changes without review, and without writing any of the unit tests required by everybody else. Later he would assign bugs or enhancements to his team members, and they would realize that in order to test their changes, they’d have to write the entire missing unit test harness. Then he’d complain that their minor changes to his code were taking way too long.
Admin
This hits a bit too close to home. Actually I'm wondering if this was submitted by a coworker who recently left.
How do you deal with "team leads" like this? Micro managers, who always have to have their touch on your work, who demand piles of inept, inane, sometimes incorrect shit before they'll approve your PR? Teams leads who make suggestions exactly like this? Team leads who, in their PR, add a function and changes the quotes in the remainder of the entire file, making you wonder what exactly has changed on those lines and making it hard to understand what his contribution was in the PR?
Please.. I need help here. I'm not kidding.
Admin
I spent two weeks of my life hunting for a bug that had been introduced six months earlier by another team's lead dev who thought his code didn't have to be reviewed. The effect of the bug was that your computer crashed if it was put to deep sleep for about 45 seconds - 30 seconds was fine, 60 seconds was fine, but an interval somewhere in between crashed it.
His change: He spotted a statement if (ptr != NULL) { ... } and since clear and understandable code like that is for wimps and not for real programmers, and because he was smarter than anyone else, he changed it to if (!ptr) { ... }. If you can't see the difference, neither could he, apparently.
Admin
Changes such as a quote on the remainder of the file should be in a different commit, doesn't matter about PR.
Admin
You find another job. If you are good at what you do that's not a big problem. If you aint well there ain't helping you.
Admin
For the friendship book (not only for team leads):
– Jon Postel, RFC 761, January 1980, https://datatracker.ietf.org/doc/html/rfc761#section-2.10