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
fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
How about writing JSON by hand in Java instead of using a library? Why would anybody do this to themselves :(

Adbot
ADBOT LOVES YOU

Grazing Occultation
Aug 18, 2009

by angerbutt

ultra-inquisitor posted:

Wouldn't
code:
const string& str = fileNameGen->getFilename("blah");
delete &str;
work? This way you can return by reference which is faster than returning by value! :downs:

No. You can't delete a const pointer. You'd have to cast away the const-ness first.

Besides that, as Vanadium said: if I've got a const reference returned to me, I'm assuming that I don't need to manage it.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Grazing Occultation posted:

No. You can't delete a const pointer. You'd have to cast away the const-ness first.
Not true. See 5.3.5.2. (I'm assuming that you mean pointer-to-const, not const pointer [which would still be a valid delete target])

Mustach fucked around with this message at 22:48 on Dec 9, 2009

newsomnuke
Feb 25, 2007

Grazing Occultation posted:

Besides that, as Vanadium said: if I've got a const reference returned to me, I'm assuming that I don't need to manage it.
Of course, I was just questioning whether it was a "guaranteed" memory leak, which it's not AFAIK.

Lexical Unit
Sep 16, 2003

code:
std::complex<double> d = (0.0, 1.0); // why's it getting it backwards? Whatever.

1337JiveTurkey
Feb 17, 2005

I'm stuck at work diagnosing some build error that only happens on my system in a perl script somewhere under seven layers of antcall with some gratuitous javascript tossed in the middle.

edit: I forgot about the little bit which runs some taglet parser over an autogenerated buildfile.

1337JiveTurkey fucked around with this message at 03:44 on Dec 10, 2009

pseudopresence
Mar 3, 2005

I want to get online...
I need a computer!

Lexical Unit posted:

code:
std::complex<double> d = (0.0, 1.0); // why's it getting it backwards? Whatever.

This is a little gem of a horror :3:

BigRedDot
Mar 6, 2008

Fib posted:

This is a little gem of a horror :3:

Your tax dollars buy only the best.

Grazing Occultation
Aug 18, 2009

by angerbutt

Mustach posted:

Not true. See 5.3.5.2. (I'm assuming that you mean pointer-to-const, not const pointer [which would still be a valid delete target])

Hmmm. It seems you're right but I could've sworn otherwise. :)

Dietrich
Sep 11, 2001

My own horror from today.

I've got a Dictionary<Tuple<int, int>, CustomObject> which is used to represent a cell on a grid and the custom object that that cell is in charge of displaying a value from.

Hurr, I had never heard of Point before, I guess. Duh.

CanSpice
Jan 12, 2002

GO CANUCKS GO
Not really a coding horror but it's about codinghorror.com:

quote:

ugh, server failure at CrystalTech. And apparently their normal backup process silently fails at backing up VM images.

looks like 100% data loss. thanks.. crystaltech.. :(

you sort of assume your hosting company is competent. That's not a safe assumption in my experience.

looks like it's 100% internet search caches for recovery. Any tips on recovering images, which typically aren't cached?

I had backups, mind you, but they were on the virtual machine itself :( I am OK on post-text, getting the post images is much harder..
Spot the horror!

jandrese
Apr 3, 2007

by Tiny Fistpump
Failure to insure that your backup solution is actually working (by making a restore on a temporary server and verifying that everything made it intact) doesn't really qualify as a coding horror. Any backup software that silently fails is a coding horror though. That is the least appropriate place for a silent failure condition.

king_kilr
May 25, 2007

CanSpice posted:

Not really a coding horror but it's about codinghorror.com:
Spot the horror!

That he wasn't doing backups? (No, backups on *the same server* aren't backups).

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Dietrich posted:

My own horror from today.

I've got a Dictionary<Tuple<int, int>, CustomObject> which is used to represent a cell on a grid and the custom object that that cell is in charge of displaying a value from.

Hurr, I had never heard of Point before, I guess. Duh.

I had a moment like this the other day. I did an elaborate section of code to loop through an array, checking at every step if it was out of bounds, and resetting it to 0... with an if statement.

About a day after I submitted the code (it was an assignment) I realized that I could have reduced my code by half, and made it much more readable, by simply using modulo.

king_kilr
May 25, 2007

CanSpice posted:

Not really a coding horror but it's about codinghorror.com:
Spot the horror!

http://74.125.95.132/search?q=cache...lient=firefox-a

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!


quote:

If you're using Linux, it's something a lot like that. If you're using Windows, go f*ck yourself.
what a superburn, such sublime ownage coming out of Atwood in that post :rolleye:

HIERARCHY OF WEEDZ
Aug 1, 2005

Dijkstracula posted:

what a superburn, such sublime ownage coming out of Atwood in that post :rolleye:

you're a retard, he was quoting jwz, who *does* unequivocally own

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Panic! at the Fist Jab posted:

you're a retard, he was quoting jwz, who *does* unequivocally own
:suicide: So noted, though indeed, jwz's anti-M$$$ cheapshots do tend to grate on me, too.

It's not like it takes any special skill to come up with something like that.

Zhentar
Sep 28, 2003

Brilliant Master Genius

I love this comment:

Coding Horror commenter posted:

My backup strategy? I post my important data in base64-encoded little chunks in the comments on the blogs of people who actually take the necessary steps to backup their data.

U3VpdGNhc2UgY29tYmluYXRpb246IDEgMiAzIDQgNQ==
RS1tYWlsIHBhc3N3b3JkOiBwYXNzd29yZDE=

Kelson
Jan 23, 2005

jandrese posted:

Failure to insure that your backup solution is actually working (by making a restore on a temporary server and verifying that everything made it intact) doesn't really qualify as a coding horror. Any backup software that silently fails is a coding horror though. That is the least appropriate place for a silent failure condition.
Silently failing backups is, I've discovered, far more common than makes any sense if half the responsible folks were competent. Hell, NetBackup (amongst others) semi-regularly emails updates addressing silent backup failures... (at least they're aware of it, I guess)

jandrese
Apr 3, 2007

by Tiny Fistpump
Sadly, silent failure appears to be a very common feature in backup software. That's why it's so important that when you decide to change backup software that you go and test it first to discover exactly what happens when the backup fails and how the restore feature actually works (not what the manual says).

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"

Dijkstracula posted:

what a superburn, such sublime ownage coming out of Atwood in that post :rolleye:
Atwood runs everything on Windows and .NET, he loves Microsoft

Zhentar posted:

I love this comment:
This is, in hindsight, the best thing ever posted on codinghorror.com

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?

CanSpice posted:

Not really a coding horror but it's about codinghorror.com:


It's the internet self-correcting itself.

Space Kablooey
May 6, 2009


CanSpice posted:

Not really a coding horror but it's about codinghorror.com:
Spot the horror!

The fact that he was backuping his data on a VM image?

jandrese
Apr 3, 2007

by Tiny Fistpump
It's like a coding horror clown car. Just when you think you've seen them all, another one pops right out.

geeves
Sep 16, 2004

building an XPath query

code:
public String methodName(String tagString){
//tagString delmited by ";"
ArrayList<String> tagNames = processTagString(tagString);

for (int i = 0 i < tagNames.size(); i++) {
    // Set up filter string and add tags to array list
    String filterString = "";
    String queryString = "/jcr:root//content/foo";
    for (int j = 0; j < i; j++) {
        if (0 < j) {
            filterString += " and @cq:tags='" + tagNames.get(j) + "'";
        } else {
            filterString += "@cq:tags='" + tagNames.get(j) + "'";
        }
    }
    queryString += "[" + filterString + "] order by @cq:lastModified";
    return queryString;
}

}

geeves fucked around with this message at 03:23 on Dec 16, 2009

Presto
Nov 22, 2002

Keep calm and Harry on.
code:
int zero = 0;
int one = 1;
int four = 4;
int five = 5;
int nine = 9;
:psyduck: This occurs in several files, with different combinations of numbers. And there are occurrences of things like this:

code:
for (i = zero; i < 15; i++)
It's like someone heard that magic numbers in code were bad, so they just thought they'd name them all, and the most obvious name is of course the word for that number. Or maybe they were guarding against the day when the value of 4 changes.

TheSpook
Aug 21, 2007
Spooky!

Presto posted:

code:
int zero = 0;
int one = 1;
int four = 4;
int five = 5;
int nine = 9;
:psyduck: This occurs in several files, with different combinations of numbers. And there are occurrences of things like this:

code:
for (i = zero; i < 15; i++)
It's like someone heard that magic numbers in code were bad, so they just thought they'd name them all, and the most obvious name is of course the word for that number. Or maybe they were guarding against the day when the value of 4 changes.

Imagine what will happen if the value of 15 changes! Obviously, you have some future-proofing to do.

CanSpice
Jan 12, 2002

GO CANUCKS GO

TheSpook posted:

Imagine what will happen if the value of 15 changes! Obviously, you have some future-proofing to do.

And what if the definition of ++ changes? Better change everything to use a plusplus() function!

mr_jim
Oct 30, 2006

OUT OF THE DARK

Presto posted:

code:
int zero = 0;
int one = 1;
int four = 4;
int five = 5;
int nine = 9;
:psyduck: This occurs in several files, with different combinations of numbers. And there are occurrences of things like this:

code:
for (i = zero; i < 15; i++)
It's like someone heard that magic numbers in code were bad, so they just thought they'd name them all, and the most obvious name is of course the word for that number. Or maybe they were guarding against the day when the value of 4 changes.

This thread just came full circle.

Goreld
May 8, 2002

"Identity Crisis" MurdererWild Guess Bizarro #1Bizarro"Me am first one I suspect!"

floWenoL posted:

I love it when people try to post coding "horrors" and it backfires.

I think embedding *180/PI or /180*PI (or /PI/180 or *PI/180) everywhere is more of a coding horror than the cited code, which isn't a horror at all.


Am I the only person that stores the (PI/180) or (180/PI) part beforehand as a macro, define, variable, or whatever? I know that a nonretarded compiler should convert it into a multiplication operation, but I'm so used to avoiding unnecessary division at all costs that it's just a habit.

Also, I agree that a degreesToRadians() et al. function is a necessity if you're doing any graphics work. Maybe change it to degToRad() or something shorter, but the code quickly becomes unreadable if you don't do it.

As for pi, I always have to have pi, 2*pi, and pi/2 defined. I deal with shitloads of cosines/dot products and vector calculus so it's a necessity.

Steve French
Sep 8, 2003


My favorite part of this is where he demonstrates that he doesn't understand what a filesystem is:

fatwood posted:

Acronis does a lot of things, but most of all it's drive imaging software, a fancy GUI over the rsync command.

Avenging Dentist
Oct 1, 2005

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

Goreld posted:

Am I the only person that stores the (PI/180) or (180/PI) part beforehand as a macro, define, variable, or whatever? I know that a nonretarded compiler should convert it into a multiplication operation, but I'm so used to avoiding unnecessary division at all costs that it's just a habit.

Probably not, but that doesn't justify superstitious programming.

Presto
Nov 22, 2002

Keep calm and Harry on.

mr_jim posted:

This thread just came full circle.
Maybe it's the same guy. :aaa:

Forgot about this part too: double dzero = (double)0.0;

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender

Janin posted:

Please post more details about insane Japanese software, because this post right here is incredible.
I was asked to migrate a Japanese webapp from Sun to Linux. The webapp supported authentication, downloads, forums, and a support tracking system. They gave me access to the directory where all the code was kept, and I thought there was a mistake because there was only one file in it, a large Perl file. But there was no mistake. That single gigantic Perl file did everything. There were no other Perl files, HTML pages or templates. Every URL in the site would load that file and query parameters would tell it what to render.

:downsgun:

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
How big was the file?

Flobbster
Feb 17, 2005

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

minato posted:

I was asked to migrate a Japanese webapp from Sun to Linux. The webapp supported authentication, downloads, forums, and a support tracking system. They gave me access to the directory where all the code was kept, and I thought there was a mistake because there was only one file in it, a large Perl file. But there was no mistake. That single gigantic Perl file did everything. There were no other Perl files, HTML pages or templates. Every URL in the site would load that file and query parameters would tell it what to render.

:downsgun:

Oh man, I've been there except instead of a Perl script, it was a single Java servlet class that rendered every page based on query parameters, using huge blocks of System.out.println calls to dump the HTML.

First thing I did was throw that code out and replace it with a handful of JSP pages.

edit: This was the same project that had another Java application as the server back-end (the servlet was a student front-end), and used a message-passing scheme where each message was a different class that contained the message parameters. That's great, but instead of having an abstract base class for all the message types and having the message class implement its "do it" logic in a virtual method, there was a four-page long if/else if statement that did an instanceof test for each message type.

Flobbster fucked around with this message at 00:01 on Dec 19, 2009

king_kilr
May 25, 2007
Anyone here ever parsed psycinfo or scopus records (some medical bibliography format). I'm dealing with a code base for parsing them out, and it's a fracking clusterfuck. It's actually open source :(

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender

MEAT TREAT posted:

How big was the file?

I don't remember exactly, but it was huge, over 1MB.

Another Japanese coding horror. A long while ago there was a 3D file format designed for games. Each component of the file had a type (3D mesh, texture, animation data, etc) and each type had various bitfields that described attributes of that component ("flat/gouraud/textured shading", "anti-aliased", "has normal", etc) and these were meant to be used to indicate which "driver method" to use to handle that component.

But the way the libraries were set up, each combination of bit fields had to have its own driver method. So if you had a 3D mesh that was anti-aliased and another that wasn't, you couldn't just use a single driver method for both where you'd check the bitfield and flip the anti-aliasing on. You had to write two separate drivers. Multiply this by the many different bitfields and it meant that potentially it would be necessary to write 2^32 drivers.

So dumb.

Adbot
ADBOT LOVES YOU

Vinterstum
Jul 30, 2003

Goreld posted:

Am I the only person that stores the (PI/180) or (180/PI) part beforehand as a macro, define, variable, or whatever? I know that a nonretarded compiler should convert it into a multiplication operation, but I'm so used to avoiding unnecessary division at all costs that it's just a habit.

A nonretarded compiler would store that as a constant, actually. So yeah. Don't :). At least not for that reason.

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