The ugliest code I've ever seen.

kcwong

Emperor
Joined
Jan 31, 2002
Messages
1,108
Location
Hong Kong
for(idi = 0; idi<gp_221_add22Arr_INDS.length; idi++){
if(gp_221_add22Arr_INDS[idi]){
var tmarrArr = gp_221_add22Arr_INDS[idi];
var ddataiND = tmarrArr[0];
var ddaitemVal = _pppag_AItmes[tmarrArr[0]][0];
var xyzTmVa = ddaitemVal+SUBFIX;
jsp_ITem_SEL_IDNS[jsp_ITem_SEL_IDNS.length]=ddataiND;
<%if(_PAGE_PAR_assignemntMode == pageTools.ASSIGNMENT_MODE_DELEGATE){%>
var ssArr = new Array(xyzTmVa, modeDesc, date11Arr[1]);
<%}else{%>
var ssArr = new Array(xyzTmVa, date11Arr[1]);
<%}%>
jsp_ITem_SEL_Vals[ddataiND] = ssArr;
ADD_txt+=xyzTmVa+'^';
selectedADD = true;
}
}
}

Those are a small section out of a JSP, by someone who left the company a week ago. Now I have to maintain this piece of garbage. :mad:
 
:lol: nice choice of variable names....
 
:lmao:

Just use search and replace to fix it. Creating rubbish code is a common way for programmers to try and secure their jobs. At least it's not spaghetti! ;)
 
I especially like the apparent typo in "jsp_ITem_SEL_IDNS" and the random letters in "xyzTmVa" :lol:
 
This is why I always use informative variable names like, for example...

if (!R2_obj) {...} // an indication to expect vars from "Revision 2" of the application

I also use comments to help maintenance programmers. I'm one of the few nicer developers you can meet. I'll even supply documentation with a list of all custom names in R1, R2, R3 &c..

However, I am like this because I struggle to even read mediocre third party code. If it's not written by me then it looks like jibberish and I suppose that makes me more aware of the dangers.

I have never met one programmer who takes the matter as seriously as I do.

Although this next part only affects me, a lot of my code has portions that look like...

MM_varname // might indicate that this is part of code for a company with initials MM
ZZ_varname // might indicate that I took this code snippet from a project with initials ZZ

This is really helpful to me because I can see where the code came from, and go back to the original source if I need a quick revision.
 
KaeptnOvi said:
:lol: nice choice of variable names....

Especially these lines:

var ddaitemVal = _pppag_AItmes[tmarrArr[0]][0];
var xyzTmVa = ddaitemVal+SUBFIX; // <----- this line
jsp_ITem_SEL_IDNS[jsp_ITem_SEL_IDNS.length]=ddataiND;

With the spaces between the variables missing, you'd think you saw some Base64 data or something.

There's also quite a lot of other typos... e.g. "ttype" coded as "ttpye" (even the original ttype doesn't make too much sense), "allITmes" instead of "allItems". String constants declared but not used, String literals everywhere... the list goes on and on.

I've thought about doing find and replace... but there're quite a lot of code in it, and in some parts of the code, JSPs are generating JavaScripts - variable names are generated. So I have concern changing it... besides, any change of that scale would require a full scale re-testing... and I don't have time for that. The client using it won't want to change too, as they've tested the current one and the code at least works. I'm stuck with this mess :(

Gogf said:
What does it do?

It's a profile management web application (the whole application was by the same lousy programmer). All the JPS, CSS, JavaScript, HTML and servlets and classes share the same messy coding style. My ex-co-worker is a disgrace to the programmer profession :mad:
 
Can you submit a report and claim overtime? It is a difficult situation :sad:

As with all my problems, I would go to http://www.tek-tips.com (I mention it yet again) and post this scenario in the "my development as a professional" forum. You might get some good advice from other maintenance coders or IT managers who have had maintenance programmers make similar complaints.

I love that side and am a member of about 20 forums there :love:

A long time ago I was an MVP but I've not been contributing much for over a year so my rating is now weak :p
 
stormbind said:
I also use comments to help maintenance programmers. I'm one of the few nicer developers you can meet. I'll even supply documentation with a list of all custom names in R1, R2, R3 &c..

bah, comments and documentation are for ze weak ;)

