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
Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Haha, I'm not sure what the bigger WTF is, the fact that you store the user/pass unencrypted in the cookie (thus sending it over the wire every time you request a page) or the blatant SQL injection.

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

pokeyman posted:

Ah yes, that ancient coding blasphemy. Death to the not operator! All hail empty code blocks! Allah ackbar!

He's using Perl (or Ruby) too, so he doesn't even have to use the not operator - unless will work just as well.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ehnus posted:

Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension.

"If not (whatever) do this" is less clear to you than "unless (whatever) do this"? I mean, one of them is a common English construct.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
From the iPhone dev thread:

Unparagoned posted:


code:
char ddd[4];
for(int i=1; i<=NUMBEROFUNITS; i++)
	{
		
		sprintf(ddd,"%d",i);
		[b]//printf("begining of LOOP");[/b]
		NSString *StemporyUnitInt=[NSString stringWithFormat: @"%s",
[unitOptionsSQL getSqlEntry: aaa select:cc from:bbb where:eee is:ddd]] ;
		printf("\n index %d", i);
		unitOptionList[i]=[StemporyUnitInt intValue];

		
	}
EDIT: Looks like if I put the folowing at the start of the loop all workds fine. It's fustrating trying to find out what the problem is when everything I try fixes it.
char *testtt;
sprintf(testtt,"%d",i);
printf("testtt %s", testtt);

Jargon posted:

Haha when you pick your variable names do you just like hold down the last key like "one-one thousand, two-one thousand"?
That's too hard, you just copy and paste the code you need and then just add another char to the variables aa->aaa.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
"handle_pants_event" is the greatest function name ever and I am going to use it all the time now.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Inverse Icarus posted:

code:
// checking below me
// no children to right or left
// i am a leaf node

This is the exact opposite of a coding horror.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

meinstein posted:



What font are you using?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ColdPie posted:

Hahaha oh man you should've seen my Tetris clone from high school. Let's just say there were local variables named xxxxx and yyyyy.

I wish I could find my old IRC library. I created a very bad state machine to parse messages from the server, one byte at a time.

One giant while loop with a switch(state) and case 3: if (byte == ':') then state = 4; etc...

Oh and I thought I was being "cute" with monty python quotes in the comments.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I'm reimplementing a tool that fills space. I don't have source for the original tool, but that's what Reflector is for!...

code:
if (Regex.IsMatch(input, "[0-9,]+ bytes free"))
 {
       MatchCollection matchs = Regex.Matches(input, "[0-9,]+ bytes free");
       this.lblFreeSpaceLabel.Text = "Free Space:\n" + matchs[0].ToString().Substring(0, matchs[0].Length - 11).ToString() + " bytes";
       string str = Regex.Replace(matchs[0].ToString().Substring(0, matchs[0].Length - 11).ToString(), ",", "");
       this.lMUFreeSpace = Convert.ToInt64(str);
}
...I don't think I'm missing much.

ed: I think my favorite part of this is that he knows to use regexes, but seems unaware of how exactly he should be using them.

Dessert Rose fucked around with this message at 23:59 on Jul 8, 2009

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Haha, I love their "fail" page. Someone submitted a GA program that evolves hello world.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Janin posted:

that's not the problem here

it's recursive in how lovely it is, that's loving amazing

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Goat Bastard posted:

It's not quite a for-case though, is it? If refresh(1) is called then the pass == 2 stuff gets skipped, and similar for refresh(2).

Note: I am in no way defending this lovely method.

right, that happens in for-case too, the difference is that here the for loop is accomplished by recursion

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

quadreb posted:

Genetic TSP?

From what he's said in the QuestHelper thread, that would seem to be the case (he talks about how it tends to get "stuck" on somewhat-good solutions when a large change would be better, which is exactly the issue a GA would face, for example)

GAs are still magic to me. I want to make a game with GA AIs.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
The comment implies that if they don't do this, it'll be filtered by some other bit of code. Which is sort of a coding horror in itself.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Well, I notice it says "some web-software", implying that it's not necessarily a default option of PHP (which I wouldn't discount out of hand, since it is PHP) but rather perhaps a package some people have on their servers that causes issues, and this hack is to fix it

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Supervillin posted:

