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
UberJumper
May 20, 2007
woop
So at my work we use an internal software, called cataloguer. It takes in a single file or folder and a metadata file, that contains a whole bunch of information about the file or folder. Then writes this information to an Oracle server.

Simple right? Well the guy who developed it, left around a year ago. The whole software is only about... 250k lines of C code. The code has 0 comments, and all the variable names have no vowels. And are generally abbreviated, if there is something already with the same abbrevated name. Then he adds a number next to it. So lets say:

buffer becomes! bffr then instead of using lets say a DIFFERENT loving NAME, he uses, bffr001 further away. Now okay, so we just need to make a small change... right? So we shouldnt have to mess with the code.

:suicide:

Theres alot of wonderful hex address attached to variables, and a little bit of ASM code here and there. Why are we doing (void ***)rspu.sttmnt = {0, 0, 0, 0, 0, 1, ........ } What the :suicide:

I dont know what that does. Period. Okay whatever. Huh, looks like thats supposed to be the SQL statement you want to execute, i'm confused. The statement, is an array of, unsigned ints...? :gonk:

Well thats retarded, we should just see how this connects to the SQL server, i guess and write some sort of workaround.

Then we all realized. What SLCT_OFFST = "0x0fb8d2b" does. We realized why we need to install the specific build of the oracle client(7i)...

The system, basically reads the username and password from a plain textfile, starts the oracle client GUI software. Does a shitton, of random memory hacks, and injects the SQL statement we want into the client interface and then it shoves it on the SQL server. I don't know who this man was, but he is a horrible horrible jerk.

:suicide: :suicide: :suicide:

We're upgrading to Oracle 11, in two weeks, and the whole work environment rests on this software. This is why the software does extremely werid poo poo, when i try to run it using oracle 11 and just doesn't work. We can't push back the deadline, and i know its our fault. But gently caress.

Adbot
ADBOT LOVES YOU

UberJumper
May 20, 2007
woop
On friday i was asked to update a small internal app, all it needed was a few little changes, maybe a weeks of work. A coop student wrote this, about 5 years ago in Java.

What the gently caress...?

A small snippet of a function:

code:
            int k1 = a(i1, j1);
            b(l1, k1, j1 + 1);
            k1 = c(i1, j1);
            b(l1, k1, j1 + 1);
            k1 = i1 - 1;
            b(l1, k1, j1);
            k1 = i1 + 1;
            b(l1, k1, j1);
            int j2 = j1;
            int i2 = i1;
            d d1 = this;
            d1 = a(i2, j2);
            b(l1, d1, j1 - 1);
            j2 = j1;
            i2 = i1;
            d1 = this;
            d1 = c(i2, j2);
            b(l1, d1, j1 - 1);
            return;
:smithicide:

The name of that function is a

0 Comments. FML.

UberJumper
May 20, 2007
woop
I think the old coop student (who will become a wind-chime soon) didn't use a decompiler. I looked a bit into java Decompilers, but from my understanding is that in java it will return the original functions names, etc. It also keeps comments :confused: Also this code, has sprinkles of names that, are slightly more descriptive. There is just random blobs of BS code like this(its almost all BS code).

I don't quite understand how this works, the vast majority of the code though. To me, this shouldnt work, gently caress i dont even know why it works.

I dug around and looked at b.

Theres two b's

First:

