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
Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I'm not going to tell you how to live your life, but rewriting a 3KLOC Java file containing 7 classes is probably not going to result in you needing to be hospitalized. As return0 says, it sounds like it's a little toy that you shouldn't try to mutate from prototype to production. Just write 2KLOC of better code now that you have it to work from.

Adbot
ADBOT LOVES YOU

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Bad coding page of the beast!
http://www.frightbytes.com/computerdemons/error666.html

DimpledChad
May 14, 2002
Rigging elections since '87.
Yay for weird/obsolete VCS! We use SVK, which is a clunky distributed VCS hacked on top of SVN via Perl scripts. It's been abandonware for several years. It's not absolutely horrible, but is missing a lot of features and has pretty sub-par documentation. Fortunately we're in the process of getting ready to switch to Git!

As far as coding horrors, I encountered this the other day in a daily rollup job. Was asked to figure out why it was taking hours to complete. Changed all the variable names etc.

php:
<?

  public function rollUpSomStuf(){
    foreach($this->rollup->getRollup() as $foo => $foo_rollup){ //aggregates a bunch of stuff from Mongo collection
      foreach($foo_rollup as $bar => $bar_rollup) {
        if($this->hasValid($bar)) { 
          $baz = $this->getbazFrombar($bar);
        } else { 
          //debug logging
        }
        foreach($bar_rollup as $frotz => $frotz_rollup) {
          foreach($frotz_rollup as $flim => $flim_rollup) { 
            foreach($flim_rollup as $flam => $flam_rollup) {
              foreach($flam_rollup as $doink => $doink_rollup) { 
                foreach($doink_rollup as $narf => $narf_rollup){ 
                   foreach($narf_rollup as $blargh => $blargh_rollup){
                    foreach($blargh_rollup as $spliff => $spliff_rollup){ 
                      foreach($spliff_rollup as $splorch => $splorch_total){
                        $this->mongoThingy->date = $this->date(); 
                        $this->mongoThingy->foo = $foo;
                        $this->mongoThingy->bar = $bar;
                        if($this->hasValidbar($bar)) { 
                          $this->mongoThingy->sprocket = $baz['sprocket'];
                          $this->mongoThingy->frotz = $baz['frotz'];
                          $this->mongoThingy->zergrush = $baz['zergrush'];
                          $this->mongoThingy->bazoom = $baz['bazoom'];
                          $this->mongoThingy->hyphy = $baz['hyphy'];
                        } else { 
                          $this->mongoThingy->frotz = $frotz;
                        }

                        $this->mongoThingy->flim = $flim;
                        $this->mongoThingy->flam = $flam;
                        $this->mongoThingy->doink = $doink;
                        $this->mongoThingy->narf = $narf;
                        $this->mongoThingy->blargh = $blargh;
                        $this->mongoThingy->spliff = $spliff;
                        $this->mongoThingy->splorch = $splorch;
                        $this->mongoThingy->crunk = $splorch_total;

                        $this->mongoThingy->insert();
                      }                  
                    }
                  }
                }
              }
            }
          } 
        } 
      }
    }
  }
?>

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I really appreciate the attention to fakename detail.

Doctor w-rw-rw-
Jun 24, 2008

Subjunctive posted:

I really appreciate the attention to fakename detail.

Is 'garply' not a common fourth placeholder name outside Berkeley? I thought it was missing that one.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I don't see "quux"- one of my old officemates got me in the habit of using it as a third metasyntactic variable after foo and bar.

Steve French
Sep 8, 2003

Internet Janitor posted:

I don't see "quux"- one of my old officemates got me in the habit of using it as a third metasyntactic variable after foo and bar.

Ugh it's foo, bar, baz, *then* quux I am surrounded by amateurs

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Baz is far too similar to bar which can lead to confusion as you can read about in my seminal paper (read: Wordpress post) "Baz Considered Harmful: Choosing the Right Metasyntactic Variables for your Web Framework or Whatever". Furthermore,

DimpledChad
May 14, 2002
Rigging elections since '87.
I'll admit that I forgot what comes after baz. I have seen frotz used though. The other ones were just whatever popped into my head. Of course even if I'd remembered every metasyntactic variable ever created, it might not have been enough in this case.

Internet Janitor posted:

Baz is far too similar to bar which can lead to confusion as you can read about in my seminal paper (read: Wordpress post) "Baz Considered Harmful: Choosing the Right Metasyntactic Variables for your Web Framework or Whatever". Furthermore,

"Is Baz an Anti-Pattern? Pseudovariable Best Practices for Agile Prototyping"

DimpledChad fucked around with this message at 05:46 on Nov 7, 2014

Xenoveritas
May 9, 2010
Dinosaur Gum

Subjunctive posted:

I'm not going to tell you how to live your life, but rewriting a 3KLOC Java file containing 7 classes is probably not going to result in you needing to be hospitalized. As return0 says, it sounds like it's a little toy that you shouldn't try to mutate from prototype to production. Just write 2KLOC of better code now that you have it to work from.

It's just annoying because at this point I've been waiting something on the order of two months for it to be delivered. (E: To clarify, it was supposed to be delivered two months ago after an original estimate of a couple of weeks. Now that it's 2 months behind schedule, discovering it's going to be a fairly major refactoring is somewhat annoying.) I finally get a 250MB ZIP file containing the code, a JAR containing a compiled version of that code and all its dependencies, and then all of its dependencies outside the JAR a second time for good measure. (Not even going to begin to guess why.)

However it contains such gems as:

Java code:
// Kmin and Kmax are ints.
int numTopics = 2*(int)Math.floor((double)Kmin + ((double)Kmax - (double)Kmin)/2);

// Later in same method

Integer Inte;

// Later in same method

Integer Int;

// Even later

Instance I;
This is why you shouldn't let mathematicians write code.

(To be fair, he's using Integer because they're keys in a hashmap. I have no clue whether or not this makes sense at this point in time.)

Xenoveritas fucked around with this message at 06:26 on Nov 7, 2014

Zopotantor
Feb 24, 2013

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

Steve French posted:

Ugh it's foo, bar, baz, *then* quux I am surrounded by amateurs

HEATHENS!

foo, bar, baz, zip, qux, quux, quuux, ...

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

Xenoveritas posted:

Java code:
// Kmin and Kmax are ints.
int numTopics = 2*(int)Math.floor((double)Kmin + ((double)Kmax - (double)Kmin)/2);

Can the number of topics only be even? The floor makes it equivalent to:
Java code:
int numTopics = Kmin + Kmax;
numTopics -= numTopics % 2;
He wrote , which most people would simplify to , so your mathematician probably isn't very good at math either...

Don Mega
Nov 26, 2005
I had the misfortune of working for the company that is responsible for this http://www.astm.org/search/js/fullsite-search.js?v54a

I'm a big fan of the block of code that nests ~12 levels located around line 1000.

Fun fact: all product pages (thousands) were generated by bash & perl scripts as separate html pages rather than having a single, dynamic page. This broke routinely.

Don Mega fucked around with this message at 07:07 on Nov 7, 2014

Qwertycoatl
Dec 31, 2008

The Laplace Demon posted:

Can the number of topics only be even? The floor makes it equivalent to:
Java code:
int numTopics = Kmin + Kmax;
numTopics -= numTopics % 2;
He wrote , which most people would simplify to , so your mathematician probably isn't very good at math either...

The "min + (max - min)/2" looks like he heard about how to take an average without integer overflow messing things up, but didn't really believe it so cast everything to doubles just in case.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
I used to use doh and blah as metasyntactic variables. At some point I switched to morbo, turbo, furbo. Now that I'm older and lazier, it's just a, aa, aaa...

TheresaJayne
Jul 1, 2011
Well i know of a true horror i have mentioned on here before
Article.java

200+ lines of imports
Cyclic complexity off the scale
and somewhere in the region if i recall correctly between 12k-15k lines

And only the system architects are allowed to make any changes.

sarehu
Apr 20, 2007

(call/cc call/cc)
foo, bar, baaz, khan, quux, bah, blah, are mine. Sometimes I use aa, bb, cc, etc.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I like arse and blep.

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!
If no one will ever see what I'm prototyping, I usually go with butts, lol, and what.

thathonkey
Jul 17, 2012
just started working with a new dev who is supposed to be really good. i mentioned most of us use sublime text or vim or some text editor like that and he starts telling me about how he uses an IDE and that unironically netbeans is the best one and also that text editors are for newbs. welp. project is doomed.

Mogomra
Nov 5, 2005

simply having a wonderful time

thathonkey posted:

just started working with a new dev who is supposed to be really good. i mentioned most of us use sublime text or vim or something text editor like that and he starts telling me about how he uses an IDE and that unironically netbeans is the best one and also that text editors are for newbs. welp. project is doomed.

I got tricked into using netbeans once.

It was fun working out how entire files that I didn't even touch turned into conflicts. Line endings or something. I don't know. It was bad.

Zorro KingOfEngland
May 7, 2008

The editor doesn't matter, but rather what you put into the editor that makes a true coding horror.

Space Kablooey
May 6, 2009


Nah, Netbeans is pure poo poo. Last night, my professor was walking us through some code on the projector and when he saved one of his files, Netbeans crashed. When he opened Netbeans up again, every time he selected the file, it would crash.

Then he decided to reboot the computer, and Deep Freeze took care of the rest.

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
C# code:
resultset.All(x => { x.StatusName = getCusTomPriceStateNameByCode(x.CustomPricingStateEnum); return true; });

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Jethro posted:

If no one will ever see what I'm prototyping, I usually go with butts, lol, and what.

Is it bad the first garbage variable name that always comes to me is fart?

o.m. 94
Nov 23, 2009

u should select metasyntactic variables based on the optimal hamming word distance from each other. Solving for n words left as an exercise for the reader

o.m. 94 fucked around with this message at 17:47 on Nov 7, 2014

Dicky B
Mar 23, 2004

asdf, wefwef and fffff

Polio Vax Scene
Apr 5, 2009



I just use every profanity I can think of. If I run out I start using the names of people I hate.

dwazegek posted:

C# code:
resultset.All(x => { x.StatusName = getCusTomPriceStateNameByCode(x.CustomPricingStateEnum); return true; });

I just sat here saying "gently caress gently caress gently caress. gently caress. what the gently caress. why. gently caress.".

Also, CusTom.

Munkeymon
Aug 14, 2003

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



asd, qwe zxc, lkj, poi are my go-tos in order of frequency.

If I'm mad I'll effort-type abusive names directed at whatever language, framework or buggy shitpile of software is pissing me off at the moment. I find it surprisingly cathartic.

thathonkey posted:

just started working with a new dev who is supposed to be really good. i mentioned most of us use sublime text or vim or some text editor like that and he starts telling me about how he uses an IDE and that unironically netbeans is the best one and also that text editors are for newbs. welp. project is doomed.

Their PHP editor was decent sometime around 2010. I can't remember if PHPStorm existed back then but it probably did and wasn't an option because the shithole I used to work in was allergic to spending money.

ToxicFrog
Apr 26, 2008


Described by a friend of mine in a codebase she inherited. This is not the exact code, but a dramatic reenactment based on her description.

Bash code:
#!/bin/bash

if [[ $1 == getpid ]]; then
  echo $PPID > /tmp/pid
  exit 0
fi

bash $0 getpid; PID=$(cat /tmp/pid)

# More, equally revolting code that uses $PID goes here.
This is basically "PID=$$", except horrible and it introduces a fun race condition.

No Safe Word
Feb 26, 2005

Munkeymon posted:

asd, qwe zxc, lkj, poi are my go-tos in order of frequency.

If I'm mad I'll effort-type abusive names directed at whatever language, framework or buggy shitpile of software is pissing me off at the moment. I find it surprisingly cathartic.
I thought this was only the purview of commit messages, didn't realize it also extended to variable names for some.

My commit examples
code:
non-merge down into main, there are no changes here, TFS is just stupid as heck

<snip other stuff> (BAD MERGE TFS BAAD)

rename <name of branch> BECAUSE OF PATH LENGTH LIMITATIONS AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
and then one magical night a few months back
code:
unfuck poo poo

Changeset #####   (default commit message)

Changeset #####

continual unfucking of poo poo

wfsadf

asdfasdfasdf


and then sort of the opposite, when a coworker of mine pointed out a silly bug:
code:
<name of coworker> is smarter than me, okay?

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

Manslaughter posted:

Also, CusTom.

The guy who wrote this is absolutely terrible when it comes to that sort of stuff, there are at least 5 different misspellings of CustomPricing in the entire change. Even in that tiny snippet there's an inconsistency between CustomPricing and CustomPrice.

Other stuff that we're (sometimes permanently) stuck with thanks to him: "GeneRatePassword", "PhoneNumberSerfvice", "PhonenUmberController", "DoProviosing", "ReferenceLonegerThen50".

He's also the only person on the entire team that insists on using lower-case method names for private functions. No big deal, it's just annoying that everyone adheres to a certain standard, and he consistently breaks it. On the plus side, I can tell that the code is going to be terrible before I see it, because I know he wrote it.

edit:
I just realized I started the post with "The guy who wrote this is absolutely terrible when it comes to that sort of stuff...", implying that he's not-terrible at other stuff, which isn't true. He's equally terrible at everything.

dwazegek fucked around with this message at 18:55 on Nov 7, 2014

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

No Safe Word posted:

I thought this was only the purview of commit messages, didn't realize it also extended to variable names for some.

My commit examples
code:
non-merge down into main, there are no changes here, TFS is just stupid as heck

<snip other stuff> (BAD MERGE TFS BAAD)

rename <name of branch> BECAUSE OF PATH LENGTH LIMITATIONS AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
and then one magical night a few months back
code:
unfuck poo poo

Changeset #####   (default commit message)

Changeset #####

continual unfucking of poo poo

wfsadf

asdfasdfasdf


and then sort of the opposite, when a coworker of mine pointed out a silly bug:
code:
<name of coworker> is smarter than me, okay?

I was making a site for a friend and using GitHub pages for it since he didn't have the permanent webspace up yet, and that requires a commit if you want to upload changes to the web, so all the experimenting resulted in a bunch of commits in a row:

code:
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaaaaaa
aaaaaaaa
aaaaaaaaa
ok it works now

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.

No Safe Word posted:

I thought this was only the purview of commit messages, didn't realize it also extended to variable names for some.

My commit examples
code:
non-merge down into main, there are no changes here, TFS is just stupid as heck

<snip other stuff> (BAD MERGE TFS BAAD)

rename <name of branch> BECAUSE OF PATH LENGTH LIMITATIONS AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
and then one magical night a few months back
code:
unfuck poo poo

Changeset #####   (default commit message)

Changeset #####

continual unfucking of poo poo

wfsadf

asdfasdfasdf


and then sort of the opposite, when a coworker of mine pointed out a silly bug:
code:
<name of coworker> is smarter than me, okay?
http://www.commitlogsfromlastnight.com/

substitute
Aug 30, 2003

you for my mum
I just wrote a small function yesterday that returns $rear end. I'm leaving it. :colbert:

The function argument was $arr so it seemed like a logical progression, sort of like iterators: i, j etc.

Which now, has me thinking I could just use famous asses for nonsense vars - Iggy, Jlo, Kim...

zergstain
Dec 15, 2005

HardDisk posted:

Nah, Netbeans is pure poo poo. Last night, my professor was walking us through some code on the projector and when he saved one of his files, Netbeans crashed. When he opened Netbeans up again, every time he selected the file, it would crash.

Then he decided to reboot the computer, and Deep Freeze took care of the rest.

Maybe I remembered it wrong, but I thought I preferred it to eclipse.

Xenoveritas
May 9, 2010
Dinosaur Gum
One more.

Java code:
public static boolean StringLexicographicallyGreaterThan(String S1, String S2) {
    // Returns true if S1 is lexicographically greater than S2 where the codepoint of each character is compared.
    // Returns false otherwise
So, uh, wait, how is this different than S1.compareTo(S2) > 0?

Java code:
    if (S1.length() > S2.length())
        return true;
    if (S1.length() < S2.length())
        return false;
Oh. I see.

BigRedDot
Mar 6, 2008

substitute posted:

I just wrote a small function yesterday that returns $rear end. I'm leaving it. :colbert:

https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/iterators.c#L960

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

Xenoveritas posted:

One more.

Java code:
public static boolean StringLexicographicallyGreaterThan(String S1, String S2) {
    // Returns true if S1 is lexicographically greater than S2 where the codepoint of each character is compared.
    // Returns false otherwise
So, uh, wait, how is this different than S1.compareTo(S2) > 0?

Java code:
    if (S1.length() > S2.length())
        return true;
    if (S1.length() < S2.length())
        return false;
Oh. I see.

What does it return if S1.length() == S2.length()?

On a somewhat similar note, I found this yesterday:
C# code:

private bool nullableDecimalEquals(decimal? d1, decimal? d2)
{
  if (d1 == null && d2 == null)
    return true;
  if (d1 == null)
    return false;
  if (d2 == null)
    return false;
  return d1.Value == d2.Value ? true : false;  
}

In case you're not familiar with .NET nullables, this gives the exact same results as the default equality comparer; I guess writing d1 == d2 was too easy.

Adbot
ADBOT LOVES YOU

Xenoveritas
May 9, 2010
Dinosaur Gum

dwazegek posted:

What does it return if S1.length() == S2.length()?

At that point it falls through and does what it says it does. Although it uses String.codePointAt(int) at each index instead of String.charAt(int) which I'm pretty sure is completely pointless because surrogate pairs are set up so that they'd sort lexicographically correctly even without being unpacked. But I'm willing to give that a pass as that involves knowing the difference between characters and code points.

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