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
geetee
Feb 2, 2004

>;[

Lone_Strider posted:

The dev who created this is one of those "stuck in his ways" people who's best fit is maintaining some Access 97 application.

Ugh, I work with one of those. I think now is a great time for me to start poo poo again about the "guid" table. I talk so much poo poo about my coworkers. I really hope none of them are goons.

Adbot
ADBOT LOVES YOU

Victor
Jun 18, 2004
For those of you with SQL2005, NEWSEQUENTIALID() was created for you:

MSDN posted:

Creates a GUID that is greater than any GUID previously generated by this function on a specified computer.

subreality
Oct 4, 2002

I require a cup of tea and a large tray of internets immediately.
Years ago, I got hired to take over a few websites that were created by "this guy that's really good with computers" :(

Watch him "resize" an uploaded image in PHP5:
php:
<?
  $filename = "whatever.jpg";

  $image = imagecreatefromjpeg($filename);
  $image_width = imagesx($image);
  $image_height = imagesy($image);

  while ($image_width > $max_width) {
    $image_width = $image_width - 1;
  }
  while ($image_height > $max_height) {
    $image_height = $image_height - 1;
  }

  echo '<img src="'.$filename.'" width="'.$image_width.'" height="'.$image_height.'">';
?>
I can't even begin to list the things that are wrong with this.

How can someone who has even the faintest idea of how to use math (or knows how the internet works) write this... drivel?? :smithicide:

subreality fucked around with this message at 06:12 on Dec 5, 2008

subreality
Oct 4, 2002

I require a cup of tea and a large tray of internets immediately.
The same guy also wrote a login.php that went a little something like this:
php:
<?
  $logged_in = false;

  $users = mysql_query("SELECT * FROM users");

  while ($row = mysql_fetch_assoc($users)) {
    if ($row['username'] == $_POST['username'] && $row['password'] == $_POST['password']) {
      $user_id = $row['id'];
      $logged_in = true;
    }
  }
?>

Fenderbender
Oct 10, 2003

You have the right to remain silent.
Hmm..well if we're trying to strictify this perl code, then I can't use scalar refs...I've got it!

code:
for (@facilities) {
    eval('$' . $_ . ' = 1');
}
:(

indigoe
Jul 29, 2003

gonna steal the show, you know it ain't no crime

subreality posted:

The same guy also wrote a login.php that went a little something like this:
php:
<?
  $logged_in = false;

  $users = mysql_query("SELECT * FROM users");

  while ($row = mysql_fetch_assoc($users)) {
    if ($row['username'] == $_POST['username'] && $row['password'] == $_POST['password']) {
      $user_id = $row['id'];
      $logged_in = true;
    }
  }
?>

Could have been worse, at least it's secure from sql injection.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

subreality posted:

The same guy also wrote a login.php that went a little something like this:
php:
<?
  $logged_in = false;

  $users = mysql_query("SELECT * FROM users");

  while ($row = mysql_fetch_assoc($users)) {
    if ($row['username'] == $_POST['username'] && $row['password'] == $_POST['password']) {
      $user_id = $row['id'];
      $logged_in = true;
    }
  }
?>
He probably only read the first page of the PHP/MySQL tutorial...

spiritual bypass
Feb 19, 2008

Grimey Drawer

indigoe posted:

Could have been worse, at least it's secure from sql injection.

It amazes me how seemingly few people know how SQL injection works and how to use prepared statements.

MrMoo
Sep 14, 2000

subreality posted:

php:
<?
  while ($image_width < $max_width) {
    $image_width = $image_width - 1;
  }
?>
Really '<' not '>'? How long does that run for?

Victor
Jun 18, 2004
O(1) for very large values of 1.

subreality
Oct 4, 2002

I require a cup of tea and a large tray of internets immediately.

MrMoo posted:

Really '<' not '>'? How long does that run for?

Woops. That was a typo by me, recalling his code from memory.
Thanks, corrected now.

Mikey-San
Nov 3, 2005

I'm Edith Head!

subreality posted:

The same guy also wrote a login.php that went a little something like this:
php:
<?
  $logged_in = false;

  $users = mysql_query("SELECT * FROM users");

  while ($row = mysql_fetch_assoc($users)) {
    if ($row['username'] == $_POST['username'] && $row['password'] == $_POST['password']) {
      $user_id = $row['id'];
      $logged_in = true;
    }
  }
?>

Who gives a gently caress about this disaster when you're storing passwords in plain text in the database?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

geetee posted:

Ugh, I work with one of those. I think now is a great time for me to start poo poo again about the "guid" table. I talk so much poo poo about my coworkers. I really hope none of them are goons.

Yeah, the SDET we hired is one of those.

He seriously tried to defend the use of global variables.

a slime
Apr 11, 2005

When I was 12 I was doing a Visual Basic class through a high school program and I didn't know what the gently caress I was doing. I made a little sprite game with Timer and Image controls- pressing arrow keys enabled various timers that moved the image control around (TimerMoveLeft, TimerMoveRight, etc). This is pretty bad, but not really worth posting.

Here's the bad rear end part: it was multiplayer. Each instance of the game would constantly write the player's position to a text file. To connect to another player, you had to pop open a file dialog, navigate through Windows networking and select their player file. Bam. Multiplayer gaming via file I/O over Windows networking. I dare you to commit a worse atrocity.

edit: we were using VB5 so I may have been younger than that

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

not a dinosaur posted:

Here's the bad rear end part: it was multiplayer. Each instance of the game would constantly write the player's position to a text file. To connect to another player, you had to pop open a file dialog, navigate through Windows networking and select their player file. Bam. Multiplayer gaming via file I/O over Windows networking. I dare you to commit a worse atrocity.

edit: we were using VB5 so I may have been younger than that

Hahahaha that's so loving awesome for being 10 years old. You figured out a solution with the pieces you were given, that commendable.

No Safe Word
Feb 26, 2005

Mikey-San posted:

Who gives a gently caress about this disaster when you're storing passwords in plain text in the database?

Hey now ... he could have a javascript control on the page that hashes the password they enter before the POST fires!

ehnus
Apr 16, 2003

Now you're thinking with portals!

Ryouga Inverse posted:

Yeah, the SDET we hired is one of those.

He seriously tried to defend the use of global variables.

Really? Global variables? How heinous!

What's next, is he going to say that "goto" actually makes sense in certain situations?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ehnus posted:

Really? Global variables? How heinous!

What's next, is he going to say that "goto" actually makes sense in certain situations?

Okay, look, there's a difference between there possibly being edge cases in which it can be used and...
code:
        private void ReadIniFile()
        {
            input = new FileStream("config.ini", FileMode.Open, FileAccess.Read);
            fileReader = new StreamReader(input);
            _buffer = fileReader.ReadLine();
            _inputFields = _buffer.Split('=');
            textBoxMovieName.Text = _inputFields[1];

            _buffer = fileReader.ReadLine();
            _inputFields = _buffer.Split('=');
            textBoxRecordTime.Text = _inputFields[1];

            _buffer = fileReader.ReadLine();
            _inputFields = _buffer.Split('=');
            _RecordFormat = _inputFields[1];
            PrepareReadRecordFormat();

            fileReader.Close();
            input.Close();
        }
I mean, I feel like I'm reading Ruby or something, except ugly.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Spent the last hour reading this thread and now I'm extraordinarily worried I'm going to end up in here some day. There were so many in here that I didn't understand without explanatory posts :(

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Ample worry (self awareness?) is step one on your journey to not being here. If at any time you thought "my code looks like this" or "that looks like a good idea", then you should be really worried.

Why not quote a post you don't understand and ask for clarification? I'm sure at least one goon won't be able to restrain himself and will wow us with his knowledge of The Right Way.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Triple Tech posted:

Ample worry (self awareness?) is step one on your journey to not being here. If at any time you thought "my code looks like this" or "that looks like a good idea", then you should be really worried.

Why not quote a post you don't understand and ask for clarification? I'm sure at least one goon won't be able to restrain himself and will wow us with his knowledge of The Right Way.





(Just don't read any programming blogs and you'll be fine.)

subreality
Oct 4, 2002

I require a cup of tea and a large tray of internets immediately.

Mikey-San posted:

Who gives a gently caress about this disaster when you're storing passwords in plain text in the database?
It was all part of his masterplan to drive me insane

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Avenging Dentist posted:






(Just don't read any programming blogs and you'll be fine.)

I read The Daily WTF most work mornings, does that count? :shobon:

Victor
Jun 18, 2004

Ledneh posted:

Spent the last hour reading this thread and now I'm extraordinarily worried I'm going to end up in here some day. There were so many in here that I didn't understand without explanatory posts :(
Anyone in here who claims to have never written code that could be submitted to this thread is a pretender*. The key is that you continue to learn and figure out ways to be less retarded.

* or hiiiilarious

biznatchio
Mar 31, 2001


Buglord

Victor posted:

Anyone in here who claims to have never written code that could be submitted to this thread is a pretender*. The key is that you continue to learn and figure out ways to be less retarded.

* or hiiiilarious

Hell, I'll go so far as to acknowledge that I still write bad code today.

Sometimes short deadlines make for serious design compromises.

geetee
Feb 2, 2004

>;[

biznatchio posted:

Hell, I'll go so far as to acknowledge that I still write bad code today.

Sometimes short deadlines make for serious design compromises.

These words are so true, and it hurts.

chocojosh
Jun 9, 2007

D00D.

Ryouga Inverse posted:

Okay, look, there's a difference between there possibly being edge cases in which it can be used and...
code:
        private void ReadIniFile()
        ....
I mean, I feel like I'm reading Ruby or something, except ugly.

What exactly is wrong with that code? He has an INI file with three lines in the form of X=Y and he's taking the second field of the first three lines and using them to populate values. How is it ugly?

Outlaw Programmer
Jan 1, 2008
Will Code For Food

chocojosh posted:

What exactly is wrong with that code? He has an INI file with three lines in the form of X=Y and he's taking the second field of the first three lines and using them to populate values. How is it ugly?

It's not the worst code I've ever seen but it does have a few problems. First, it looks like the _buffer and _inputFields variables should be local in scope (tough to say without seeing the rest of the class, but it's probably a WTF either way).

Second, it makes some pretty big assumptions about the format of the file. Typically, properties files like this shouldn't really care about the ordering of the information. What if someone adds some whitespace, or comments, to the file? What happens when more properties need to be added? I'm not a .NET guy but I'm pretty sure there has to be a better way to read these config files.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

chocojosh posted:

What exactly is wrong with that code? He has an INI file with three lines in the form of X=Y and he's taking the second field of the first three lines and using them to populate values. How is it ugly?

Every variable there is global (well, technically it's private to the class but since the entire app is this one class... which is a big WTF all by itself) and the method doesn't return anything or take anything (because it uses global variables), for starters.

The config file name is hardcoded, in more than one place.

The code itself doesn't handle humans editing the file gracefully. Since he's using the INI format he intends humans to be able to edit it, and humans screw up a lot. Especially humans who aren't very good at using computers, which this app is targeted at.


The biggest WTF is simply that it took him an entire week of working 12h a day (he worked on it from home) to turn out code of this quality, and he gets paid more than I do.

chocojosh
Jun 9, 2007

D00D.

Ryouga Inverse posted:

:words:

Thanks, because of the comment you made about the goto I read it four times wondering where the goto was.

Outlaw: When I wrote a small desktop app for my company last summer, I just followed the "standard convention" at our office and used app.config. I believe ConfigurationManager.AppSettings was what I used.

I hope it didn't take him 60 hours to just come up with a 20 line function! If so.. are you looking to replace him?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

chocojosh posted:

Thanks, because of the comment you made about the goto I read it four times wondering where the goto was.

Outlaw: When I wrote a small desktop app for my company last summer, I just followed the "standard convention" at our office and used app.config. I believe ConfigurationManager.AppSettings was what I used.

I hope it didn't take him 60 hours to just come up with a 20 line function! If so.. are you looking to replace him?

Well, I was responding to someone trying to troll me for possibly suggesting that something in coding could NEVER have a use.

It's not just that function, it's his whole app.

Basically what we want to do is a GUI wrapper for a CLI app. Doing it in VBS would have been faster, but not as flexible, while doing it in C# allows us to do some other things that VBS can't do.

He has managed to take all the disadvantages of the VBS approach and apply them to the C# approach, and his code didn't work AT ALL until the end of the week. And it's still missing a few key features. His code review consisted of "Don't ever use global variables." "Well I wanted to get it working quickly..." "Don't use globals. It's terrible style. Also, catch the events you actually care about rather than events that are tangentially related. Further, your code doesn't even work." "Well this is just a review about the composition of the code..." "Okay. GLOBAL VARIABLES. VOID METHODS. CALLING TOSTRING() ON STRING VALUES."

My boss knows that he can't do the work effectively AT ALL and is, I believe, looking to replace him, but it's harder to find a competent SDET than you'd think.

The punchline is that this guy is on his contracting break from MS' Explorer team. I can't quite wrap my head around this situation at ALL.

a rad dink
May 28, 2006

take me to your peener
Here's one you all might enjoy. There was a guy here, that thankfully left a while ago, that did a lot of the coding around here. While this is just a little taste of his WTFery, I've encountered a laundry list of problems with his style.
Sure perl will let you play pretty loose with the rules, but that's no reason to abuse it. Among such silliness as a LOVE of global variables (I don't think he ever scoped anything in his life), every single thing being in a function to the point the actual script was just a short list of two or three functions at the bottom, and an almost smug disregard for how to actually write working code, there's this:

code:
sub Twait {
    for ($loop = 1; $loop < 18000000; $loop++) {

#        do nothing simplely pause for a short period of time 12 seconds                                          
    }
}
Apparently sleep() is for the plebs.

Potassium Problems
Sep 28, 2001

Ryouga Inverse posted:

"...CALLING TOSTRING() ON STRING VALUES."
Holy poo poo, this is like a tell-tale mark for crappy devs. I bet when he was called on it he said "well I'm just making sure"

Erasmus Darwin
Mar 6, 2001

Lone_Strider posted:

I bet when he was called on it he said "well I'm just making sure"

string = string.toString().toString().toString().toString(); /* Really loving string. */

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Lone_Strider posted:

Holy poo poo, this is like a tell-tale mark for crappy devs. I bet when he was called on it he said "well I'm just making sure"

Seriously. textBox.Text.ToString()? Really? I mean, really?

Vanadium
Jan 8, 2005

Guys, I am sure the .toString() calls get inlined...

waffle iron
Jan 16, 2004

Vanadium posted:

Guys, I am sure the .toString() calls get inlined...
That's not the problem, it's the fundamental misunderstanding of one of the main classes and the simplest feature of the entire language/base.

Vanadium
Jan 8, 2005

That just makes the code more portable. In Ruby it is common practice to call .to_s on string-like objects

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.
You can't subclass java.lang.String.

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Vanadium posted:

That just makes the code more portable. In Ruby it is common practice to call .to_s on string-like objects

This is a level, right?

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