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
Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

MrBishop posted:

I'd punch someone in the face if I had to maintain that. It's the code equivalent of, "Everything's ok...... NOT!!".

If everything is ok on opposite day, do this:

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Flobbster posted:

I don't know how good VB (compile) --> MSIL (decompile) --> C# would look

It still looks pretty good except for a few small problems like certain features of VB causing implicit declarations that got (maybe still get?) turned into stuff like $12AB = something; that doesn't compile if you just paste it into a code file because of the $.

I was in charge of obfuscating the build at the place I used to work and most obfuscaters I tried did a passable job of mangling the logic, but would usually gently caress up namespace resolution to produce code that crashed all over the place unless you excluded huge chunks of your project from obfuscation :v:

Nigglypuff
Nov 9, 2006


BUY ME BONESTORM
OR
GO TO HELL

Munkeymon posted:

I was in charge of obfuscating the build at the place I used to work
this is an irl job that people have :psyduck:

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Nigglypuff posted:

this is an irl job that people have :psyduck:

This would be the best job in the world.

Fenderbender
Oct 10, 2003

You have the right to remain silent.
code:
sub stringlength {
    my $string=$_[0];
    my $length;
    $string=$string . "*****";
    $length=index($string,"*****");
    return($length);
}
._.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Nigglypuff posted:

this is an irl job that people have :psyduck:

I was in charge of making an obfuscated build because I was in charge of the build because I was in charge of continuous integration. Obfuscation wasn't supposed to be a big deal because you're just supposed to be able to point the product we were using at the assemblies and tell it to go nuts, but it took days of tweaking settings in the obfuscater to get the obfuscated assemblies to not crash on startup. I never did get a fully functional, obfuscated build made while I was there. No, it was not fun. I think the product was Object Blender or something?

The SmartAssembly demo worked on the first try, but he had already bought the other piece of poo poo as a bundle with some pre-made Vista-like UI controls from the same company.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Fenderbender posted:

code:
sub stringlength {
    my $string=$_[0];
    my $length;
    $string=$string . "*****";
    $length=index($string,"*****");
    return($length);
}
._.

That's adorable

UserNotFound
May 7, 2006
???

rt4 posted:

What's this thing supposed to do?
Is the database itself as horrible as this query?

It's supposed to report on grad school application and acceptance statistics based on nearly every field of data imaginable. The previous programmer created them based on each departments needs, and I have decided it best to create a "general solution" that can be tailored through the UI by the departments, instead of requiring me to figure out what the hell this code is doing(wrong).

The copy/paste sequence that got it posted here may well have screwed up/pasted over itself at some point...my computer noticeably slowed down when I sent the whole query through jabber on Meebo... And no, I don't like the database any better, but at least I understand it.

ErIog
Jul 11, 2001

:nsacloud:

MrBishop posted:

I'd punch someone in the face if I had to maintain that. It's the code equivalent of, "Everything's ok...... NOT!!".

Wait. Is it? It's stupid and unclear, but it looks like it would work like it's supposed to. It should definitely be written 'status != OK,' but it's not throwing the error if the status is OK unless there's something I'm missing.

If the status is not OK then it returns a false on the check, inverts it to a true, and posts the "not OK." error.

If the status is OK then it returns a true on the check, inverts it to a false, and skips the error message.

ErIog fucked around with this message at 23:17 on Oct 2, 2009

Inverse Icarus
Dec 4, 2003

I run SyncRPG, and produce original, digital content for the Pathfinder RPG, designed from the ground up to be played online.

ErIog posted:

Wait. Is it?

He's not saying it's wrong, programatically. He's saying that it reads like what he said; It's the coding equivalent of "Everything's ok... NOT!"

It's rear end backwards for no reason, and quickly looking over the code is confusing.

code:
for(int i=0; !(i>=10); i++) { something(); }

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.

Munkeymon posted:

I was in charge of obfuscating the build

Well I hope this thread has taught you that it's far cheaper and far more effective to simply hire worse programmers.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Fenderbender posted:

code:
sub stringlength {
    my $string=$_[0];
    my $length;
    $string=$string . "*****";
    $length=index($string,"*****");
    return($length);
}
._.

:kiddo::hf::laugh:

MrBishop
Sep 30, 2006

I see what you did there...

Soiled Meat

Inverse Icarus posted:

He's not saying it's wrong, programatically. He's saying that it reads like what he said; It's the coding equivalent of "Everything's ok... NOT!"

It's rear end backwards for no reason, and quickly looking over the code is confusing.
This is exactly it. Most of the horrors I run across aren't bugs, they're just things that leave me asking wtf. Yesterday's, for example: My coworker wanted to return the number of items that had been processed in a method (in a C# project). Instead of just keeping a count as he iterated through the list of items (or, you know, just call list.Count), he decided to query the database to count the inserted records.

MrBishop fucked around with this message at 18:14 on Oct 3, 2009