i'm one of the guys that uses really long variable name that describe exactly what they're for. I have to type more, but at least I still know what every variable is for at first glance. I really hate it when people use non-descriptive variable names such as my_var (possibly multiple times as my_var1, my_var2, etc) or crap like that.
 
You wouldn't like Perl then, $_ ;)
 
KaeptnOvi said:
bah, comments and documentation are for ze weak ;)

:lol: Sounds like at work. I'm modifying code that prior programmers wrote with little or no documentation.

Then there's the good old "Feature Creep" in a project that would've been done 2-3 months ago, but everyone wants "just one more thing". ;)
 
stormbind said:
You wouldn't like Perl then, $_ ;)

you're right, i don't :yuck: (maybe i just can't think abstract enough, but perl code frightens me....)
 
Chieftess said:
:lol: Sounds like at work. I'm modifying code that prior programmers wrote with little or no documentation.

Then there's the good old "Feature Creep" in a project that would've been done 2-3 months ago, but everyone wants "just one more thing". ;)
I won't touch that stuff, and I keep written documentation of everything to make sure the project either 1) achieves it's original objectives or 2) someone else gets blamed for incuring additional expense :D

Right now, a four-page list of issues (which I created) has just come back to me after going full-circle through the organisation. This copy is covered in lines and question marks - but that is brilliant, it means management know exactly what is going on and where time & money is being spent.

I heard other people say they have done whole projects without ever speaking with other departments or being given documentation - whatever works for them :confused:

K, I love Perl, but thanks to people like you (which seems to be 99.9% of web developers) I rarely get to practice it so I'm not as good with it as I should be :sad:
 
I don't think Perl is about abstract thinking, as long as subroutines have descriptive names the _ works rather well. I agree that it's not always ideal.

Some of my curly-bracket code uses the imfamous _ aswell, because I sometimes cannot think of a variable name to use :lol:

I also use arguments[0] in JS functions quite a bit and I suppose that is similar.
 
Chieftess said:
:lol: Sounds like at work. I'm modifying code that prior programmers wrote with little or no documentation.

Then there's the good old "Feature Creep" in a project that would've been done 2-3 months ago, but everyone wants "just one more thing". ;)

I just love "feature creep". :D

Even with a *fixed* delivery schedule, we have trouble meeting the customers' desires. We hold a "rack-and-stack" meeting for the users' requirements early in each development cycle, where we determine (with them) what we can put into the next release. Invariably, by the time we are in integration testing, they come back and ask for "just one more thing". The problem is, usually it is directed from the Pentagon that certain capabilities be included. But real-world problems just don't know our development schedule. ;)
 
Code:
dodsond2.orig: dodsond2.gz
	@${RM} -f dodsond2.orig.c
	-${GUNZIP} < dodsond2.gz > dodsond2.orig.c
	-@if [ -s dodsond2.orig.c ]; then \
	    ${ECHO} "${CC} ${CFLAGS} dodsond2.orig.c -o dodsond2.orig"; \
	    ${CC} ${CFLAGS} dodsond2.orig.c -o dodsond2.orig; \
	else \
	    ${RM} -f dodsond2.orig.c; \
	    ${ECHO} "sorry, we could not gunzip dodsond2.gz"; \
	fi

dodsond2.gz: dodsond2.gz.uu
	@${RM} -f dodsond2.gz
	${UUDECODE} dodsond2.gz.uu

dodsond1: dodsond1.c
	${CC} ${CFLAGS} dodsond1.c -o dodsond1

clean:
	$(RM) -f *.o a.out core 

clobber: clean
	$(RM) -f $(WINNERS)
	$(RM) -f $(ALT_NAMES)
	${RM} -f dodsond2.orig.c dodsond2.gz shapiro_t2.c shapiro_t1

nuke: clobber
	@${TRUE}

install: all
	${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null

There is a competition for obfuscated code:
http://www.au.ioccc.org/main.html
 
IOCCC... I knew the site for many years. Recently I visited the site and read some old news about people tatooing the programs on their forearms :)
 
That is ugly? You haven't seen some of the stuff I turn in for assignments :D
 
Back
Top Bottom