I'd just like to see what possible input string could go through those two lines and come out different.

What I'm saying is that, while we can all lol about />/i because haha angle brackets don't have a lowercase, the real coding horror here is the security package this bit of code is meant to fix interoperability with.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Zombywuf posted:

I see this practise as a big red warning sign.

For sure. All the interviews I've ever been a part of have been a bunch of interviews leading up to the "stuffed suit" who is usually the hiring manager. The only interview I've ever been to where it was JUST the manager was him basically creating a team from scratch.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ehnus posted:

I have no problem with #if 0 ... #endif but it's nearing horror status when it gets checked in.

Yeah, checking in commented out code is terrible. You're using source control for that reason, just take it out.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

geetee posted:

Maybe setting myself up for embarrassment, but can you explain how people should use revision control systems?

Don't check in commented out code because you're half done with it. Check in only code that builds.

When you pick up your code tomorrow, use the handy conflict resolution tools that your RCS has! That way, you can see any changes that anyone made to things that your code might have been affected by, and people don't open up a method and go "WTF?" because there's a big block of half-done code in there and they have no idea how to go about modifying the code anymore.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Lysidas posted:

Commented-out code doesn't affect whether the project builds :downs:

Yes, I'm aware of that. Those were two separate and mutually independent statements; sorry that wasn't very obvious.

Checking in commented out code is almost always bad. The problem is that if it stays there for more than about two commits, it's never going to leave, and then you have this problem where the rest of the codebase changes around this block of commented out code, and now it doesn't make any sense at all.

I would have an example, but I'm not working at the company where I saw the most heinous example of this. Basically, it was a case of code reuse, where they took a previous project and then modified a few things. As stuff got modified, sometimes people would just comment out the old code, presumably so that one could see what it used to do.

But then about five commits down the chain, that old code had nothing to do with what was actually going on anymore, but - surprise! - it was still there, and when I came in to look at the codebase, it made it far harder to understand what was supposed to be going on.

I also had a coworker check in an entire file that didn't build for various reasons, but he had the genius idea to effectively comment it out by removing it from the project. That's why I said both of those things together :)

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

royallthefourth posted:

:waycool: Thanks for clearing that up.

Are you trying to be sarcastic or something?

Because if you are, this thread is about to get way more interesting.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
yeah like that's a lot of php code and in any 20+ line chunk of php there's bound to be at least one horror but honestly using a shell exec command to start a server probably isn't it

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

floWenoL posted:

Good point. I'm actually not familiar with the state of decompilers for languages like Java/C#. How readable does "reasonable" look? Are variable names preserved?

As far as C# goes, if you don't run it through Dotfuscator the thing basically looks like you just removed comments.

If you do, then the variable names change to a, b, c, d, etc (so, no change :v: ) or nonprintable characters if you have the full version, but it's still trivial to see your app logic.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

MagneticWombats posted:

Couldn't you do something like
code:
 yes | stupidInstall 

this works until:

code:
Do you want to erase the hard drive? [no]
Are you sure you want to erase the hard drive? [no]

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ton1c posted:

You know it's funny, a good number of people reading this thread and that reddit thread would probably be guilty of a number of things in this thread. Programming should be more like music, where you compete against yourself rather than bash those who suck, but then nothing would get done.

I don't understand. There are musical pieces that everyone, even those who don't know a thing about musical theory, can agree are loving terrible.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

CanSpice posted:

And if they change the definition of a radian then it only needs to be changed in two places!

no one argued that this was a good reason for doing it but if you can't see why rads = degreesToRadians(degrees); is better in every way than rads = degrees/180*PI; then the coding horror, it's you

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

A A 2 3 5 8 K posted:

I thought it might be a copy/paste failure but then I thought of how unlikely that would be coming from a PHP enthusiast.

:drat:

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Ugg boots posted:

Whenever I see MUMPS I wonder why people actually write it by hand instead of writing it in another language that gets translated/compiled to MUMPS. I swear that would be one of the first things I tried if I got stuck with lovely language work.