Zombywuf
Mar 29, 2008

MrBishop posted:

This is exactly it. Most of the horrors I run across aren't bugs, they're just things that leave me asking wtf. Yesterday's, for example: My coworker wanted to return the number of items that had been processed in a method (in a C# project). Instead of just keeping a count as he iterated through the list of items (or, you know, just call list.Count), he decided to query the database to count the inserted records.

Sound like a race bug in waiting to me.

ErIog
Jul 11, 2001

:nsacloud:
As a former horror coder, I think I can explain the faulty reasoning of not keeping a count during the loop. Novice coders can find the logic of iterations confusing, and can be paranoid of off by one errors. Instead of thinking through the iterating code properly, they look to some outside way of keeping track because they don't trust their own code.

I can't really blame them, but they tend not to do even that part properly.

I had a hell of a time wrapping my head around the proper for loop in the case of iterating over a sequence in C. Thankfully, I program mostly in Python now where I don't have to think about it. I can do it in C, but it takes me a few extra seconds to think about what I'm doing.

ErIog fucked around with this message at 21:39 on Oct 3, 2009

ColdPie
Jun 9, 2006

ErIog posted:

As a former horror coder, I think I can explain the faulty reasoning of not keeping a count during the loop. Novice coders can find the logic of iterations confusing, and can be paranoid of off by one errors. Instead of thinking through the iterating code properly, they look to some outside way of keeping track because they don't trust their own code.

I can't really blame them, but they tend not to do even that part properly.

I had a hell of a time wrapping my head around the proper for loop in the case of iterating over a sequence in C. Thankfully, I program mostly in Python now where I don't have to think about it. I can do it in C, but it takes me a few extra seconds to think about what I'm doing.

The best way to fix off-by-one errors is to just randomly change loop conditions until it stops crashing.



P.S. anyone hiring?

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

ColdPie posted:

The best way to fix off-by-one errors is to just randomly change loop conditions until it stops crashing.

P.S. anyone hiring?

No, the correct way is to just never use arrays. Instead of declaring an array like a[10], declare separate variables a0, a1, ..., a9 and unroll the loop. Then, if you ever mess up your bounds and do something like a10, it gets flagged at compile time as an error.

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!
The correct way to fix crashes caused off-by-one errors in loops involving arrays is to make every array one element larger than it needs to be
This advice was in Code Complete, so you know it's good

RussianManiac
Dec 27, 2005

by Ozmaugh
Who the hell still has problems with off by one errors in loops and still work in the industry?

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
Can't you just do a foreach or use the array length as a variable when iterating?

TheSleeper
Feb 20, 2003

Ensign Expendable posted:

Can't you just do a foreach or use the array length as a variable when iterating?

Not every language has foreach and using the array length doesn't prevent you from doing something like for(int i = 1; i <= arraylength; i++) in C++ because you're retarded and don't know/think about the fact that C/C++ arrays are indexed from 0 to n-1.

edit:
vvvvv sorry, I got lost in the comment above about being a "former horror coder" and "being able to do it in C but it takes a second to think" vvvv

TheSleeper fucked around with this message at 08:25 on Oct 5, 2009

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
The context for this was originally C#

UraniumAnchor
May 21, 2006

Not a walrus.

RussianManiac posted:

Who the hell still has problems with off by one errors in loops and still work in the industry?

In my last job the 'big boss' checked in a piece of code that was k<=30 instead of k<30 and caused some 3rd-level damage. That one was fun to track down.

Mikey-San
Nov 3, 2005

I'm Edith Head!

UraniumAnchor posted:

In my last job the 'big boss' checked in a piece of code that was k<=30 instead of k<30 and caused some 3rd-level damage. That one was fun to track down.

Does the 'big boss' not like to have other engineers review his changes before committing?

Opinion Haver
Apr 9, 2007

UraniumAnchor posted:

In my last job the 'big boss' checked in a piece of code that was k<=30 instead of k<30 and caused some 3rd-level damage. That one was fun to track down.

What exactly does '3rd-level damage' mean?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

yaoi prophet posted:

What exactly does '3rd-level damage' mean?

When the epidermis is lost with damage to the subcutaneous tissue?

1337JiveTurkey
Feb 17, 2005

yaoi prophet posted:

What exactly does '3rd-level damage' mean?

Sounds to me like it had effects which showed up several modules away from the original cause of the problem. Like a classpath error in one module being traced back to a Kodo error which was caused by yet another module failing to deploy because of what ultimately amounts to the clustering configuration referring to a host that doesn't resolve.

UraniumAnchor
May 21, 2006

Not a walrus.

Mikey-San posted:

Does the 'big boss' not like to have other engineers review his changes before committing?

He was one of those 'I know the best way and will not be persuaded otherwise' people. Also one of those 'reinvent the wheel because the standard wheels are all terrible' people. In general he was a pretty good coder, but he was annoying as hell to work under.

yaoi prophet posted:

What exactly does '3rd-level damage' mean?

In this context, it means that a bad pointer causes another pointer to get scribbled on (instead of crashing right away), and when that second pointer later gets dereferenced, it causes a crash because it's bad. But the crash originates in code that didn't cause the actual damage. 2nd-level damage.

In this case that second pointer didn't cause a crash, but overwrote ANOTHER pointer, which finally caused a crash in some utterly unrelated module from the k<=30 piece, hence 3rd-level.

Continue as many times as you like. nth-level damage.

UraniumAnchor fucked around with this message at 23:25 on Oct 4, 2009

biznatchio
Mar 31, 2001


Buglord
Hey as long as we're making up terminology I'd like to suggest that we call it 'flobertyfloo' instead.

To be used as in "Man, Bob checked in a bad change and due to our widespread lack of error checking across our entire codebase I spent all week tracking down flobertyfloo."

Or "Wow it's really terrible that no input validation was taking place, or else the flobertyfloo that cost us a million dollars in downtime might have been avoided."

Mikey-San
Nov 3, 2005

I'm Edith Head!
Yeah, most people just call that a memory stomper or something, 'cause that's the only important part. This "n-level damage" thing sounds like how Ulillillia would describe a bug.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Mikey-San posted:

Yeah, most people just call that a memory stomper or something, 'cause that's the only important part. This "n-level damage" thing sounds like how Ulillillia would describe a bug.

UraniumAnchor's name also starts with U, trap sprung

But yeah, once you've accessed the first invalid pointer, everything else that happens after that enters undefined behavior no-man's-land, so trying to denote the depth of accesses that it takes for something to actually break with a visible effect is a pointless exercise.

Sounds like your boss needs to use the cool diagnostic checked pointer library that I developed for our students to use when we teach them C++.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Flobbster posted:

But yeah, once you've accessed the first invalid pointer, everything else that happens after that enters undefined behavior no-man's-land, so trying to denote the depth of accesses that it takes for something to actually break with a visible effect is a pointless exercise.

At what level do demons fly out your nose?

MrBishop
Sep 30, 2006

I see what you did there...

Soiled Meat

Avenging Dentist posted:

At what level do demons fly out your nose?

9th?

Anyway, on the topic of loops.... Was looking into why one of our web pages was running so slowly, ran across this gem.

code:
/// <summary>
/// Gets the record id of the location we're viewing on the page, which gets used
/// in dozens of places.
/// </summary>
private long LocationId
{
    get
    {
        LocationCollection col = LocationCollection.Create(true);
        foreach (Location loc in col)
        {
            if (loc.UserName.ToLower() == UserName)
            {
                // Set a bunch of class variables here.
                // Oh, and keep looking through the collection of hundreds 
                // of locations for no reason whatsoever.
            }
        }
        return _locationId;
    }
}

UraniumAnchor
May 21, 2006

Not a walrus.

biznatchio posted:

Hey as long as we're making up terminology I'd like to suggest that we call it 'flobertyfloo' instead.

To be used as in "Man, Bob checked in a bad change and due to our widespread lack of error checking across our entire codebase I spent all week tracking down flobertyfloo."

Or "Wow it's really terrible that no input validation was taking place, or else the flobertyfloo that cost us a million dollars in downtime might have been avoided."

http://catb.org/jargon/html/S/secondary-damage.html

I mean I guess you could say that the jargon file isn't a dictionary but I didn't pull this out of thin air.

Trabisnikof
Dec 24, 2005

UraniumAnchor posted:

http://catb.org/jargon/html/S/secondary-damage.html

I mean I guess you could say that the jargon file isn't a dictionary but I didn't pull this out of thin air.

As yes, Secondary Damage is caused by a Fandango on core. Duh.

floWenoL
Oct 23, 2002

Trabisnikof posted:

As yes, Secondary Damage is caused by a Fandango on core. Duh.

Haha, yes. I wouldn't take terminology advice from ESR, personally.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
It doesn't even exist in the real Jargon File, just the bizarro ESR version.

HFX
Nov 29, 2004

pokeyman posted:

What does what you said have anything to with what you quoted?

Just that many languages such as C / Java are utterly terrible about making you constantly declare a rather low level when it would be better off to give you something high level and then have a low level if you need it.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

HFX posted:

Just that many languages such as C / Java are utterly terrible about making you constantly declare a rather low level when it would be better off to give you something high level and then have a low level if you need it.

I'm glad you're not a coworker.

Adbot
ADBOT LOVES YOU

HFX
Nov 29, 2004

Avenging Dentist posted:

I'm glad you're not a coworker.

Awesome.

I write for my needs. Often times, this does mean using C, C++, Java. However, I've also realized how much time I waste coding for them. This is especially true when you realize that static type inferring functional languages are often more then fast enough without making you think about the small details when they aren't necessary.

HFX fucked around with this message at 08:25 on Oct 5, 2009

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