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
Zhentar
Sep 28, 2003

Brilliant Master Genius

Smugdog Millionaire posted:

How do you write 100,000 lines of code in a single file before you think to yourself "surely there's a better way to organize this"?

Horror Maker posted:

I have never worked with classes in that way where I create them myself so I am not sure of how to do this actually.

And looking back through their posting history to a couple months ago...

Horror Maker posted:

Hello

I am not sure what I am missing out but I am calling "sendTest" and pass along "hello1" and "hello2" to that function.

What I now want to return is "hello1b" and "hello2b" in the MessageBox shown below. I think I missing out some detail?
code:
        private void button3_Click(object sender, EventArgs e)
        {
            String g1 = "hello1";
            String g2 = "hello2";
            sendTest(g1, g2);

            MessageBox.Show(g1);
        }
        void sendTest(String one, String two)
        {
            one = "hello1b";
            two = "hello2b";

            return;
        }

Given the style, it's someone who has been forced to use programming in the pursuit of a particular goal. They haven't made any attempt to simply learn to program; instead only attempting to expand their knowledge when encountering a problem they don't already know some way to solve, and even then they simply want to be told the solution, either through forums or piecing together tutorials, never attempting to understand why things work they way they do.

Adbot
ADBOT LOVES YOU

Bhaal
Jul 13, 2001
I ain't going down alone
Dr. Infant, MD

Optimus Prime Ribs posted:

Well I know what it's doing. I just don't know what purpose it serves.
Maybe the dude really badly wanted to assign an event id to the text file using POST data, and do literally nothing else.

Makes me wonder why he didn't just use a GET variable in the URL for the id.
My guess is it's his nuke button in case he gets fired or the business relationship otherwise goes sour, with SQL injection via the unescaped POST variable being his means of malice. So he dresses it up, hoping it looks like meaningful code to the untrained/uncaring eye, or "I'm not sure why this is here, but I don't want to remove it and break something" to anyone who examines it, and in either case it remains untouched.


pokeyman posted:

"Beauty and Rage", Museum of Modern Programming, 2011.
Can't forget this gem:

https://www.youtube.com/watch?v=5-OjTPj7K54
code:
I was taught assembler in my second year of school.
It's kinda like construction work -- with a toothpick for a tool.
So when I made my senior year, I threw my code away,
And learned the way to program that I still prefer today.

Now, some folks on the Internet put their faith in C++.
They swear that it's so powerful, it's what God used for us.
And maybe it lets mortals dredge their objects from the C.
But I think that explains why only God can make a tree.

For God wrote in Lisp code
When he filled the leaves with green.
The fractal flowers and recursive roots:
The most lovely hack I've seen.
And when I ponder snowflakes, never finding two the same,
I know God likes a language with its own four-letter name.

Now, I've used a SUN under Unix, so I've seen what C can hold.
I've surfed for Perls, found what Fortran's for,
Got that Java stuff down cold.
Though the chance that I'd write COBOL code
is a SNOBOL's chance in Hell.
And I basically hate hieroglyphs, so I won't use APL.

Now, God must know all these languages, and a few I haven't named.
But the Lord made sure, when each sparrow falls,
that its flesh will be reclaimed.
And the Lord could not count grains of sand with a 32-bit word.
Who knows where we would go to if Lisp weren't what he preferred?

And God wrote in Lisp code
Every creature great and small.
Don't search the disk drive for man.c,
When the listing's on the wall.
And when I watch the lightning
Burn unbelievers to a crisp,
I know God had six days to work,
So he wrote it all in Lisp.

Yes, God had a deadline.
So he wrote it all in Lisp.

Bhaal fucked around with this message at 20:34 on Oct 27, 2011

qntm
Jun 17, 2009
Well if we're going down this road I might as well also roll out The Story Of Mel, which is simultaneously a heartwarming free verse tale of hardcore coder skill of days gone by, and a coding horror story about the unmaintainable rat's nest of code that Mel clearly left in his wake, everywhere he went.

ToxicFrog
Apr 26, 2008


Plorkyeran posted:

Grading is awesome because you get to punish people for writing terrible code rather than having to just sigh and put up with it.

Grading is terrible, because you realize that of the 20 people registered for the course, only 16 bothered to commit a solution at all.

And of those 16, only one implemented the spec correctly. Over half, on the other hand, submitted something that does not actually run (except in the most charitable sense that "the OS successfully loads the executable").

And all of these are third-year students who have somehow passed several programming courses.

:suicide:

(My favorite failure mode was the two programs that are somehow written in such a way that only absolute paths work on the command line. How is that even possible? It's harder to do it that way than to accept both absolute and relative paths!

I say "was" because today it was superseded by the program that doesn't check how many nodes are available, and instead starts by assuming it can only create 1 process and then doing some math that results in it trying to create -1 processes and crashing.)

baquerd
Jul 2, 2007

by FactsAreUseless

ToxicFrog posted:

Grading is terrible, because you realize that of the 20 people registered for the course, only 16 bothered to commit a solution at all.

And of those 16, only one implemented the spec correctly. Over half, on the other hand, submitted something that does not actually run (except in the most charitable sense that "the OS successfully loads the executable").

And all of these are third-year students who have somehow passed several programming courses.

This is only a problem when you have academic/political pressure to pass a certain percentage.

ToxicFrog
Apr 26, 2008


baquerd posted:

This is only a problem when you have academic/political pressure to pass a certain percentage.

We don't. And I didn't say it was a problem.

It's just drat depressing. :sigh: Are they that clueless? If so, how did they pass the previous courses? Do they just not care? If so, why did they sign up for this course?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

loinburger posted:

Same industry. Another piece of code I had to rewrite from the same contractor was the box-packing algorithm - the way the contractor's code put items in boxes was "If the items' dimensions fit in the empty box, and there is sufficient unused volume in the box, then the item fits!" In other words, given a 12x12x12 box (volume 1728) and three 8x8x8 items (combined volume 1536), the algorithm would put all three items in the box, even though this is sort of impossible.

When I rewrote the algorithm to prevent overlapping boxes, the QA guy on the project complained that the new algorithm used more box volume than the old algorithm.

loin: That's because the old algorithm allowed boxes to overlap.
QA Guy: Well, we never worried about overlapping boxes before.
loin: I suggest we start worrying about it.

Heh, I had a similar problem when coding a cost-estimator for the various shipment types. The solution before we put in company specific algorithms? Use the dimensions and weight of the assembled product. So an ikea style desk would estimate at 300% because its assembled size is so much greater than its flat pack size.

Mind you some of those company specific solutions were a horror unto themselves. Dim factors for some, LxHxDxWx<magic number> for others. I tell you one thing though, NMFC codes and old school EDI parsers are the real loving horror.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

baquerd posted:

This is only a problem when you have academic/political pressure to pass a certain percentage.
Even then you can sometimes try your hardest to convince them they're going to fail and trick them into withdrawing from the class. Making them cry in the process is optional.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

ToxicFrog posted:

Grading is terrible, because you realize that of the 20 people registered for the course, only 16 bothered to commit a solution at all.

"Only" 80%? Fewer than half of the students of first-year mathematics courses that I teach examples classes for bother to hand in the set work for marking. In fairness, in my department that work doesn't count towards the grade (it is all on the exam at the end).

Also, I know this is a thread for people to blow off steam, but some of you sound like you have utterly terrible attitudes towards teaching.

ToxicFrog
Apr 26, 2008


Hammerite posted:

"Only" 80%? Fewer than half of the students of first-year mathematics courses that I teach examples classes for bother to hand in the set work for marking. In fairness, in my department that work doesn't count towards the grade (it is all on the exam at the end).

This assignment is worth 10% of their final grade. Yeah, that's peanuts compared to the term project or the exam, but it's not something I'd expect people to blow off lightly either.

Ursine Catastrophe
Nov 9, 2009

It's a lovely morning in the void and you are a horrible lady-in-waiting.



don't ask how i know

Dinosaur Gum

Hammerite posted:

"Only" 80%? Fewer than half of the students of first-year mathematics courses that I teach examples classes for bother to hand in the set work for marking. In fairness, in my department that work doesn't count towards the grade (it is all on the exam at the end).

Also, I know this is a thread for people to blow off steam, but some of you sound like you have utterly terrible attitudes towards teaching.

To be fair, I think that's why a lot of us aren't teaching. I know I personally don't have the patience for it; it's bad enough when something as theoretically logical and rule-following as a computer starts throwing poo poo fits.

baquerd
Jul 2, 2007

by FactsAreUseless

OriginalPseudonym posted:

To be fair, I think that's why a lot of us aren't teaching. I know I personally don't have the patience for it; it's bad enough when something as theoretically logical and rule-following as a computer starts throwing poo poo fits.

Have you ever seen a computer not be logical and rule following? Excepting hardware failure I mean.

TasteMyHouse
Dec 21, 2006
Even hardware failures are perfectly logical and rule following -- if you understand the rules.

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

baquerd posted:

Have you ever seen a computer not be logical and rule following? Excepting hardware failure I mean.

No, but a system call might which is just as bad.

Zombywuf
Mar 29, 2008

TasteMyHouse posted:

Even hardware failures are perfectly logical and rule following -- if you understand the rules.

Tell me that when you've got an IP address conflict.

tef
May 30, 2004

-> some l-system crap ->

qntm posted:

Well if we're going down this road I might as well also roll out The Story Of Mel, which is simultaneously a heartwarming free verse tale of hardcore coder skill of days gone by, and a coding horror story about the unmaintainable rat's nest of code that Mel clearly left in his wake, everywhere he went.

I want to believe

Ursine Catastrophe
Nov 9, 2009

It's a lovely morning in the void and you are a horrible lady-in-waiting.



don't ask how i know

Dinosaur Gum

baquerd posted:

Have you ever seen a computer not be logical and rule following? Excepting hardware failure I mean.

To be fair, every issue has a sane and logical reason for happening, but those reasons don't necessarily have to be sane and logical. For example, if you have a cron script that cleans up your server by rm -rfing every file with a ".swp" extension at midnight on alternate tuesdays, then that will cause issues, and if you don't know about the script, then you'll have no idea why it's happening.

Or if someone decides that the fan in their computer is making too much noise and pulls it out, thus leading to overheating and irrational behavior.

The irritation generally stems from attempting to find the reason for it, assuming that you have the time and resources necessary to, but occasionally irrational behavior is too deeply embedded to do anything but work around (like, for example, when you have a 10 gig codebase that's maintained in sourcesafe, and occasionally sourcesafe says "this checkout is too large" and stops doing the checkout with a messagebox that simply states "(NULL)").

loinburger
Jul 10, 2004
Sweet Sauce Jones

Scaramouche posted:

Heh, I had a similar problem when coding a cost-estimator for the various shipment types. The solution before we put in company specific algorithms? Use the dimensions and weight of the assembled product. So an ikea style desk would estimate at 300% because its assembled size is so much greater than its flat pack size.

Mind you some of those company specific solutions were a horror unto themselves. Dim factors for some, LxHxDxWx<magic number> for others. I tell you one thing though, NMFC codes and old school EDI parsers are the real loving horror.
I checked around online to see how other people were solving the problem, and was surprised at the number of people who were brute-forcing it. I had a quarter-second deadline to come up with an estimate for 50 items, so brute force obviously wasn't going to work.

Eventually we came up with a way to split up the box's free space after putting in an item, e.g. after putting an 8x8x8 item in a 12x12x12 box you've got an 8x8x4 free space, a 12x8x4 free space, and a 12x12x4 free space; that way we could still use the free space without running into the problem of overlapping items

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Zombywuf posted:

Tell me that when you've got an IP address conflict.

That has absolutely nothing to do with hardware failure (e.g. capacitors exploding, dielectric breakdown and electromigration in CMOS transistors, very noisy inputs to a crappy power supply causing odd spikes in voltage at seemingly-random intervals).

brosmike
Jun 26, 2009

loinburger posted:

I checked around online to see how other people were solving the problem, and was surprised at the number of people who were brute-forcing it. I had a quarter-second deadline to come up with an estimate for 50 items, so brute force obviously wasn't going to work.

Eventually we came up with a way to split up the box's free space after putting in an item, e.g. after putting an 8x8x8 item in a 12x12x12 box you've got an 8x8x4 free space, a 12x8x4 free space, and a 12x12x4 free space; that way we could still use the free space without running into the problem of overlapping items

This might be acceptable for your application, but a naive implementation of this sort won't be able to achieve optimal solutions in a few cases. In the example you cited, for example, you might have a hard time detecting that an 8x8x8 and 3 12x8x4s will fit.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

SlightlyMadman posted:

"svn blame" is possibly the best thing to ever have happened in computer history.

Testers found that (old) poo poo's broken when they were testing my new component. Blame to the rescue. Wasn't my fault. Another dude had changed the Makefile and it was no longer copying the old component from the source tree to the build environment.

brosmike posted:

This might be acceptable for your application, but a naive implementation of this sort won't be able to achieve optimal solutions in a few cases. In the example you cited, for example, you might have a hard time detecting that an 8x8x8 and 3 12x8x4s will fit.

http://en.wikipedia.org/wiki/Bin_packing_problem

Yeah, it's not easy.

loinburger
Jul 10, 2004
Sweet Sauce Jones
Yeah, we had no hope of finding the optimum. Instead we wrote the algorithm so that it more-or-less randomized the order in which items were packed, the item rotations, and the way that free space was partitioned, and then ran a few hundred iterations of it and returned the best result. (For fifty items were could run about 500 iterations and still fall within the quarter-second deadline; for fewer items we increased the number of iterations accordingly)

Beef
Jul 26, 2004

pokeyman posted:

Ah yes, I can see it now..



"Beauty and Rage", Museum of Modern Programming, 2011.

Allow me to contribute with something I found, in honor of McCarthy:

code:
Here lies a Lisper
Uninterned from this mortal package 
Yet not gc'd
While we retain pointers to his memory

qntm
Jun 17, 2009

TasteMyHouse posted:

Even hardware failures are perfectly logical and rule following -- if you understand the rules.

You mean... physics?

TasteMyHouse
Dec 21, 2006

qntm posted:

You mean... physics?

Yeah, that was my point (though I was specifically thinking of materials science, electronics, signals and systems, etc); although computers are "logical and rule following" that doesn't help you when the logic and the rules are obscure or beyond easy comprehension.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Smugdog Millionaire posted:

How do you write 100,000 lines of code in a single file before you think to yourself "surely there's a better way to organize this"?

A former coworker of mine learned the hard way that VB6 can't load more than 65,534 lines of code in a single module. To give you an idea of how terrible the code was: whenever he received data with a deeper level of recursion than his program could support, he added another nested while loop to all of his functions.

anagramarye
Jan 2, 2008

Array Age Man

DaTroof posted:

whenever he received data with a deeper level of recursion than his program could support, he added another nested while loop to all of his functions.

:psypop:

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

DaTroof posted:

A former coworker of mine learned the hard way that VB6 can't load more than 65,534 lines of code in a single module. To give you an idea of how terrible the code was: whenever he received data with a deeper level of recursion than his program could support, he added another nested while loop to all of his functions.

I'm not really sure what is worse here: that you need to load that many lines, that they apparently used a 16 bits integer even though I'm pretty loving sure VB6 never ran on 16 bits platforms, or that the number of lines is 65,534 and not 65,535.

EDIT: Actually I guess it would make sense that you'd code your for loop as < 65,535, so nevermind on that last one.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
VB supported 16-bit through 4.0 and I doubt it got a full rewrite when it went 32-bit only so some lingering 16-bitisms isn't surprising. Excel being limited to 65536 rows until 2007 is quite a bit worse.

Zhentar
Sep 28, 2003

Brilliant Master Genius
VB 4.0 was also the first version to support 32-bit (since there was no 32-bit Windows for previous versions to support).

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Plorkyeran posted:

Excel being limited to 65536 rows until 2007 is quite a bit worse.

1) The Excel binary format has roots in classic MacOS. The 128k mac had a 32-bit processor, but at the time saving two bytes per cell index was pretty significant.

2) I vehemently believe that anyone who wants more than 65,536 rows in an Excel worksheet is a Bad Person in the same way as someone with 120,000 lines of code in a single file.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Internet Janitor posted:

2) I vehemently believe that anyone who wants more than 65,536 rows in an Excel worksheet is a Bad Person in the same way as someone with 120,000 lines of code in a single file.
Excel happens to be a pretty good way to view things like CSV-formatted log files.

evensevenone
May 12, 2001
Glass is a solid.
Happens a lot when you're an ME who does a lot of data logging with lovely tools that just save big CSV files and whose boss won't let you have matlab or anything nice :(

Thank god that life is over.

fez2
Jan 24, 2002

Just got another one of these today at work.

code:
CALL BANK-VALIDATION-MODULE USING ... FIF-COMM-AREA

EVALUATE FIF-RTN-CD (1)
WHEN 0
  CONTINUE
WHEN 1
  SET INVALID-BANK-AND-BRANCH-NBR TO TRUE
WHEN 2
  SET INVALID-BANK-ACCT TO TRUE
END-EVALUATE
Of course the call doesn't work at all and it's falling through the evaluate. This bug has been live for 2 years and no one noticed because COBOL developers don't really test anything. It's embarrassing.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

YeOldeButchere posted:

I'm not really sure what is worse here: that you need to load that many lines, that they apparently used a 16 bits integer even though I'm pretty loving sure VB6 never ran on 16 bits platforms, or that the number of lines is 65,534 and not 65,535.

The VB limitations were unfortunate, but that guy's code was definitely the worst part of it. There was absolutely no excuse for that module to be more than 5000 or so lines of code. Copy/paste was his version of Maslow's hammer.

PrBacterio
Jul 19, 2000

fez2 posted:

Just got another one of these today at work.

code:
CALL BANK-VALIDATION-MODULE USING ... FIF-COMM-AREA

EVALUATE FIF-RTN-CD (1)
WHEN 0
  CONTINUE
WHEN 1
  SET INVALID-BANK-AND-BRANCH-NBR TO TRUE
WHEN 2
  SET INVALID-BANK-ACCT TO TRUE
END-EVALUATE
Of course the call doesn't work at all and it's falling through the evaluate. This bug has been live for 2 years and no one noticed because COBOL developers don't really test anything. It's embarrassing.
I'm sorry, is it bad that I just can't look beyond the horror of actually using COBOL at all in the first place to whatever it is you're trying to show to us here? :stare:

Zombywuf
Mar 29, 2008

Internet Janitor posted:

2) I vehemently believe that anyone who wants more than 65,536 rows in an Excel worksheet is a Bad Person in the same way as someone with 120,000 lines of code in a single file.

Er, should we just truncate our datasets if they get to big?

(of course the real horror is trying to do anything on windows)

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Should we just truncate our source files if they get too big?

Basically if you have a dataset that big you should be looking at different tools and approaches than Excel.

Zombywuf
Mar 29, 2008

Internet Janitor posted:

Basically if you have a dataset that big you should be looking at different tools and approaches than Excel.

Name one and why I should use it.

Adbot
ADBOT LOVES YOU

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
-Put your dataset in a database and use a query language to find out what you actually want to know. It will consume fewer system resources, be less likely to lock up for minutes at a time and your results will be repeatable. Even interactively, if you can search and filter data more quickly, you can extract more information from it.

-Use a programming language meant for data processing. R, for example, can easily deal with millions of rows of data in a fraction the time and space Excel would require.

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