code:
public final double b(int i1)
{
	//Todo: 
	return new Double(22D + ((double)i1 * t[1]).doubleValue();
}
Now. Can anyone see at least two things that make this some sort of coding horror?

code:
public final void b(int i1, int j1)
{
	//RET CODE
	boolean RET = true;
	//access
	int k1 = PROC[l1].FIRST;
	int l1 = PROC[l1].SECOND;
	//WORKS
	if(PROC[j1].s > 22D || j1 < k1)
	{
		k1 = ag.FIRST;
		l1 = ag.SECOND;
	}
	if(i1 <= k1 - (int)60D || j1 >= l1 + (int)60D)
		RET = true;
	
	if(RET)
	{
		l1 = b(l1);
	}
}
Okay okay.

I don't understand.... Would this function even change anything? Aside from manipulating the global RET value(even though it can never be false here.).....

:confused:

The comments are the most descriptive ever. I love my job.

:suicide:

UberJumper
May 20, 2007
woop

McGlockenshire posted:

But... if it's being created as a double, why is he immediately casting it to an int? And since when have primitive non-decimal numbers been anything but ints? This assumes that the coder thought of this. This code makes my head hurt.

Thats what i am wondering, its full of litttle things that have enough little things (random comments, including one about subtle anal sex :confused:) to make me think it wasnt decompiled. I think it was done as a gently caress you kind of thing.

Anyways im working on this today so i'll see if i can find function c

UberJumper
May 20, 2007
woop
Yeah so i found the other b function, it was buried. I showed my boss some stuff, and basically told him its FUBAR. I don't think its been run through a code obfuscator, since half of the code can make sense, otherwise its the most ambitious/random obfuscator, i have ever heard of or seen.

The update (which is to add a little bit more functionality to it) has been put on hold :woop:. But i love this, so i will keep digging when i have time :)

Function B:

(this is pretty much all unmodified, i changed the employee name written in the code though)

code:
public final void b(WrapperFIXED_A l1, WrapperFIXED_B l2, int l3)
{ 
	WrapperFIXED_C cWRAP = NULL;
	if(l2 == null)
	{
		// Roger wanted me to make sure that this cant happen if it does anyways
		String checkIT = new String(l1.VALUE())
		if(checkIT == NULL)
		{
			throw RuntimeException("CRTIAL ERROR! THIS CANNOT HAPPEN!!!!!");
		}
		// MAKE SURE
		else if(checkIT != NULL)
		{
			return;
		}
		else
		{
			return;
		}
		return;
	}
	// Gte rid of stupid roundin
	if(l1.CALC((double)l3 * 0.1000001D) < 40D)
	{
		//TOTAL
		//Reason 
		for(l3 = 0; l3 < 10; l3++)
		{
			l1.a += (new Double(l1.CALC((double)l3 * 0.1000001D)).doubleValue());
			l1.b += (new Double(l1.CALC((double)l3 * 0.1000001D)).doubleValue());
		}
	}
	else if(l1.CALC((double)l3 * 0.1000001D) > 40D)
	{
		for(l3 = 0; l3 <= 10; l3++)
		{
			// STUPID JAVA
			// They shuod make it where:
			//	Like: new int's(temp1 AND temp2) = PROC[l3].FIRST AND PROC[l3].SECOND;
			// IT WOULD be BETTER!! 
			// Java i sstupid if i dont cast then it might give me back a boolean or somthing, if FIRST is 0 or 1 it will give me A BOOLEAN!!!!
			//This will crash.
			//
			int temp1 = (int)PROC[l3].FIRST;
			int temp2 = (int)PROC[l3].SECOND;
			double d2;
			l1.RET = (int)((d2 = l2.a + CONSTANTS.getCONSTANTVARIABLE(new String("K"))) / 22D);
			l1.RETSECOND = a(l2.b + L);
			int constantKVALUE = new Integer(CONSTANTS.getCONSTANTVARIABLE(new String("K"))).intValue();
			if(CHECK_VALUE(l1.a, l1.b) && PROC[l1.a][l1.b] == -1 && (l1.a % 2 == 1 && l2.a + constantKVALUE > 0D) &&
			 constantKVALUE >= 11D && (l1.a % 2 == 0 && constantKVALUE < (double)PROC[216] || constantKVALUE <= (double)PROC[216] - 11D))
			{
				String constantUSED = new String("K");
				//MAKE WRAP!
				cWRAP = new WrapperFIXED_C(new String("CLIMATE_CHECKER"), temp1, temp2, constantUSED);
				//CHECK to makje sure it was built
				if(cWRAP.GETVALUE() == "CLIMATE_CHECKER")
				{
					//OKAY
				}
				else
				{
					throw new RuntimeException("CRITICAL ERROR NOT EQUAL!!!!!!!!");
				}
			}
		}	
	}
	else
	{
		//JUST in case it goes bad
		throw new RuntimeException("CRITICAL ERROR SHOUDLDNT BE");
	}
	//IF WE MADE it this far we update GLOBAL variables with new CWRAP!
	//WE make sure its CWRAP.
	PROC[3] = (WrapperFIXED_C)cWRAP;
	//THERE fixed this.
	
	//TODO:
	// FIX BUGS
	// But it si done!
}
:???:

I like the nice little, rant though. It made me warm and fuzzy.

*EDIT*

Fixed it so it doesnt destroy the page.

*EDIT2*

Sigh, is there a better way to do this? I cant stop it from destroying this page.

UberJumper fucked around with this message at 03:00 on Feb 24, 2009

UberJumper
May 20, 2007
woop

TRex EaterofCars posted:

You could put it in a pastebin, but I think it's worth it to see this poo poo in all its glory.

To be perfectly frank, I feel a lot better about some of the poo poo I've written in a rush or early in my career... nothing was ever this bad.

Also, I personally love this part:
code:
        // Roger wanted me to make sure that this cant happen if it does anyways
	String checkIT = new String(l1.VALUE())
	if(checkIT == NULL)
Did a scientist write this? I've seen some absolute poo poo come out of scientists...

Nope, not a scientist. It was written by a third year Software Engineering coop student from Waterloo University.(:???:)

(I don't want to go into alot of detail, since i am too a coop student, and dont want to break rules(I dont know if there are even any))

The application is an internal Government Application its basically a massive spanning :cthulhu: application that is used, to fetch some random sets of information/other stuff.

Thankfully this poo poo, is only confined within a little application that only deals with a very specific type of data. It's used maybe twice a month. But unfortunately since the system is basically :cthulhu: it interacts with other parts of the system using temporary files, and some other ridiculous things.

But realistically :cthulhu: needs to die a slow/painful death. Its terrible and probably in total is a million lines of code. This is one small part made up of around 40 odd java classes(the gently caress does it use them for) and is :suicide: to try and figure it out.

Maybe the kid never really programmed before, but gently caress come on.

:suicide:

I think i should start pushing to have an actual source repistory, with code inspections etc. Because this is ridiculous.

UberJumper
May 20, 2007
woop
So i actually looked at the wrapper objects, i can see what they are for. But its just useless.

I browsed and found all the wrapper java classes, WTFGFD.

WrapperFIXED_A.java
WrapperFIXED_A.class
WrapperFIXED_B.java
WrapperFIXED_B.class
WrapperFIXED_C.java
WrapperFIXED_C.class
WrapperFIXED_D.java
WrapperFIXED_D.class
WrapperFIXED_E.java
WrapperFIXED_E.class
WrapperFIXED_G.java
WrapperFIXED_G.class
WrapperFIXED_H.java
WrapperFIXED_H.class
WrapperFIXED_I.java
WrapperFIXED_I.class
WrapperFIXED_J.java
WrapperFIXED_J.class

What happend to WrapperFIXED_F? :iiam:

:(

All the classes are identical just with a slightly difference class name. I found this comment in A Tho.

Its GOLD:

code:
/*
	JAVA IS STUPID, LET THIS BE A WARNING TO ANYONE!!!

	I MADE 9 WRAPPERS ENDING WITH LETTERS, SINCE JAVA cant make classes right. THEY ARE ALL THE SMAE!!!!!!
	
	JAVA is hirrable because I want to make 50 classes at once! It cant let me. This fails WHY? With C++ it would work.
	
	for(z = 0; z <= 100; z++)
	{
		WrapperFIXED_ + z z = new WrapperFIXED_ + z;
	}

	WHY IS THIS SO HARD??!@?! If i want 50 clases i need to be able to do it better. 
*/
:suicide:

Please someone tell me what the gently caress he is rambling about?

UberJumper
May 20, 2007
woop
One more before i go to bed.

This is what WrapperFIXED_A.java is made of:

(NOTE: I cut out alot of the boring stuff, because its redundant, boring and useless code, some of the other functions were given to him, he just gave them retarded all caps names)

All my comments start with >> and are bolded.

code:
public class WrapperFIXED_A
{
	public int n1;
	public int n2;
	
	/* >> Tons of other defintions crap, i've snipped it */
	
	/* >> The only private variable in the class, i didnt snip it because.... its.. hilarious*/
	// THIS MAN! PROTECTS YOU WHILE YOU CODE
	private int O_O;
	
	//* >> Uhhh okay?... moving on.
	public void foo()
	{
		
	}
	
	//* >> WHAT THE gently caress!
	public String VALUE()
	{
		String temp = new String(VALUE);
		String newtemp = new String(temp.trim());
		if(newtemp == NULL)
		{
			throw RuntimeException("VALUE IS NULL!");
		}
		else if(newtemp != NULL)
		{
			//Touppercase, can't make that NULL? RIght?
			String returnVALUE = new String(newtemp.toUpperCase());		
			return returnVALUE;
		}
		else
		{
			throw RuntimeException("VALUE IS NOT EXISTANCE!");
		}
		throw RuntimeException("ERROR");
		
		//Cannot be at this Code line so its safe to retutn Null cause we cant get that
		return NULL;
	}
	[b]//* >> Rest is boring.[/b]
}
Its kinda tame, what he is doing with strings :isam:, he did make me laugh with the private variable face man. But no...

For the retarded little minirant of his, my theory is:

for this:

for(int i = 0; i <= 100; i++){
(WrapperClass_ + i) (mywrapper_ + i) = new (wrapperclass_ + i);
}

I think that more explains it, im not sure. Looks like he wants to dynamically create 100 variables, of a 100 different classes.

I.e.
WrapperClass_1 mywrapper_1 = new WrapperClass_1();
WrapperClass_2 mywrapper_2 = new WrapperClass_2();
... etc.


Why. :iiam:

*EDIT* Boo bold doesnt work in code tags.

UberJumper fucked around with this message at 05:25 on Feb 24, 2009

UberJumper
May 20, 2007
woop
So i saw this today from ERDAS's software SDK...

code:
#define __(a) a
What the gently caress?

I was curious because they prototype their functions like:

<type> <function name> __((<parameter list>))

UberJumper
May 20, 2007
woop
code:
rows = gp.SearchCursor(A_Layer, The_SQL_Query_For_This_Layer)
row = rows.next()

# CHeck if Row is NULL, seems turning a row into a string, that is Null will print "None"
if str(row) != "None":
  <do something>
else:
  # Free the License!
  del gp
  sys.exit("Error Bad Feature layer")
:psyboom:

Now whats the biggest WTF here?

UberJumper
May 20, 2007
woop
:psyduck:

code:
_CREATE_GP_DEFS = {
  '9.0' : (lambda x = (lambda : __import__('win32com.client')) :
    win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")),
  '9.1' : (lambda x = (lambda : __import__('win32com.client')) :
    win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")),
  '9.2' : (lambda x = (lambda : __import__('arcgisscripting')) :
    arcgisscripting.create()),
  '9.3' : (lambda x = (lambda : __import__('arcgisscripting')) :
    arcgisscripting.create(9.3))
}

UberJumper
May 20, 2007
woop

Janin posted:

What does this even do? The lambda parameters aren't used anywhere, so the imports are pointless.

e:


This looks like it's supposed to simulate lazy evaluation, not currying, unless there's something really weird going on elsewhere.

Oops! I actually copied the broken one, here is the correct one that was checked in:

code:
_CREATE_GP_DEFS = {
  '9.0' : (lambda x = (lambda : __import__('win32com.client')) :
    (x()).Dispatch("esriGeoprocessing.GpDispatch.1")),
  '9.1' : (lambda x = (lambda : __import__('win32com.client')) :
    (x()).Dispatch("esriGeoprocessing.GpDispatch.1")),
  '9.2' : (lambda x = (lambda : __import__('arcgisscripting')) :
    (x()).create()),
  '9.3' : (lambda x = (lambda : __import__('arcgisscripting')) :
    (x()).create(9.3))
}
I only noticed this, because i am partially using some common modules, and saw that. His argument was "I dont want to create 2 line functions!"

It works.. i kinda like it but... :psyduck:

UberJumper fucked around with this message at 06:26 on Jan 26, 2010

UberJumper
May 20, 2007
woop
Ugh more horrors:

Honestly this is written by someone who worked in the industry for awhile. :negative: i am a coop student, so i don't have any say. But gently caress.

Note. The code i posted above is not this person, and the following morning he actually was like "what the gently caress did i do?". And corrected it.

I See Too Much poo poo Like this:

code:
 
HasAFc = (lambda x: str(x) != "None" and "True" or "false")(str(<some random variable>))
<snip 400 loving lines of python>
if HasAFc == "True":
  <dosomeshit>
if HasAFc == "False":
  <do some stupid poo poo>
Or....(hint count the spaces)

code:
s3 = "    "  # 3 spaces
He then went a did a gently caress everything dictonary of lambda expressions, that i dont... it hurts.. It parses metadata, we extract around 890 odd keys, and this does it all in a dict..... E.g.:

code:
    'PROCESSOR'     : [re.compile(r'^(\s+)?processor:(\s+)?(?P<VALUE>[a-zA-Z0-9_\-/.]+)'), \
        lambda x: (len(x) > 12 and [x[:11]] or [x])[0]],
    'BEGDATE'    : [re.compile(r'Img_SceneStartDateTime="(?P<VALUE>\d{8} \d{2}:\d{2}:\d{2}([.]\d+)?)"'), \
        lambda x: (lambda y : \
            ''.join([c for c in (y[:y.rfind('.')]) if c not in '.: ']))(x)],
'EXTENT_LAT_1'  : [re.compile('(Img_ImageSceneLeftTopLatitude)="(?P<VALUE>[-]?\d+([.]\d+)?)"'), lambda x: x],
:psyboom:

UberJumper
May 20, 2007
woop
Ohgod :psyduck:

code:
    return ''.join(map(lambda x: str(x[0]), [(len(list(group)), name) for name,
      group in itertools.groupby(
        ''.join(map(str, map(lambda x: x + 1, self.data)))
        )
      ]))
This converts a list of 1 and -1's into RLE string.

UberJumper
May 20, 2007
woop

ZorbaTHut posted:

Slightly late on this point, but the complete inability to disable specific warnings, or turn specific warnings into errors (i.e. with more fidelity than a global -Werror), has led to me writing a small chunk of shell script that wraps GCC, grabs the output, runs a bunch of sed scripts on it to turn some warnings into errors and eliminate other warnings entirely, and returns an appropriate error code.

I'm not sure if this is a coding horror or a coding glory, since it works drat well and makes GCC quite a bit more pleasant to use . . . but it definitely makes me want to cry.

I am not much of a *nix guy, but is there any decent alternative to gcc?

UberJumper
May 20, 2007
woop

Munkeymon posted:

Seems like this should go here:
http://arstechnica.com/software/news/2010/04/developers-apparently-love-net-hate-mfc-ruby-on-rails.ars


'See, the rails community is so much better than you that we simply can't be bothered with your pathetic little survey.'

I never quite understood why most rails developers acted like complete and utter douchebags. I went to a technology conference last year, aside from Microsoft / IBM / Sun, it was a big ruby on rails circle jerk.

:bahgawd: Ruby on Rails will be the death of .Net and Java!
:btroll: Python/C++ will die too why would anybody use that!
:bahgawd: Now everybody drink your koolaid.

Sadily i think everybody drank the ruby koolaid. As a result i got to have dinner and chat with some lonely microsoft / sun guys. Ironically i checked up on those companies promoting ruby and majority of them have yet to release anything.

Adbot
ADBOT LOVES YOU

UberJumper
May 20, 2007
woop
code:
def connectToFtp(ftp_connection_information_desc, ftp_connection_information):
	<do poo poo>
	return ("Connected to remote FTP via <stuff>", ftp_obj)
	
def listFiles(ftp_directory_desc, ftp_directory):
	<do poo poo>
	return ("Listed files at directory" + ftp_directory, <list of files>)
	
def DoLotsOfFTPShit():
	ftp = connectToFtp("Connecting to internal staging FTP Server", <insert connection information>)
	print ftp[0]
	ftp_obj = ftp[1]
	
	files = listFiles("List files in the ftp directory", <insert directory>)
	
	<do poo poo>


I looked around more and every single function this guy wrote follows this form:

code:
def <function name>(<parameter_name>_description, <parameter_name>, <rinse / repeat>):
	<body function>
	return (<description of return value>, <return value>)
I honestly have heard of "verbose" code. But what the christ :psyduck:. I haven't the faintest loving idea what the gently caress he was attempting or trying to achieve here. 99% of the time the description value is not used at all.

I think a bottle of scotch in the morning is needed. Ugh.

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