|
tef posted:See, where you might use "result" I would use bln_flg_tst_cnd_args_x. Hahahahahahahahahahaha Oh COBOL, you humor me so.
|
# ¿ Mar 22, 2008 02:48 |
|
|
# ¿ Apr 30, 2024 01:50 |
|
ehnus posted:Two that come immediately to mind are breaking out of nested loops in C/C++/C# The one thing I did like about PHP was that they offer the break X construct that lets you break out of nested loops as far as you want.
|
# ¿ Jun 15, 2008 02:22 |
|
jonnii posted:I'm sure this has been mentioned a million times, but I see this EVERY day and it winds me up. I do it because it makes my code look cleaner. I usually don't use == true for if statements whose conditions are method calls, provided that the method has a meaningful name. I'll do, for example, if (m_isOpening == true) { }
|
# ¿ Jun 20, 2008 20:44 |
|
floWenoL posted:C++ is not immune to this. Especially when you use #define bool int
|
# ¿ Jun 24, 2008 00:50 |
|
wolf_man posted:Is there a more elegent/better way of solving this problem ? Probably not using PHP would make it more elegant
|
# ¿ Jul 11, 2008 22:03 |
|
enki42 posted:It's actually pretty easy to hack up an extension method on Object for in if you really want it. I think this should work: Assuming this is C# and not Java (I still can't tell the difference, heh) then you don't need the overloads. You can do: code:
|
# ¿ Aug 27, 2008 17:34 |
|
At work someone wrote this:code:
|
# ¿ Aug 28, 2008 02:06 |
|
RegonaldPointdexter posted:I saw this in some JavaScript yesterday: Just trying to be thread safe!
|
# ¿ Aug 28, 2008 17:05 |
|
Nehle posted:
You don't want to do this. What if two people are accessing the website at the same time? Your two queries are not one atomic operation, meaning that two individuals' INSERT statements could fire and then their two SELECT statements (not always INSERT SELECT INSERT SELECT). Then they'd both get the same result back from LAST_INSERT_ID() which is obviously NOT what you want.
|
# ¿ Sep 6, 2008 20:27 |
|
DaTroof posted:The function returns the last ID inserted on the current connection. As long as those two users' inserts were performed on different connections, they will NOT get the same result from LAST_INSERT_ID(). That's fair then.
|
# ¿ Sep 6, 2008 23:33 |
|
HappyHippo posted:Now that I think about it, that's probably what I did. I was trying to remember without actually having the code to look at. Nice save.
|
# ¿ Sep 8, 2008 22:49 |
|
netcat posted:A friend who interns at some lovely gamedev company around where I live told me they had someone applying for a job, and he sent in a game together with the source code. The code (in C++) was riddled with stuff like this: I like to keep my integers on the heap, too, just on the off chance that if my stack gets corrupted my data (integers) will still be correct.
|
# ¿ Dec 10, 2008 07:01 |
|
shrughes posted:Well regarding 3000 line functions, they're only sensible when the level of complexity is very low, like when 2975 lines are used to fill a static array. Maybe you should be reading in your static array in some other fashion then? I mean I do know of reasons for having that data in code, but there are often times better solutions.
|
# ¿ Dec 23, 2008 02:33 |
|
rotor posted:n&1 is a little weird, but I don't see what makes it a coding horror!! It's at least hardware dependent. Unless it says somewhere in the C++ specification that integers have to be represented exactly as they are commonly today...
|
# ¿ Jan 6, 2009 00:56 |
|
hexadecimal posted:Do you mean 2's compliment instead of sign bit or something? In that case it would still work for all positive numbers. Where does it say that 00000001 is 1? What if hardware specifies that the sign bit is the least significant bit instead of the most significant bit? What if it stores the least significant bit in the highest significant bits place for integers? Edit: Also stop PMing people and get in #cobol, it's more fun.
|
# ¿ Jan 6, 2009 01:00 |
|
Steve French posted:Now, I agree that doing &1 to test for even/odd is silly, but this is a pretty dumb point. If you can't assume something as elementary as that, then bitwise operations quickly become nearly (completely?) useless. No they aren't. They only become useless if you're only doing bitwise operations on integers expecting the bitwise operations to have a result on the numerical representation. In all worlds doing 0xFF & 0x01 would equal 0x01, but not in all numerical representations does the 0x01 bit represent the same thing. What if, for example, a system only had a floating point math processor, so all integers are floating point numbers. Ignoring the precision problems, & 0x01 would not tell you if the number is even or odd, but in all representations it would give you the least significant bit.
|
# ¿ Jan 6, 2009 07:06 |
|
heeen posted:Hahaha better yet, how do you define modulus for float numbers? Ever heard of fmod?
|
# ¿ Jan 7, 2009 17:02 |
|
I did get pretty carried away with the retarded examples, but it's still loving stupid to rely on the representation of something to do something mathy when you have a perfectly good/obvious/understood/optimizable way of doing it, as in this case.
|
# ¿ Jan 7, 2009 17:03 |
|
Painless posted:It won't "bitch", but it's quite possible that it will randomly fail! Just use unions drat it. Where in the C standard does it specify that unioned elements will occupy the same space in memory?
|
# ¿ Jan 7, 2009 20:09 |
|
Edit: Thanks.
|
# ¿ Jan 7, 2009 20:51 |
|
hexadecimal posted:I was really high at the time and was thinking of truth tables instead of normal comparison. I was trying to think of a way to sort the way I did in one line. Are you high now?
|
# ¿ Jan 9, 2009 00:31 |
|
Scaevolus posted:which tends to make useless copies of the object that most compilers are unable to optimize away. Is that like what happens with Quote != Edit?
|
# ¿ Jan 9, 2009 02:48 |
|
I mentioned this in IRC as it was playing out, but I'm sitting in a Computer Science majors computer lab, and there are three guys sitting next to me working on a Perl assignment. I know for a fact they're not freshmen or sophomores but even if they were, ugh. So, they have to take input into their program and want to validate and make sure the user enters in a number (as opposed to something else.) Their solution? Store the input in a temp variable. Multiply the temp variable by 1. Make sure the temp variable is the same as the input. Also this quote "You could also use a regular expression but that'd be a pain in the rear end." Ugh.
|
# ¿ Jan 26, 2009 20:07 |
|
Triple Tech posted:Degrees don't mean poo poo! I wonder what their thought process was that using regexp validation, which is infinitely more robust, was somehow worth less than "multiplying something by one"? Geniuses at work, people. I think regexps are too hard. One of them used a regexp for something else and the other two were like :dropjaw:.
|
# ¿ Jan 26, 2009 23:48 |
|
Munkeymon posted:We have a single point of return policy. I know some people like that, but Ugg I hate it. I'd rather jump the hell out of a triply-nested loop with a Return statement than try to get out some other way. (Though I guess PHP has a break(x) function that breaks you out of multiple loops, doesn't it?)
|
# ¿ Feb 5, 2009 20:04 |
|
Avenging Dentist posted:What are you talking about? I think it's a joke but idgi
|
# ¿ Feb 8, 2009 05:36 |
|
ryanmfw posted:What would be the correct email regex? this gets brought up all the time: (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
|
# ¿ Feb 12, 2009 00:11 |
|
My girlfriend was sent an auto-generated password to log into some medical site. We couldn't believe the password: ) |. / It worked fine to login, but I mean, who the hell thought of writing a generator to create those kinds of passwords?
|
# ¿ Mar 13, 2009 22:32 |
|
Lord Uffenham posted:Never heard of the ole generate a password by taking a random 1x14 rectangle out of a piece of ASCII art? Oldest trick in the book, man. Hahaha, that's great.
|
# ¿ Mar 13, 2009 23:27 |
|
That Turkey Story posted:I'm pretty sure I gave an example. Even TTS isn't willing to read his wall of text to answer that question definitely though.
|
# ¿ Mar 20, 2009 23:33 |
|
mr_jim posted:A friend just told me about a guy he works with who prefaces every function name with his user name, as in: code ownership baby
|
# ¿ Apr 2, 2009 20:58 |
|
Kidane posted:Hahahaha, I hadn't seen the first one, that's awesome. What the hell is reverse logic? Using !~ instead? In C I'd wrap the whole thing in () and put !(...)
|
# ¿ Apr 9, 2009 23:56 |
|
Janin posted:It's pretty common in Python code written by people used to C++/Java. [citation needed]
|
# ¿ Apr 10, 2009 21:25 |
|
evilneanderthal posted:I hope that provides some clarification. I've seen my share of lovely Python code and I've never seen that, sorry.
|
# ¿ Apr 11, 2009 06:38 |
|
pokeyman posted:e: Come to think of it, isn't "if" redundant if you have goto? How would you conditionally branch with goto?
|
# ¿ Apr 12, 2009 19:45 |
|
shrughes posted:Put function pointers in a two-element array and index the array with a boolean. Pfft, function pointers are such a redundant feature
|
# ¿ Apr 12, 2009 19:48 |
|
Triple Tech posted:
You really like the word frobnicate, don't you? Also I liked your old avatar better.
|
# ¿ Apr 15, 2009 19:32 |
|
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.
|
# ¿ Jan 8, 2010 05:31 |
|
Milotic posted:The two features I dislike the most in .NET 3.5 are lambda expressions and the return of the dreaded var. Yes, I know the compiler can work it out. I'm not as smart as the compiler. If I'm looking at your code, there's a good chance there's something wrong with it. Please make my life a bit easier. 1. Lambda expressions are amazing, especially when dealing with dispatching stuff between worker threads and the UI thread. 2. I agree, var blows. It might not be a problem if you're the one writing the code, but when I'm trying to read it...
|
# ¿ Jan 27, 2010 05:30 |
|
|
# ¿ Apr 30, 2024 01:50 |
|
geetee posted:Something appears to be missing. he just cut out the long part of the post...
|
# ¿ Feb 5, 2010 05:58 |