Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Missing "FileNotFound" and "{CompanyName}Yes"

Adbot
ADBOT LOVES YOU

Macichne Leainig
Jul 26, 2012

by VG

Bruegels Fuckbooks posted:

Missing "FileNotFound" and "{CompanyName}Yes"

My favorite, the 4-state boolean.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Macichne Leainig posted:

My favorite, the 4-state boolean.

This is why you model booleans as varchar in databases, so you can have

Y = Yes,
N = No,
Z = CompanyYes,
F= FileNotFound

etc.

Absolutely brilliant future-proofing.

Foxfire_
Nov 8, 2010

Hammerite posted:

Thank god it's documented what each value means
I've written stuff like that when I've had a lint rule to issue warnings on undocumented enum values, and writing the stupid comment is less ugly and easier than suppressing it for those particular lines

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Foxfire_ posted:

I've written stuff like that when I've had a lint rule to issue warnings on undocumented enum values, and writing the stupid comment is less ugly and easier than suppressing it for those particular lines

Hammerite posted:

love to see a library in which every property accessor has a documentation string that says either "gets the value of the Foo property" or "sets the value of the Foo property" as though that were helpful to anyone, clearly solely because there is some policy saying that every method and property accessor is required to have a documentation string so they can claim they reach some documentation target

perhaps if you have a rule or policy that says everything has to have documentation, and that rule or policy can be satisfied on paper by writing documentation that is obviously totally and utterly useless, that rule or policy is not actually worth imposing or enforcing

QuarkJets
Sep 8, 2008

Hammerite posted:

love to see a library in which every property accessor has a documentation string that says either "gets the value of the Foo property" or "sets the value of the Foo property" as though that were helpful to anyone, clearly solely because there is some policy saying that every method and property accessor is required to have a documentation string so they can claim they reach some documentation target

This person was trying to pad the size of their commits. Are we sure this isn't the Twitter codebase post-Elon?

QuarkJets
Sep 8, 2008

Foxfire_ posted:

I've written stuff like that when I've had a lint rule to issue warnings on undocumented enum values, and writing the stupid comment is less ugly and easier than suppressing it for those particular lines

Modify the linter to disable that rule

And if it's an open source linter then open a pull request to permanently delete that rule because it is an abomination

yippee cahier
Mar 28, 2005

Hammerite posted:

love to see a library in which every property accessor has a documentation string that says either "gets the value of the Foo property" or "sets the value of the Foo property" as though that were helpful to anyone, clearly solely because there is some policy saying that every method and property accessor is required to have a documentation string so they can claim they reach some documentation target

sometimes it’s easier to tell your IDE to autogenerate a doc block instead of arguing in a pull request about how confusing a member function called “encodeToBuffer” that takes one parameter called “buffer” really is.

QuarkJets
Sep 8, 2008

biznatchio posted:

That's the beauty of it. If it's not written down as a requirement then you still absolutely shouldn't be changing the logic during a refactor!

The logic was broken, preserving broken logic is unnecessary

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Hammerite posted:

love to see a library in which every property accessor has a documentation string that says either "gets the value of the Foo property" or "sets the value of the Foo property" as though that were helpful to anyone, clearly solely because there is some policy saying that every method and property accessor is required to have a documentation string so they can claim they reach some documentation target

A genuine thing I found in a former employer's web app:

code:
// Increment the view count
$view_count++;
But the insane block of line noise that was responsible for parsing and evaluating template expressions? Not a single goddamn comment.

Bongo Bill
Jan 17, 2012

Variable names are comments.

biznatchio
Mar 31, 2001


Buglord

QuarkJets posted:

The logic was broken, preserving broken logic is unnecessary

As mentioned above, literally none of the people involved in the refactor said anything about the logic being incorrect. The change was presented as being based entirely on a guess by someone who had no idea what the code was for.

And as also mentioned above, even if the logic was wrong, you shouldn't mix refactoring with functional changes.

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

biznatchio posted:

As mentioned above, literally none of the people involved in the refactor said anything about the logic being incorrect.

The Transcript posted:

1:18 here's a piece from some sales analysis
1:21 code that has been causing trouble ever
1:22 since it was written
1:24 at a casual glance it looks harmless
1:26 enough
1:27 but it's typical of the rest of the code
1:29 in this program a program that hasn't
1:31 worked right since the programmer quit
1:33 two years ago

qsvui
Aug 23, 2003
some crazy thing
I think he meant the logic about that particular line. He's right, none of the people in the video even implied there was a bug there. They clearly didn't know why the logic was like that, so the safer thing to do was leave it be.

I don't even know why the video even mentioned that the code was buggy because they didn't say whether the bug was fixed or not by the end.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

qsvui posted:

I think he meant the logic about that particular line. He's right, none of the people in the video even implied there was a bug there. They clearly didn't know why the logic was like that, so the safer thing to do was leave it be.

I don't even know why the video even mentioned that the code was buggy because they didn't say whether the bug was fixed or not by the end.
There's supposed to be multiple parts, so the bug was inside us all along.

biznatchio
Mar 31, 2001


Buglord

qsvui posted:

I think he meant the logic about that particular line. He's right, none of the people in the video even implied there was a bug there. They clearly didn't know why the logic was like that, so the safer thing to do was leave it be.

I don't even know why the video even mentioned that the code was buggy because they didn't say whether the bug was fixed or not by the end.

There's also that, unless you contrive very specific requirements, the change they made to the line won't actually fix what they guess the intended behavior is supposed to be; and if the system is a fixed-point system (which is a possibility considering the pseudo-language is based on COBOL and Fortran), would in fact make the code more wrong.

They suppose "well this condition is 'less than 25%' so this condition should just be 'less than 1/3rd'". If we assume they guessed correct and that's what the logic should actually be, then the change they made does not actually make the code do that comparison -- regardless of whether the underlying system is fixed-point or floating-point -- because .33 is already lower than 1/3rd; and changing the operator doesn't *make* it 1/3rd.

But it *does* suddenly mean that 0.33 exactly (which is only possible in fixed-point) would not match the condition, when it should because 0.33 exactly is less than 1/3rd but they just added it to the set of values that will incorrectly fail the condition. There's a test case right there that would have passed pre-change and failed post-change.

And in either case, with the change or without the change, values that mathematically would calculate out to >0.33 and <(1/3) -- for example 0.332 (which is >0.33 in floating point comparisons; and rounds to 0.33 in fixed point scale 2) -- would fail the check even though by the presumed logic they should pass it. (Well they'd have passed pre-change fixed-point, but failed post-change fixed-point; but they also fixed >=(1/3) to <0.335 failing pre-change fixed-point but passing post-change fixed-point, so let's call that a wash.)

So at best (floating-point) they failed to fix the supposed defect. At worst (fixed-point) they failed to fix the defect and introduced a regression.

biznatchio fucked around with this message at 09:37 on Dec 31, 2022

QuarkJets
Sep 8, 2008

I bet this code has lots of unit tests

Bongo Bill
Jan 17, 2012

What they did is make the code more fixable.

Ranzear
Jul 25, 2013

QuarkJets posted:

Modify the linter to disable that rule

For decades nobody could be assed to change their IDEs to display four space tabs instead of eight (or two if they personally preferred!)

Now you expect them to change linter settings, lmao.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.
It's worth noting the end-goal of the video is not how to refactor or troubleshoot code (presumably that would be in another video where they find the real bug), but how to write your code to avoid this sort of error-prone process in the first place. It's obviously contrived since nobody's gonna look at "rr" and immediately guess what it is, every interpretation could be wrong and they don't know it.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Hammerite posted:

love to see a library in which every property accessor has a documentation string that says either "gets the value of the Foo property" or "sets the value of the Foo property" as though that were helpful to anyone, clearly solely because there is some policy saying that every method and property accessor is required to have a documentation string so they can claim they reach some documentation target

and nothing anywhere in any documentation or comment that explains what Foo means

Nalin
Sep 29, 2007

Hair Elf
They went about this the wrong way. Both should have been changed to less-than-equal-to.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Nalin posted:

They went about this the wrong way. Both should have been changed to less-than-equal-to.

0.33 should have changed to 1.0/3

Soricidus
Oct 21, 2010
freedom-hating statist shill
They should just have rewritten the whole thing in algol

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Soricidus posted:

They should just have rewritten the whole thing in algol

Jensen device FTW.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
The soviets used a pencil

Carbon dioxide
Oct 9, 2012



Thanks Microsoft.

Xarn
Jun 26, 2015
I miss STL's cat examples.

Apex Rogers
Jun 12, 2006

disturbingly functional

The examples are ridiculous but it seems a bit sus to pass this by value in the first place. I guess it’s good for hot paths or something, just seems like a footgun going forward

Xarn
Jun 26, 2015
sufficiently small struts perform better when passed by value, because avoiding potential for aliasing makes it simpler for the optimizer to reason about

Carbon dioxide
Oct 9, 2012

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

The only reason I could think of doing it this way is if you are perversely proud of this hack and want to get asked about it. It's software exhibitionism.

QuarkJets
Sep 8, 2008


lmao software engineers need to be subject to licensing requirements

redleader
Aug 18, 2005

Engage according to operational parameters

QuarkJets posted:

lmao software engineers need to be subject to licensing requirements

also language designers, honestly

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Bruegels Fuckbooks posted:

The only reason I could think of doing it this way is if you are perversely proud of this hack and want to get asked about it. It's software exhibitionism.

Obfuscation contest for the language.

Ranzear
Jul 25, 2013

Says way too much about Go when someone uses such a dirty hack of templating and unicode abuse to replicate basic Rust behavior.

Or worse, it really is based on ye olde Java templating.

QuarkJets
Sep 8, 2008

If they had just used the word "precompiler" it'd be considered perfectly normal

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

QuarkJets posted:

If they had just used the word "precompiler" it'd be considered perfectly normal
Yes, having to insert Aboriginal characters would then be completely acceptable

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?
Unicode was a mistake

Adbot
ADBOT LOVES YOU

QuarkJets
Sep 8, 2008

Sagacity posted:

Yes, having to insert Aboriginal characters would then be completely acceptable

You mean having the *privilege* of inserting Aboriginal characters

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply