|
Bonus posted:I see someone has been reading Schrödinger's book on programming. Don't worry, the software is working perfectly in another universe. Edit: Some of my old code: code:
code:
very fucked around with this message at 15:19 on Mar 22, 2008 |
# ? Mar 22, 2008 15:06 |
|
|
# ? Apr 19, 2024 12:58 |
|
The single greatest argument in VB.NETcode:
Another gem: code:
|
# ? Mar 22, 2008 16:17 |
|
One of the guys who worked on my project before I got there was a great coder, but an absolutely horrible speller. I'm constantly finding variables or methods named catagory, assistint, lisence, componint, and crap like that. I never thought people would need spellchecking in an IDE, but man did this guy need SOMETHING. It's not so bad in the Java code because it's pretty obvious when you're accessing something that doesn't exist, but in the client code and legacy web services it's a bitch sometimes. Every once in awhile I'll wonder why data coming from the service is undefined, and it'll end up being I was expecting category rather than catagory or license instead of lisence. And naturally since it's a service we can't just go and change the definitions, because other people might be depending on it. So I'm stuck writing things like getLisenceId() just so it's consistent at least.
|
# ? Mar 22, 2008 22:06 |
|
At my last job, we hired a guy who was supposed to be pretty good at...well...some technology. I won't say which, because you'd be able to figure out who it is. In fact, he was one of the coauthors of the O'Reilly book on it, so we assumed he really knew his stuff. Our product was written in Java, and he was supposed to write the section dealing with this technology. 2 days before we were supposed to code freeze, he's freaking out, saying that nothing works and he can't figure out why. I look at his code. First clue something was wrong: he's storing EVERYTHING as strings. Integer return codes? Strings! Boolean values? "True" and "False". Casting them to ints or bools every time he needs to use them, which is pretty often. Sometimes the casting was insane. I would see things like this: code:
code:
I spent the next 2 days and nights trying to figure out what the guy's code was really supposed to do, finding all the copy-pasted code, refactoring, and getting rid of the numerous unnecessary "factory" classes and abstract classes that he tried using in his failed attempts to get his code to work.
|
# ? Mar 22, 2008 22:30 |
|
such a nice boy posted:
We used to have a control that could display multiple other controls in a grid, which we used to display multiple video streams simultaneously. For whatever reason, if you changed the number of cells in the grid from (e.g.) 4 to 6, the control would first switch to 5 cells, and then to 6. Also, if you wanted less cells than you had, it word reset itself to 1 cell, and then count up until it reached the desired amount. Turns out the resizing code looked something like this: code:
code:
Seems that the reason why it always counted up when adding controls, was that for case N to work, case N - 1 had to have run.
|
# ? Mar 22, 2008 23:20 |
|
dwazegek posted:
No. Strings are immutable, so any changes made inside the method don't apply to result anymore. Never mind the fact that result will never equal "worked" since they will never point to the same object, and he should have used .equals.
|
# ? Mar 23, 2008 02:24 |
|
such a nice boy posted:What's wrong with that code? Is it just that Yes, that's why it was insane. I wanted to branch based on which number was higher (i.e., if(_a > _b) ). My code requires more work, breaks for cases where an argument is negative, and obviously relies on _b not being zero. That's why it was such a wtf for me. I don't even remember writing it, but source control doesn't lie.
|
# ? Mar 23, 2008 04:21 |
|
such a nice boy posted:I walked over to my manager's office and showed him the code. His jaw almost hit the ground.
|
# ? Mar 23, 2008 06:33 |
|
First day on my new job, confronted with this: INSERT INTO Applications ( Password, AccessLevel, MemberNum, MemberType, MemberExpiry, PCExpiry, AccountCreated, Title, FirstName, LastName, Gender, Lang, BirthdayMonth, BirthdayDay, BirthdayYear, HomePhone, WorkPhone, MobilePhone, FAX, Email, Street, Apartment, PostalCode, City, Province, Country, MailingSame, MailStreet, MailApartment, MailPostalCode, MailCity, MailProvince, MailCountry, Sport, Passport, , L2F, L2FMonth, L2FYear, L2FSport, L3F, L3FMonth, L3FYear, L3FSport, L4R, L4RMonth, L4RYear, L4RLocation, L4F, L4FMonth, L4FYear, L4FSport, NCID, NCIDMonth, NCIDYear, NCIDLocation, L5F, L5FMonth, L5FYear, L5FSport, Uni1Name, Uni1FromMonth, Uni1FromYear, Uni1ToMonth, Uni1ToYear, Uni1Program, Uni1Degree, Uni2Name, Uni2FromMonth, Uni2FromYear, Uni2ToMonth, Uni2ToYear, Uni2Program, Uni2Degree, Equivalence, Course1Name, Course1FromMonth, Course1FromYear, Course1ToMonth, Course1ToYear, Course1Degree, Course2Name, Course2FromMonth, Course2FromYear, Course2ToMonth, Course2ToYear, Course2Degree, WorkedGames, WorkedOlympics, WorkedParalympic, WorkedCommonwealth, WorkedPanam, WorkedCanada, International, IntAthlete, IntSeries, IntFromMonth, IntFromYear, IntToMonth, IntToYear, Emp1ActiveYear, Emp1WeekHours, Emp1YearMonths, Emp1EverFullTime, Emp1EverLocation, Emp1EverFromMonth, Emp1EverFromYear, Emp1EverToMonth, Emp1EverToYear, Emp1Name, Emp1FromMonth, Emp1FromYear, Emp1ToMonth, Emp1ToYear, Emp1Position, Emp1FullTime, Emp1Street, Emp1Apartment, Emp1City, Emp1Province, Emp1PostalCode, Emp1Contact, Emp1Phone, Emp1Income, Emp2Name, Emp2FromMonth, Emp2FromYear, Emp2ToMonth, Emp2ToYear, Emp2Position, Emp2FullTime, Emp2Street, Emp2Apartment, Emp2City, Emp2Province, Emp2PostalCode, Emp2Contact, Emp2Phone, Emp2Income, Emp3Name, Emp3FromMonth, Emp3FromYear, Emp3ToMonth, Emp3ToYear, Emp3Position, Emp3FullTime, Emp3Street, Emp3Apartment, Emp3City, Emp3Province, Emp3PostalCode, Emp3Contact, Emp3Phone, Emp3Income ) VALUES ('','member','','Associate Member','7/2/2009','3/3/2010','6/2/2008','Mr.','Fake','Fakington',0,1,0,0,0,'','','','','fake@gmail.com','','','','','','0',0,'','','','','','0','0','',0,0,0,'0',0,0,0,'0',0,0,0,'',0,0,0,'0','0',0,'0',0,0,0,0,'','',0,0,0,0,'','','',0,0,0,0,'','',0,'',0,0,0,0,'','',0,0,0,0,'',0,0,0,0,0,0,'','',0,0,0,0,'',0,0,0,0,0,'',0,0,0,0,0,0,0,'',0,'','','','','','','',0,'',0,0,0,0,'',0,'','','','','','','',0,'',0,0,0,0,'',0,'','','','','','','',0) Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ','.
|
# ? Mar 23, 2008 19:09 |
|
I got a call because a website I'd written a while back was "broken in IE fix it now". Some other guy had been making changes to the site and had no idea what was broken, so I figured it was easier just to fix all the rendering bugs by adding a conditional stylesheet than to try to track down his changes. I spent about half an hour hacking together fixes for everything before I realized what the problem was. He had removed the doctype and <html> tag entirely, sitewide, which sent IE into quirks mode and subsequently some kind of horrible deathspin. To date I have no idea what his rationale for doing that could have been.
|
# ? Mar 23, 2008 19:20 |
|
bitreaper posted:... Passport, , L2F, ... It's funny; I laughed at the error message, then noticed what I imagine is the error (quoted) one second later. Why can't I do that with my own code...
|
# ? Mar 23, 2008 21:08 |
|
pokeyman posted:It's funny; I laughed at the error message, then noticed what I imagine is the error (quoted) one second later. Weird, that's exactly what I did; I ran it through a validator and it just told me there was an error on line 1, then I noticed the double comma.
|
# ? Mar 23, 2008 21:25 |
|
At my old job some one once wrote:code:
-- Ratty
|
# ? Mar 23, 2008 23:06 |
|
Ratty posted:At my old job some one once wrote: He was SO close to independently developing the FOR-CASE paradigm -- Ratty
|
# ? Mar 24, 2008 01:06 |
|
Jethro posted:He was SO close to independently developing the FOR-CASE paradigm I have seen this a couple times in code at work and i fail to understand HOW people come up with this. And then afterword not realize that they could just have put all the statements in a row? Am I missing something here? At my work we have an office in Russia. Now normally the people there are fine coders, but one person (who had left before I got there) has yet to show me an example of good coding. She would use variables like zzzz, zzz, zz, z, vvvv, vvv, vv and v in one javascript document. Not to mention table layouts and image slices on a web page built 10 months ago.
|
# ? Mar 24, 2008 03:27 |
|
aeiou posted:I have seen this a couple times in code at work and i fail to understand HOW people come up with this. And then afterword not realize that they could just have put all the statements in a row? Am I missing something here? Being in a loop, you get to make use of the break keyword, and you have an iterator variable (i) which indicates which step was achieved... I used it once or twice like that anyway.
|
# ? Mar 24, 2008 16:29 |
|
such a nice boy posted:What's wrong with that code? Is it just that The way I see it - what if _b is == 0? Run-time error.
|
# ? Mar 24, 2008 16:59 |
|
Mashi posted:Being in a loop, you get to make use of the break keyword, and you have an iterator variable (i) which indicates which step was achieved... I used it once or twice like that anyway. Are you serious? I have trouble imagining how that's more practical than something like this: code:
|
# ? Mar 24, 2008 17:03 |
|
DaTroof posted:Are you serious? I have trouble imagining how that's more practical than something like this: AI saw it as a way to avoid nesting an IF statement 6 levels deep. I never said it was good I just offered some possible reasoning for doing it. Also I am self taught so yea I used to do alot of weird and zany poo poo...
|
# ? Mar 24, 2008 17:19 |
|
At a previous job, I had to maintain a huge pile of very, very poorly-written PHP for a variety of homebrewed web applications. It had several major problems. First, the guy who wrote it absolutely insisted that all of the code for a given application be in one PHP file. Second, no documentation anywhere. No comments, no notes, no nothing. His variable names... well, see below. Third, he didn't believe in functions. Everything was written as independent procedures, repeated as often as necessary. The only functions I found in his code were obviously cut-and-pasted from example books because they didn't match the rest of his style at all. Fourth (and this is the real horror), he had an include.php file that had hundreds of lines of string replacements for HTML elements. And they looked like this: code:
More often I ended up just throwing out big chunks of his code and replacing it entirely. I really wish I had had time to totally re-do the accounting system before handing it off to my replacement, because giving responsibility over that mess to someone else is probably the worst thing I've ever done to a human being.
|
# ? Mar 25, 2008 00:59 |
|
I saw something like the when I first worked for a client that had an "ecommerce site that is 90% complete, but the developer bailed..." <?php // turn any post or get into a variable... foreach($_REQUEST as $key => $value){ eval($key.' = '.$value); } // wing it if($sql == ""){ } else { mysql_query($sql); } ?> Somehow I knew that 90% was much closer to 9%.
|
# ? Mar 25, 2008 05:19 |
|
Haha. Somehow that reminded me of an ecommerce site I saw at a development firm that eventually went belly up. I think I've been blocking it from my conscious memory for the past few years. * The lead developer declared that ASP was insecure, so everything had to be written as CGI executables in Visual Basic. * He also didn't trust IIS, so the web server was O'Reilly WebSite. The 16-bit free version. * The order database was written in Access. Every order had its own MDB file. When somebody started an order, one of the CGI programs would copy an empty version of the database and populate it with a single order. Every MDB was named for its order number: 1001.mdb, 1002.mdb, etc. * The customer's credit card information was stored in plain text in the MDB. * The web server needed to be restarted several times a day because of a bug that was causing HTTP requests to hang. After a few days, I discovered the problem when I checked the server's monitor. One of the CGI programs was popping a message box with debug information. The process would halt while it waited for someone to click the OK button. * In response to the above problem, the lead developer sincerely suggested that one of us sit next to the server so we could watch for message boxes. The site finally died after 1500 orders, because each order was in a separate 200k MDB file and the server's drive ran out of space. Less than twenty of those orders were actually completed. Most of them were in-house tests. The vast majority only had one or two items in the order. Hundreds of 200k databases that each contained less than 400 bytes of actual data. And of course, after we took the machine offline for an emergency tuneup, it quickly became apparent that someone had compromised it weeks ago. Eight years later, that poor bastard of a client finally has a functional web site, but they still don't take orders online.
|
# ? Mar 25, 2008 06:22 |
|
aeiou posted:I have seen this a couple times in code at work and i fail to understand HOW people come up with this. And then afterword not realize that they could just have put all the statements in a row? Am I missing something here? I think it comes from writing on the fly. Initially you write one statement to be evaluated and everything works fine. Then you have to make a decision if the counter has some other value. So you say if it's value I definitely need to do it this way and if it's value 2 I may need to do it a different way. Then all the sudden the code is done and you realize that you are in essence doing the same thing regardless of value. At this point you may or may not have time to fix it. So I think it's a lack of pre-planning.
|
# ? Mar 25, 2008 13:00 |
|
DaTroof posted:Haha. Somehow that reminded me of an ecommerce site I saw at a development firm that eventually went belly up. I think I've been blocking it from my conscious memory for the past few years. Whenever I feel insecure about my programming skills, there's always a story like this to make me think, "At least I'm not completely retarded."
|
# ? Mar 25, 2008 14:56 |
|
Some gems from an ASP app that I inherited:code:
code:
Imagine at least 25 pages of this at several thousand lines each littered with inline sql, years of uncommented edits, and tons of copied and pasted code and you will see what I work with daily.
|
# ? Mar 25, 2008 15:34 |
|
I posted this before, and by God, I'll post it again. A PHP gem created by a freelancer we hired:code:
Debugging that was an interesting experience in anger control.
|
# ? Mar 25, 2008 15:51 |
|
Eggplant posted:Some gems from an ASP app that I inherited: code:
|
# ? Mar 25, 2008 16:03 |
|
It's not as bad as many of you encountered, but it deserves a post.code:
|
# ? Mar 25, 2008 16:57 |
|
I wrote this. You'll need a decent grasp of x86 assembly to comprehend the horror...code:
|
# ? Mar 25, 2008 19:15 |
|
j4cbo posted:I wrote this. You'll need a decent grasp of x86 assembly to comprehend the horror...
|
# ? Mar 26, 2008 00:48 |
|
j4cbo posted:I wrote this. You'll need a decent grasp of x86 assembly to comprehend the horror... x86 isn't my strong suit, but isn't that basically infinite recursion without overflowing the stack? I guess I'm assuming that 'iret' on its own is a call of some sort.
|
# ? Mar 26, 2008 01:46 |
|
iret is an interrupt vector return. If I'm understanding this right, it's like a hosed up longjmp.
|
# ? Mar 26, 2008 01:56 |
|
This isn't as bad as some of the trainwrecks in here, but it made me scratch my head for a minute.code:
I swear my coworkers aren't idiots. I think this is just a case of coding something out and then not really looking it over once you're done with it.
|
# ? Mar 26, 2008 18:08 |
|
code:
|
# ? Mar 26, 2008 18:47 |
|
Victor posted:
|
# ? Mar 26, 2008 19:08 |
|
Most of the stuff that I find that makes me want to die is far more basic than the other stuff posted so far. Like this:code:
edit: It gets better. Every control on the page is generically named (LinkButton1, LinkButton2, Label3, Label4, etc), and whoever wrote it used at least 4 labels (that I can initially see) instead of validators for error messages. Also, every method has SQL in it, and it's all inline. Better yet, half of it is duplicated from another page. grimace fucked around with this message at 19:55 on Mar 26, 2008 |
# ? Mar 26, 2008 19:33 |
|
_aaron posted:Hahaha, that's pretty awesome. But correct me if I'm wrong here: most of that stuff is .Net 3.5 stuff, right? We are still using vs2005 (but will be upgrading soon), so that doesn't apply to our stuff. When we do make the switch, I will certainly keep this in mind.
|
# ? Mar 26, 2008 21:06 |
|
When I first started my current C# job I hadn't touched HTML for about two years besides one database university course. I had also never touched .NET. I was first asked to convert a simple page from asp to ASP.NET. For some stupid reason I didn't realize that drop down lists had a text and a value property. I ended up creating a "DropDownInfo" class to map the texts displayed to the IDs via two hashtables, and you'd see code all over the place like: code:
|
# ? Mar 27, 2008 08:00 |
|
Victor posted:string Join(string delimiter) is a method I made, because MS didn't include it by default, for some odd reason.) I disagree. string.Join has existed ever since 1.0. MSDN Library posted:
|
# ? Mar 27, 2008 09:56 |
|
|
# ? Apr 19, 2024 12:58 |
|
Notice how the signature between what I posted differs from what you posted. Moreover, mine works on IEnumerable<string> and is an extension method. Here's the definition:code:
|
# ? Mar 27, 2008 10:03 |