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
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.
I wish the people that propagated that lovely SPOR style would all die. Just die. Look how convoluted that method is, and it does one thing. The following is fiction, but drat if it isn't what I look at almost every day:
code:
String assSmacker(String buttFlagellator)
{
    String retVal = null;

    if (buttFlagellator != null)
    {
        if (somethingElse())
        {
            // insert 50 lines
            retVal = whatever;
            // insert 30 lines
        }
        else
        {
            // insert 50 lines
            retVal = a_monkey;
            // insert 70 lines
        }
    }
    else
    {
        // insert 50 lines
        if (constipated())
        {
            // insert one million lines
            if (youreStillReadingThis != false)
            {   buttFlagellator = "butt";
                buttFlagellator += "butt";}
        }
        else
        {
            if (logger.isMaxDebugOn())
            {
                logger.debug("Ready to flow.");
            }
        }
    }

    if (retVal == null)
    {
        // insert your mom
        if (buttFlagellator != null)
        {
           retVal = buttFlagellator.toUpperCase();
        }
            else
            {
            if (logger.isMaxDebugOn())
            {
               logger.debug("buttFlagellator was null, skipping...");
            }
        }
    }

    return retVal;
}
Now imagine it in C++, where most of the developers don't seem to know that you can allocate things without using new and have never heard of auto_ptr

Mustach fucked around with this message at 19:16 on Aug 12, 2010

Adbot
ADBOT LOVES YOU

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

dancavallaro posted:

Don't tell that to whoever wrote that code, because he'll wrap every single line in his program with

code:
try {
   // everything!
} catch (OutOfMemoryError e) {

}
You never can be too careful!

Well you probably should gracefully handle OOM scenarios by reporting it. Although at the point you run out of heap I think the behaviour of the JVM becomes undefined.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

dancavallaro posted:

You never can be too careful!

Oh boy almost ran out of memory! Lemme just allocate a couple objects to deal with the probl-

king_kilr
May 25, 2007

Internet Janitor posted:

Oh boy almost ran out of memory! Lemme just allocate a couple objects to deal with the probl-

I don't know about Java, but CPython at least preallocated an OutOfMemory exception.

BigRedDot
Mar 6, 2008

Mustach posted:

I wish the people that propagated that lovely SPOR style would all die.
Weird I've never heard it called SPOR, and it took me a second to figure out what you meant. Back in my day I always saw it called it SESE for single-entry, single exit, but now that I think about it explicit multiple entry was already an anachronism even when I was in school 15 years ago. I suppose the concept is still around today hidden behind names like "continuation" and "generator".

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.
In that case, I'm going to claim all of the credit for that acronym. Single point of return / single-entry-single-exit is a disgusting fungus that rots code.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
SPOR is very close to "spoor" which is pretty much what that style is.

ErIog
Jul 11, 2001

:nsacloud:
I don't have code examples of this, but I thought some of you would enjoy my frustrations with this gem.

We are in the process of upgrading the overgrown CVS system that's used for our magazines. We lease this software and pay for maintenance on it. It's the backbone of everything important we do at our company. We pay a lot of money for this software. It's written in PHP.

I retrieve the provided upgrade materials from the developer's server. I begin to work through the upgrade portion of the admin manual. I make a copy of the production database to operate on in case something crazy happens. I get the software installed, and I hit the button to "Upgrade our Database." It chugs along spitting out all sorts of crazy drat warnings and errors about nearly every row in every table in the database. It finishes with a nice message, "Upgrade Successful."

I then run the included utilities to check the database structure and software environment, and it fails every drat test with very little detailed response about what exactly it's checking or is broken. So I start poking around in the database, and I notice evidence of coding horrors the likes of which I'd only ever heard rumors of.

The older versions of the software didn't define any primary keys or identity on any of the tables. In version 5 of their software they were still manually generating unique ID numbers to populate the tables with. They apparently fixed this in version 7, but neglected to make that process part of the upgrade script. So I manually fix the 20 or so tables in the database to bring them in line with how the database is supposed to be structured.

I then run the test utilities again. The system passes with flying colors, but is still utterly broken. I can't look at the test scripts to see what they're checking because they've been obfuscated with a DRM solution called ionCube. I've now decided that the use of ionCube is less about preventing people from stealing their code, and more about preventing people from seeing how poorly the drat thing is programmed.

I get on the blower with their support team about this, and they won't budge. We pay money for yearly maintenance that includes the cost of upgrades, but it somehow doesn't include the support time for them to install those upgrades. So we have to pay roughly 25% of the price we originally paid in order to have them install it. They say they never expected anyone to try to handle the upgrade themselves even though they're not building the installation costs into the prices, they give out the admin manual, and they give access to their FTP in order to download the software.

At this point they're just loving with their clients by giving them options that aren't real options. On the phone they kept reiterating, "we told you that the upgrade process was complicated." The truth is that it isn't complicated, it's broken in ways that only the maniac who coded it could possibly understand. I can deal with complicated, but completely and utterly broken isn't something I can deal with.

At this point I've lost all faith in the entire software industry. I don't consider myself a programmer, but even I am well-informed enough to recognize these sorts of coding horrors. This wasn't some sort of alpha version of their software. It was version 5. How do the people that do poo poo like this still have jobs? It makes me think I should put some time into becoming a programmer because it doesn't look like it would be too hard to compete with the abysmal status quo.

This is the third outside contractor in a row I've worked with that's given me back completely bullshit code. We contracted out a custom database app last year. It has all sorts of crazy loving bugs because the guy who wrote it can't bother to catch exceptions, scrub user input, and design database tables that aren't complete loving lunacy. We contracted out a custom archival system a year and a half ago. The company came very well-recommended. In month 8 of the project they come back to us with their own "custom developed" content management system that is complete bullshit that we never asked them to write in the first place.

I've been in so many meetings with contractors like this that I could create a buzz word bingo card of "software as a service," "we don't believe in pulling something off the shelf for our clients," "permission marketing," and "web 2.0." All of which are either meaningless or very serious negatives spun on their ear in order to sound like positives. I've taken to just writing these projects myself in-house because it doesn't appear I can find anyone I can trust to not do things in a completely hosed up broken way.

ErIog fucked around with this message at 21:20 on Aug 12, 2010

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
Niche markets tend to have REALLY poo poo programs because the top players are all "organically grown" solutions built by professionals in their fields trying their hand at playing computer programmer.

poo poo even low-to-mid sized e-commerce software is like this, I loving hate it.

ErIog
Jul 11, 2001

:nsacloud:

TRex EaterofCars posted:

Niche markets tend to have REALLY poo poo programs because the top players are all "organically grown" solutions built by professionals in their fields trying their hand at playing computer programmer.

poo poo even low-to-mid sized e-commerce software is like this, I loving hate it.

I'd always heard this and known this. I just didn't think it would be quite this bad. I could take a bug here or there. I could take some extra rigidity in the amount of customization allowed within the systems. It ends up being just really baffling stuff like applications developed on platforms they're completely not suited for.

There's a weird database app we use for advertising that would be a million times better as a web app. Yet, it's a Windows app that interfaces with an on-site database, and is completely broken because of it. Just getting reports out of it is a nightmare.

The magazine CVS app I talked about, meanwhile, was developed mainly as a web app despite the fact that 99% of the time 99% of users are going to be interfacing with it through custom plugins in Adobe CS. That's why they decided to develop it in PHP.

ErIog fucked around with this message at 21:27 on Aug 12, 2010

G-Dub
Dec 28, 2004

The Gonz

Markov Chain Chomp posted:

So it turns out that Cake Poker, a fairly major poker site, was using XOR encryption on everything and was found to have a couple of possible unaccounted for superusers on its site. When pressured about this issue, they advised players to make sure to only use wireless networks with WEP. :psyduck:

My god I used to love Cake Poker, but this does not surprise me at all!

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

ErIog posted:

I'd always heard this and known this. I just didn't think it would be quite this bad. I could take a bug here or there. I could take some extra rigidity in the amount of customization allowed within the systems. It ends up being just really baffling stuff like applications developed on platforms they're completely not suited for.

There's a weird database app we use for advertising that would be a million times better as a web app. Yet, it's a Windows app that interfaces with an on-site database, and is completely broken because of it. Just getting reports out of it is a nightmare.

The magazine CVS app I talked about, meanwhile, was developed mainly as a web app despite the fact that 99% of the time 99% of users are going to be interfacing with it through custom plugins in Adobe CS. That's why they decided to develop it in PHP.
Could probably plop a webservices/REST front end on it and it would be abstracted away. I've done that with lots of success when I needed to interface with a piece of poo poo from another piece of poo poo.

ColdPie
Jun 9, 2006

ErIog posted:

I can't look at the test scripts to see what they're checking because they've been obfuscated with a DRM solution called ionCube.

It always baffles me when companies build their entire business around a closed-source application which is actively hostile to its users. Someone at your company needs a stick through their eye and a pink slip for choosing that "solution."

Edit:

ErIog posted:

users are going to be interfacing with it through custom plugins in Adobe CS.

Pffffffhahahahahaha jesus get out of there while you're still sane.

ColdPie fucked around with this message at 22:30 on Aug 12, 2010

The Glumslinger
Sep 24, 2008

Coach Nagy, you want me to throw to WHAT side of the field?


Hair Elf
From a big project I worked on over the summer that has been in development for several years.

code:
URL[] urls=((URLClassLoader)cl).getURLs();

URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader();
	
		Method method;
		try {
			method = URLClassLoader.class.getDeclaredMethod("addURL",URL.class);
			method.setAccessible(true);
			for(int i=0;i<urls.length;i++)
			{
				URL u=urls[i];
				try {
					method.invoke(sysloader,new Object[]{u});
				} catch (a bunch of different exceptions){
                                // do stuff
		          }
			}
		} catch (other exceptions) {
                //do stuff
		}
I honestly can't tell if this is awesome hack or a terrible hack. Methods in the API have protection for a reason, but I couldn't get it to work the proper way of using the new Classloader to create the classes and invoke the main later. I need to put in some apologetic comments :smith:


Also, I found a unit test class that had all of the testing code commented out with an comment explaining that it was throwing errors so they just got rid of all the code since the class wasn't being used by anything else :psyduck:

The Glumslinger fucked around with this message at 01:33 on Aug 13, 2010

Munkeymon
Aug 14, 2003

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



http://stackoverflow.com/questions/1995113/strangest-language-feature/2038006#2038006

The third comment is part of the reason I hate PHP so much - so many people who use it have no goddamn clue. Also, the behavior is weird, but it's PHP so sane behavior would also be weird in a way.

MononcQc
May 29, 2007

I think I'm being trolled by employees long gone.

called by 'GetEmail($file)' inside 'lib/strings.php'...

php:
<?
function GetSpecialText($fname, $r = false) {
  if (!is_array($fname)) {
    $fd = @fopen($fname, 'r');
    if (!$fd) return false;
  } else {
    reset($fname);
  }
 
  while (!is_array($fname) ?
          ($line = fgets($fd, 4096)) :
          (list($k, $line) = each($fname))) {
    $line = str_replace("\r", '', $line);
    if (is_array($fname)) $line .= "\n";
 
    if ($line{0} == '#') {
      // Comment
      continue;
    }
    if ($line{0} == '@') {
      // Special tag:   @tag value\n
      $l = substr($line, 1);
      $l = ltrim($l);
      $p = strpos($l, ' ');
      if ($p === false) {
        // Error.. we ignore this line
        continue;
      }
      $tag = strtolower(substr($l, 0, $p));
      $value = trim(substr($l, $p));
      if (isset($o) && isset($o[$tag])) $o[$tag] .= "\n$value";
      else $o[$tag] = $value;
    } else {
      if (isset($o) && isset($o['body'])) $o['body'] .= $line;
      else $o['body'] = $line;
    }
  } // while
 
  if (!is_array($fname)) {
    fclose($fd);
  }
 
  // Remplacements
  if ($r) {
    reset($o);
    while (list($k, $v) = each($o)) {
      $o[$k] = replace_array($v, $r);
    } // while
  } // if ($r)
 
  return isset($o) ? $o : false;
} // GetSpecialText
?>
I wish svn blame would let me key someone's car doors

GROVER CURES HOUSE
Aug 26, 2007

Go on...
javascript:if([0]&&[0]==false){alert("welp")}

Opinion Haver
Apr 9, 2007

Broken Knees Club posted:

javascript:if([0]&&[0]==false){alert("welp")}

even better
if([0]){alert("this will evaluate");}
if([0] == false) {alert("so will this");}
if([0] == true) {alert("but not this");}

THE PLATFORM MASTER
Jun 3, 2008

crazylakerfan posted:

I honestly can't tell if this is awesome hack or a terrible hack. Methods in the API have protection for a reason, but I couldn't get it to work the proper way of using the new Classloader to create the classes and invoke the main later.

Haha, I just did this hack and also added some more that plants it firmly into the terrible category. Some Java packer places the majority of the class files in the default package so anything that references them also needs to be in the default package. Unfortunately, that code was also signed and only one cert can be used per package. My solution? Regexreflection!

code:
URLClassLoader cl = (URLClassLoader)ClassLoader.getSystemClassLoader();
Field package2certsF = ClassLoader.class.getDeclaredField("package2certs");
package2certsF.setAccessible(true);
Hashtable package2certs = (Hashtable)package2certsF.get(cl);

// load a signed jar with that addURL hack

Class.forName("..."); // force Java to load the classes I need to reference from the original package
package2certs.remove(""); // make Java forget the certificate it just loaded
Class.forName("..."); // force Java to load all my classes
package2certs.remove(""); // make Java forget the certificate for my code

GROVER CURES HOUSE
Aug 26, 2007

Go on...

yaoi prophet posted:

even better
if([0]){alert("this will evaluate");}
if([0] == false) {alert("so will this");}
if([0] == true) {alert("but not this");}

I just really like the one liner version. It's [0] is true, but also equals false?? :v:

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Broken Knees Club posted:

I just really like the one liner version. It's [0] is true, but also equals false?? :v:

It's "I don't understand javascript 101" [0] creates an array with one value, so by itself, it evaluates to TRUE, since it exists. When you do a compare, [0].valueOf() is done, and since it's a single element array, it returns that element: 0.

\/ it has it's :downs: moments for sure.

Lumpy fucked around with this message at 19:34 on Aug 15, 2010

Vanadium
Jan 8, 2005

In its defense, javascript 101 is somewhat retarded

GROVER CURES HOUSE
Aug 26, 2007

Go on...

Lumpy posted:

It's "I don't understand javascript 101" [0] creates an array with one value, so by itself, it evaluates to TRUE, since it exists. When you do a compare, [0].valueOf() is done, and since it's a single element array, it returns that element: 0.

I actually understand the reasoning behind it perfectly, but the expression is so bizarre and paradoxical that it kind of deserves to be in this thread.

NotShadowStar
Sep 20, 2000

Lumpy posted:

It's "I don't understand javascript 101" [0] creates an array with one value, so by itself, it evaluates to TRUE, since it exists. When you do a compare, [0].valueOf() is done, and since it's a single element array, it returns that element: 0.

\/ it has it's :downs: moments for sure.

This is almost on the level of Perl insanity, the only reason you'd need a bare [0] is if you're doing something Perl-retarded.

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
That's not the manner in which Perl tends to be retarded at all

Vanadium
Jan 8, 2005

What manner, unexpected type coercion shenanigans?

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

Vanadium posted:

What manner, unexpected type coercion shenanigans?

This is one of the most obvious specific examples of the general problem of trying to DWIM and failing, which would be Perl's characteristic fault to me. If I were feeling snarky, I might say that just about every instance of this - 'nancy typing', comma fuckery, the confluence of factors that necessitate the 'goatse operator', and all their friends - could have been fixed if the original Perl 6 concept of a cleaned-up Perl 5 had been done by about 2003, and the current Perl 6 implementation had been called something else, like Perl 7

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Mustach posted:

In that case, I'm going to claim all of the credit for that acronym. Single point of return / single-entry-single-exit is a disgusting fungus that rots code.
I was trying to figure out what you had cooking with the acronym too. I remember in college they rammed something down our throats like that where we could only return right at the end of things. What I thought particular worse was they were also anal about breaking out of loops. So you'd have to throw your terminal conditions in the loop construct and often deal with signal variables of some kind.

evensevenone
May 12, 2001
Glass is a solid.
I think it was a big deal in CS education in the 90s because people seemed to have really weird ideas about OO back then. So you still see it amongst people that were indoctrinated that way and never managed to figure out that the world wouldn't end and that everyone else isn't just being lazy. It's like your uncle that insists on warming the car up for 10 minutes before driving it.