How are you going to deal with the corpus of already-existing code?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Zombywuf posted:

Hey, guess what my black box does, only mine does it with human eyeballs not units of soulless energy.

You've wandered pretty far from your original complaint through.

he claims his "creates" money, too, which is interesting

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I just inherited a codebase where the previous developer had something of a mid-life crisis and disappeared off the face of the earth when it was "about 90%" done.












Not only is it actually probably that close to done, but the code actually looks like it was written by someone who knew what they were doing.

I'm sure I will find a giant coding horror in here somewhere to whack me upside the head, but so far the only one has been that he didn't know that static classes can have constructors.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Milotic posted:

Or maybe he realised that static class constructors are the real horror?

What's wrong with them? I mean, you can't/shouldn't put any logic in them that depends on the state when they're called, but if all you're doing is making a class with a bunch of constant data in it that can't be constructed through basic initializers, what's wrong with it?

The alternative is having some retarded InitializeConstants() call that has to be done in a bunch of different places.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

rjmccall posted:

Sure. On the other hand, if you would naturally give the same well-named label to two different loops in a function, it becomes really easy to make tragic mistakes.

code:
void foo() {
[...]
foo_conditional_1:
[...]
}

void bar() {
[...]
bar_conditional_1:
[...]
}

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Mista _T posted:

If the aim is readability, then why not black-box the whole test and only offer up the result? I'm probably digging further than I need to in what probably amounts as something trivial, anyway, so I'll just back down from this one.

because at some point you still have to read the rest of the code? What does this "black box" method end up looking like? Saying "well, just put all the code in some other method" doesn't solve anything at all. Okay, so how should I design that one?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Avenging Dentist posted:

Labels are local to functions so this is wholly unnecessary.

oh, and he even said "two loops in a function". welp, guess that's reading_comprehension--;

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

LockeNess Monster posted:

From a recent conversation:

IT person: the compiler does all math equations anyway

Depends. If he's talking about stuff like int i = 2 + MAX_FOO; and MAX_FOO is just defined as 4 or something, then yeah, the compiler does those

at least that's what I'd assume he was saying

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Jonnty posted:

Oh, don't be pedantic, you know what they meant.

well, what DID they mean? because you can get along just fine without arrays as long as you have pointers:

code:
typedef struct {
data_obj *next;
int data;
} data_obj;
i mean "what would you do without arrays?" is an open-ended question that can have tons of valid answers, and "make functions with 300 parameter overloads" isn't one of them

n.ed: I'm actually being serious, what do you think that that question means? They didn't ask "what would you do without any language construct that allows you to create a data type containing more than one value", they asked what you would do without arrays.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

LockeNess Monster posted:

What is an array? A contiguous buffer in memory that you can treat as a vector of values?

What is an array? A miserable pile of values! But enough talk...

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

LockeNess Monster posted:

I mean, depending on the definition of the array the assignment statement "don't use arrays" would have very different implications.

Array could mean associative array, and/or linked list could count as an array as well.

Well, yeah, that's why this discussion is anything but pedantic. "What if you didn't have arrays" is an incredibly vague question.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I guess I just hate the question because the answer they're expecting is predicated on you not knowing anything but what they've taught you. I hate questions like that because I always try to read more about what I'm doing, etc. and so I always know the "pedantic" answer to the question.

It's a legitimate question as written - "What would you do [in this function] if you couldn't/didn't want to use arrays?" because then you can give any of the valid answers that still accomplish the task but don't use arrays. But when you write the question specifically expecting the answer "gently caress WE'RE SCREWED UNLESS THERE'S SOMETHING ELSE YOU HAVEN'T TOLD ME YET" and use vague terminology to boot, well...

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Nomnom Cookie posted:

"Array" is not vague terminology in C, C++, Java, Pascal, or C#. If it's a class in PHP, yeah, you might have a point, but I don't think that was the case.

okay, so "use a linked list" is a perfectly valid response to the question, because they didn't specifically disallow that solution

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