|
Bozart posted:I'll have you know that I'm a fictional programmer! Indeed. That must mean I'm a complex programmer: one with both real and imaginary parts.
|
# ? Oct 4, 2010 19:01 |
|
|
# ? May 14, 2024 22:10 |
|
yaoi prophet posted:Net::CUPS loving sucks. In order to get information about a specific job, you have to call getJob, which internall calls the cupsGetJobs C function to get a list of every print job that the printer knows about, then iterates over it to find the appropriate job by checking the jobid. Now, to be fair, this isn't its fault, since CUPS doesn't provide any 'tell me about job N'. What is its fault is that a: there's no sign at all that getJob has this kind of behavior, and b: there's no 'get all jobs'/'get all queued jobs' function, which would be trivial to write using the CUPS API. Instead, you have to call getJobs, which returns the appropriate list of job IDs, then loop over it. Which will wind up being O(n^2) in the number of jobs in the print queue for something that should be an O(n) operation. It's a good thing you can fix it! Not sure if it would make sense to provide a function to slurp all the CUPS jobs into a hash for faster lookup later or whether you'd have cache invalidation issues (unfamiliar with CUPS), but I'm sure you'll work something out!
|
# ? Oct 4, 2010 19:04 |
|
I'm seeing this poo poo everywherecode:
|
# ? Oct 5, 2010 21:06 |
|
Bozart posted:I'll have you know that I'm a fictional programmer! Is that the same as being a programming nihilist? I don't know if this has been posted yet, presenting the regex from hell http://ex-parrot.com/~pdw/Mail-RFC822-Address.html How to validate email address? posted:
|
# ? Oct 5, 2010 22:09 |
|
A very bad man posted:Is that the same as being a programming nihilist? I think that gets posted every 16th page.
|
# ? Oct 5, 2010 23:14 |
|
Ugg boots posted:I think that gets posted every 16th page. Like do{ }while(0) instead of goto, and Hungarian notation. And MUMPS.
|
# ? Oct 6, 2010 00:23 |
|
nbv4 posted:I'm seeing this poo poo everywhere I can't really cast aspersions, because I pretty much just realized that %r prints the repr and %s casts the string for you.
|
# ? Oct 6, 2010 00:29 |
|
Today this was my friend:code:
|
# ? Oct 6, 2010 01:36 |
|
Maybe he was into constructivism
|
# ? Oct 6, 2010 01:51 |
|
I was going to put together an effortpost on Matlab - to actually contribute for a change - but I am far too lazy to do it justice. Some highlights are still in order: There is no built-in date class. Almost all Matlab functions and toolboxes either have to be told that a number is a date externally or assume that numbers within a certain range of numbers are dates. There is no built-in string class. You can either use arrays of characters or you can use "cell arrays" of characters, where cell arrays are composed of cells, which can each contain arrays of one class. So a cell array can have any number of types in 2 or more dimensions. Since matlab doesn't have a string class, they threw in a special case of cell arrays called a "cellstr" which is of course, a cell array of character arrays. The kicker? The edge cases are all wrong. An empty cell array is still a cellstr, even though it has no cell arrays in it. A cellstr, unlike all other types (or the pseudotype that this is) does not define equals, but it does define set membership. So a call of code:
code:
Also, speaking of true, false, and all other keywords: you can define variables locally that override them. Yes, that's right. If you want to set true = 0 and false = 1, you can do it. Should you ever do it? Of course not. Have I ran into code with sets false = 1? Yes, in the "Bayesian Network Toolbox". Have I ran into code at my work where someone has overwritten the most primitive functions? Yes. There are other more in depth but it would take some 'splaining. Long story short? Even numpy, which is just imitating this monster, is better at doing the exact same things by simple virtue of getting simple poo poo right.
|
# ? Oct 6, 2010 02:00 |
|
A very bad man posted:regex from hell If you're going to bring it up again, you should at least mention that that mess doesn't actually validate email addresses- it just inlines a recursive loop that should be infinite several times.
|
# ? Oct 6, 2010 02:53 |
|
I need to nullify an if...then loop across several hundred files on several remote servers, with the contents of the loop changing slightly (so no easy search/replace). That and it's several dozen lines long. Lord help me I'm considering just replacing the triggering If for all of them with:code:
|
# ? Oct 6, 2010 03:06 |
|
When I first started working with my current company some contractor had put in this piece of code. A couple of other contractors saw the code as pretty good and had put it everywhere they needed to convert to integer.code:
|
# ? Oct 6, 2010 03:09 |
|
Daald posted:
"Okay. I've got it! I've successfully parsed the integer, and the value is--" NO! WAIT! You said you were able to parse the integer? "Yes..." Alright, I want you to parse the same integer again, and let me know what you get.
|
# ? Oct 6, 2010 03:20 |
|
Internet Janitor posted:If you're going to bring it up again, you should at least mention that that mess doesn't actually validate email addresses- it just inlines a recursive loop that should be infinite several times. It's also a horror because there are several parts of the regex that get repeated over and over that could be broken out into variables and then inserted for extra legibility. Hell, if you did that it might even make it readable. Otto Skorzeny posted:It's a good thing you can fix it! Not sure if it would make sense to provide a function to slurp all the CUPS jobs into a hash for faster lookup later or whether you'd have cache invalidation issues (unfamiliar with CUPS), but I'm sure you'll work something out! gently caress no I'm not learning perl's C FFI. Opinion Haver fucked around with this message at 04:35 on Oct 6, 2010 |
# ? Oct 6, 2010 04:33 |
|
yaoi prophet posted:It's also a horror because there are several parts of the regex that get repeated over and over that could be broken out into variables and then inserted for extra legibility. Hell, if you did that it might even make it readable. That's actually just the final regex and it's really just the author joking around and showing off in the documentation. The actual source code in the Perl module that builds the regex looks like this: code:
|
# ? Oct 6, 2010 06:14 |
|
yaoi prophet posted:gently caress no I'm not learning perl's C FFI. Good thing you don't have to
|
# ? Oct 6, 2010 07:00 |
|
Orzo posted:I want you to try to parse this integer. I think the funniest thing was him naming that variable "wastedSpace". I can already see his reasoning. 1. Hey I need to parse this string to integer. 2. Wouldn't it be nice if I found a function that tells me if it is a valid string? 3. Let me see if I find it...ohh there is one...tryparse...looks like it. 4. WTF? It needs me to pass it an integer...WTF for? Ahh well stupid MS api. Here is your stupid variable. 5. Cool, I can parse it. Now let me call the parse function.
|
# ? Oct 6, 2010 15:30 |
|
Daald posted:I think the funniest thing was him naming that variable "wastedSpace". I can already see his reasoning. To compound it even further the signature of the method is TryParse(string s, out int result). Hmm... what could result possibly mean... oh well whatever time to call Parse and store the value in my local variable named result.
|
# ? Oct 6, 2010 17:29 |
|
In an otherwise very well-written testing class (edited for brevity):code:
Reformed Pissboy fucked around with this message at 18:14 on Oct 7, 2010 |
# ? Oct 6, 2010 18:38 |
|
Space Prostitute posted:
Where exactly is the again: label that it's going to?
|
# ? Oct 6, 2010 20:35 |
|
Space Prostitute posted:... I had something like this today. I saw a function call in some VB code I was working with, and right click->definition'd to see what it was doing (the name was not helpful). I was presented with a 300 line function that did...stuff with an Access database. Using many nested for loops and a total of 13 temp tables. All of which had names like "temp3," "tempM," and "temptemp." The first one used was temp3. Did I mention the three gotos? There was a comment at the top explaining what the code did. I made a note of it, and pretended I never scrolled down past that. I mean, it works, but jesus christ. The code I was looking at was sane. It's like Visual Studio goatsed me. Blue Footed Booby fucked around with this message at 02:18 on Oct 7, 2010 |
# ? Oct 7, 2010 02:10 |
|
code:
|
# ? Oct 7, 2010 08:26 |
|
code:
This type of poo poo is all over this project that was handed off to me to optimize. Also: code:
Going to school to be a nurse. 15 years of this loving poo poo...
|
# ? Oct 7, 2010 13:28 |
|
dwazegek posted:
I'm assuming you mean something besides the argument names.
|
# ? Oct 7, 2010 14:03 |
|
gibbed posted:Why is this a horror? Default parameter value is null. Calling DoSomething(someVal) will throw an exception. Calling the method as designed will break. loving HORRIBLE PROGRAMMERS!
|
# ? Oct 7, 2010 14:10 |
|
gibbed posted:Why is this a horror? Real horror spotted.
|
# ? Oct 7, 2010 14:33 |
|
oneinchhard posted:
|
# ? Oct 7, 2010 14:34 |
|
Well, if you don't think SQL injection is a horror…
|
# ? Oct 7, 2010 14:44 |
|
Orzo posted:Why are either of these 'horrors?' Lesson 1: L2STRONGLYTYPEDLANGUAGE You see SomeString1 is ALREADY A loving STRING. There is no need to call ToString(). Might as well do this: code:
code:
|
# ? Oct 7, 2010 14:55 |
|
king_kilr posted:Real horror spotted. Shut up I also missed that the default parameter value is null.
|
# ? Oct 7, 2010 15:06 |
|
oneinchhard posted:
For some reason I see this in contractor code ALL THE TIME. Apparently contractors are really really enthusiastic about toString'ing strings.
|
# ? Oct 7, 2010 17:30 |
|
Maybe it's out of habit from calling ToString() on everything else. Who needs any other data type? Strings are simple and easy to understand!
|
# ? Oct 7, 2010 18:08 |
|
Kilson posted:Where exactly is the again: label that it's going to? My bad, it should be to tryAgain, five lines up. I should add that's the only goto statement in the entire project
|
# ? Oct 7, 2010 18:17 |
|
Hah, I wasn't even thinking of SQL injection; I was more focused on the unnecessary use of StringBuilder for that particular set of strings. But for the first one, oneinchhard, yes, I understand why it's wrong. I just don't think it's a 'horror.' In fact, it's completely harmless and could easily have been introduced through a quick refactoring.
|
# ? Oct 7, 2010 18:29 |
|
Space Prostitute posted:In an otherwise very well-written testing class (edited for brevity): This is funny as hell!! 1. Using goto where a do while loop would serve the same function and immediately the next statement is a do while loop. 2. The next do while loop only runs once since it is (while(false)) and is only there so the "break" statements work. If he had used the great concept known as else or at least did what he did in part 1 and used a goto it would have at least been consistent.
|
# ? Oct 7, 2010 21:08 |
|
I came across this gem today at work (in Ruby).code:
|
# ? Oct 7, 2010 21:29 |
|
I don't really see that being a horror, just someone was probably quickly doing something. It's harmless.
|
# ? Oct 7, 2010 22:39 |
|
I'm currently porting a program from a system to another and I've noticed a large number of sql views selecting from views, that select from views, that select from views. These 'parent' views aren't being used in many places so it doesn't seem like it was a calculated decision to make the hierarchy more simple to update. This is nasty as hell. EDIT: I considered posting the code but it's will make you bleed from the eyes. A very bad man fucked around with this message at 06:40 on Oct 8, 2010 |
# ? Oct 8, 2010 06:37 |
|
|
# ? May 14, 2024 22:10 |
|
A very bad man posted:I'm currently porting a program from a system to another and I've noticed a large number of sql views selecting from views, that select from views, that select from views. These 'parent' views aren't being used in many places so it doesn't seem like it was a calculated decision to make the hierarchy more simple to update. Are any of the views materialized?
|
# ? Oct 8, 2010 11:16 |