crazyfish
Sep 19, 2002

Even worse than that was that I used to work on a project where the coding style required ENTER_FUNCTION() and EXIT_FUNCTION() macros on every method. Even if we wanted to instrument something with these, we could have used an AOP framework and did the whole thing in about 10 lines rather than the horrible code (and logging) diarrhea that ensued.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

crazyfish posted:

Even worse than that was that I used to work on a project where the coding style required ENTER_FUNCTION() and EXIT_FUNCTION() macros on every method. Even if we wanted to instrument something with these, we could have used an AOP framework and did the whole thing in about 10 lines rather than the horrible code (and logging) diarrhea that ensued.

We used to have this nonsense along with making sure we named each class with a public static String MODULE.

A good bit of civil disobedience, mixed with claiming control of the SVN repo and strategic layoffs got rid of that horse poo poo real fast.

GROVER CURES HOUSE
Aug 26, 2007

Go on...

crazyfish posted:

Even worse than that was that I used to work on a project where the coding style required ENTER_FUNCTION() and EXIT_FUNCTION() macros on every method. Even if we wanted to instrument something with these, we could have used an AOP framework and did the whole thing in about 10 lines rather than the horrible code (and logging) diarrhea that ensued.

I worked on one of these projects before. By the end, I filled around 15 pages of my notebook with diagrams and notes on the behavior of these loving things. On what planet does this poo poo ever make sense?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Rocko Bonaparte posted:

I was trying to figure out what you had cooking with the acronym too. I remember in college they rammed something down our throats like that where we could only return right at the end of things. What I thought particular worse was they were also anal about breaking out of loops. So you'd have to throw your terminal conditions in the loop construct and often deal with signal variables of some kind.

One of my profs went violently in the other direction, taking off style points unless every loop was an infinite loop where you break out of it somewhere (maybe multiple places) in the loop body. It was actually kinda useful because it can be more readable, and awesome because signal variables could be eliminated (their use was an even more egregious style violation).

Ogive
Dec 22, 2002

by Lowtax

Broken Knees Club posted:

I worked on one of these projects before. By the end, I filled around 15 pages of my notebook with diagrams and notes on the behavior of these loving things. On what planet does this poo poo ever make sense?

On the planet where they sacrifice actual progress for the appearance of progress.

w00tz0r
Aug 10, 2006

I'm just so god damn happy.
Just got my coworker to agree to let me build libraries out of a bunch of files that are used over multiple projects.

Rather than adding them to the projects, though, they've been pulled into seperate svn repositories, those svn repositories are checked out into the project folder, and then a single "foo.cpp" file has been added, which #includes all of the 20 odd files in question.

I think there is a very good possibility he's trying to troll me into quitting. This is going to be way more work than it needs to be.

Jerk Burger
Jul 4, 2003

King of the Monkeys

G-Dub posted:

My god I used to love Cake Poker, but this does not surprise me at all!
Isn't this an example of code awesome not code horror? To take advantage you either have subvert a single player's network to get that players cards, or have access to the servers (which the programmer might) and get every players cards.

shrughes
Oct 11, 2008

(call/cc call/cc)

amanvell posted:

Isn't this an example of code awesome not code horror? To take advantage you either have subvert a single player's network to get that players cards, or have access to the servers (which the programmer might) and get every players cards.

??? I am totally confused by this post.

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock

amanvell posted:

Isn't this an example of code awesome not code horror? To take advantage you either have subvert a single player's network to get that players cards, or have access to the servers (which the programmer might) and get every players cards.

Credit. Card. Numbers.

RoadCrewWorker
Nov 19, 2007

camels aren't so great

amanvell posted:

Isn't this an example of code awesome not code horror? To take advantage you either have subvert a single player's network to get that players cards, or have access to the servers (which the programmer might) and get every players cards.
Are you "the programmer" you're talking about?

Adbot
ADBOT LOVES YOU

Jerk Burger
Jul 4, 2003

King of the Monkeys

shrughes posted:

??? I am totally confused by this post.
From what I was reading on a poker forum investigating the problem, the 'encryption' was trivial to reverse if you could capture a players traffic. Part of the concern was that whoever set up this encryption either had no idea what they were doing, or deliberately used a dodgy scheme as they could get access to the traffic coming into the server.

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