|
rjmccall posted:Curly braces inside parentheses are how you get functional composition of expressions in C. Let's take it to the next level with lambdas: code:
|
# ? Nov 21, 2010 13:46 |
|
|
# ? May 13, 2024 23:53 |
|
Sorry about the hungariancode:
|
# ? Nov 22, 2010 01:50 |
|
code:
|
# ? Nov 22, 2010 19:00 |
|
It's possible that someone just started creating a class that implements some interface (error / notify) but forgot to finish it, and hopefully forgot to even hook it up to anything. Not really that unusual or horrible.
Orzo fucked around with this message at 23:26 on Nov 22, 2010 |
# ? Nov 22, 2010 19:05 |
|
Orzo posted:It's possible that someone just started creating a class that implements some interface (error / notify) but forgot to finish it, and hopefully forgot to even hook it up to anything. Not really that unusually or horrible. Of course it was hooked up to stuff It's code that was pushed to a production server and was found by the client trying to use their site.
|
# ? Nov 22, 2010 22:33 |
|
Oh. That is horrible then.
|
# ? Nov 22, 2010 23:26 |
|
the last place I worked, a vendor delivered a webapp which used a process with root rights to read a cookie with a raw python Eval(). the developer who discovered this was the case, used it to send out a department-wide email alerting everyone to the awesome 'feature' of the app. this was a six-figure application. as delivered, it could handle one request per second per server. it was entirely re-written in-house, in less time.
|
# ? Nov 23, 2010 00:48 |
|
code:
|
# ? Nov 23, 2010 18:48 |
|
npe posted:I love how one of them has data.Length < 7, and one has data.Length < 8. Obviously this is correct, but it means that there was a bit of attention paid to the functions...
|
# ? Nov 23, 2010 21:34 |
|
Ugg boots posted:I love how one of them has data.Length < 7, and one has data.Length < 8. Obviously this is correct, but it means that there was a bit of attention paid to the functions...
|
# ? Nov 24, 2010 00:49 |
|
My boss woke up the other morning and decided we'd be writing all future code in Python 2.4. We develop high speed real time systems and we're all C++ developers.
|
# ? Nov 24, 2010 03:01 |
|
I just started a new job and I broke the build with my very first commit. A fairly trivial and isolated one too. I was pulling my hair out trying to figure out what I did because it Then I get an email saying there are some race conditions in the build script that cause it to fail randomly.
|
# ? Nov 24, 2010 05:09 |
|
Hot Dog Day #55 posted:My boss woke up the other morning and decided we'd be writing all future code in Python 2.4. We develop high speed real time systems and we're all C++ developers. You could always go with stackless py-- haha oh god I can't do it.
|
# ? Nov 24, 2010 07:32 |
|
I thought of scenario where the for-case antipattern might be valid:code:
It might not be the best solution (better imo) but at least it does something you don't get from just writing the code out sequentially. Smugdog Millionaire fucked around with this message at 22:50 on Nov 24, 2010 |
# ? Nov 24, 2010 20:57 |
|
I can't think of a real-world scenario in which this is a valid option. You're calling four pairs of methods that take no parameters in parallel and you can't figure out how to refactor that to call the same two methods four times with a parameter? And if they're doing totally different things, then this code is misleading, because the for loop structure implies that you're doing something similar in each step. It looks like the only "gain" here is that you don't have to wrap each individual method in a try-catch, but again, refactoring the called methods to take a parameter would be the way to go. This is a horror because it's not obvious what is happening. Your linked code isn't really any better.
|
# ? Nov 24, 2010 21:29 |
|
Smugdog Millionaire posted:Coding horror or no? Why wouldn't you do this? (.NET 4.0) I don't know why you're using that Parallel ForEach poo poo. code:
|
# ? Nov 24, 2010 21:32 |
|
Ryouga Inverse posted:I can't think of a real-world scenario in which this is a valid option. You're calling four pairs of methods that take no parameters in parallel and you can't figure out how to refactor that to call the same two methods four times with a parameter? Each method pair is dumping some selected records from a database into a CSV file and FTPing them someplace. It's not feasible to refactor the data dump into a single method with a parameter. I did, in fact, make the FTP part of the process a method with a parameter. The gain I see is that the parallel.foreach-case form most closely mimics the form of the code if it were written to be run in serial. Ugg boots posted:Why wouldn't you do this? (.NET 4.0) I don't know why you're using that Parallel ForEach poo poo. The code I actually wrote does use the TPL but your example doesn't wait for the results and doesn't handle the exceptions. Here's the code I wound up using the TPL: code:
I'm not seriously advocating this pattern. Just bringing it up
|
# ? Nov 24, 2010 22:49 |
|
I thought the for-case pattern starts becoming valid when you start running things out of sequence like in a series of random tests and may be useful to show that they're different test cases with so much test coverage of inputs:code:
|
# ? Nov 24, 2010 22:58 |
|
Smugdog Millionaire posted:... Here's an improved version of yours: code:
|
# ? Nov 24, 2010 23:29 |
|
Ugg boots posted:Here's an improved version of yours:
|
# ? Nov 24, 2010 23:37 |
|
necrobobsledder posted:I thought the for-case pattern starts becoming valid when you start running things out of sequence like in a series of random tests and may be useful to show that they're different test cases with so much test coverage of inputs:
|
# ? Nov 25, 2010 00:00 |
|
Plorkyeran posted:i.e. when it's not actually for-case? It just happens to be a for loop creating the test data, and it just so happens to be a switch statement that does the validation, so yeah, it's not really for-case.
|
# ? Nov 25, 2010 00:02 |
|
I'm doing a group project for uni, and there's some *horrendous* code flying around. I mean, I don't know what I'm doing, but I know better than this...code:
|
# ? Nov 26, 2010 08:53 |
|
Trapick posted:I'm doing a group project for uni, and there's some *horrendous* code flying around. I mean, I don't know what I'm doing, but I know better than this... Unfortunately, things like that are kinda inevitable when working in group projects. If you told your partners you'd make a function named X that does Y, you sometimes have to deliver that function, even if it turns out you need to do things like wrap another function inside it and use global variables. There are just too many people who will refuse to refactor their code with the changes you made.
|
# ? Nov 26, 2010 10:48 |
|
Amarkov posted:Unfortunately, things like that are kinda inevitable when working in group projects. If you told your partners you'd make a function named X that does Y, you sometimes have to deliver that function, even if it turns out you need to do things like wrap another function inside it and use global variables. There are just too many people who will refuse to refactor their code with the changes you made. It also can be dereduntalely rewritten reducing it's written redundant redundacy as: pre:function renamedFunction(parm1) { return someOtherFunction(global1, global2); }
|
# ? Nov 26, 2010 10:56 |
|
karoshi posted:It also can be dereduntalely rewritten reducing it's written redundant redundacy as: I was considering pointing that out too, but I've had at least one somewhat competent guy explain to me that he really prefers it when people have an explicit branch. Not that it isn't a retarded way to write code, but I don't like to cry coding horror when some poor dude is just following the style guide.
|
# ? Nov 26, 2010 11:48 |
|
If your style guide requires you to do that then you have an awful style guide and you should take steps to change it.
|
# ? Nov 26, 2010 12:25 |
|
Just be ecstatically happy that you're in a group where other people actually write code at all.
|
# ? Nov 26, 2010 12:31 |
|
Hell is other peoples code
|
# ? Nov 26, 2010 20:20 |
|
And after a couple of years, to me I'm other people.
|
# ? Nov 26, 2010 22:43 |
|
Amarkov posted:I was considering pointing that out too, but I've had at least one somewhat competent guy explain to me that he really prefers it when people have an explicit branch. Not that it isn't a retarded way to write code, but I don't like to cry coding horror when some poor dude is just following the style guide. Yeah, it wasn't clear from his post what exactly made him laugh/cry. Maybe it was a 5-depth nesting of interface implementations, each one just calling another function that calls just another function... Personally I prefer code I can read quickly, where I don't need 5 seconds to parse it, when 1 second should be enough. That would be my style guideline. vOv
|
# ? Nov 27, 2010 01:27 |
|
bobthecheese posted:Just be ecstatically happy that you're in a group where other people actually write code at all.
|
# ? Nov 27, 2010 05:33 |
|
Plorkyeran posted:Some of my favorite group projects in college were the ones where other people didn't try to write code. A terrible group member is much worse than one that does nothing.
|
# ? Nov 27, 2010 08:42 |
|
Trapick posted:It's worked out pretty good, actually. We have a group member who can't write code to save his life, but he knows it, so he's doing an insane amount of testing. Very, very handy. Ours did the documentation
|
# ? Nov 27, 2010 19:29 |
|
One of ours spen the whole time offering to get everyone else meth, one left the country until the project was nearly done. I ended up writing about 20k lines of code myself because the only people in the group who could have helped were busy with our 600 page design document. This was our final project, and it was for a real client who had paid the university to get it done. Failure to jump through all the hoops that the uni put up meant that we would have to do another year long project the next year.
|
# ? Nov 27, 2010 22:49 |
|
Zaxxon posted:why do I keep seeing crap like this. You know what I found in our source the other week? #define PROTRAIT PORTRAIT One of the programmers consistently mistyped the word PORTRAIT (an identifier for some graphics library or something), and decided to solve the problem once and for all.
|
# ? Nov 27, 2010 23:21 |
|
poor spelling certainly is a pro trait.
|
# ? Nov 27, 2010 23:53 |
|
it's the end of the quarter, and I already wrote transpose, so why waste time?code:
|
# ? Nov 28, 2010 01:35 |
|
evensevenone posted:it's the end of the quarter, and I already wrote transpose, so why waste time?
|
# ? Nov 28, 2010 05:58 |
|
|
# ? May 13, 2024 23:53 |
|
Any decent compiler will be able to optimize it away
|
# ? Nov 28, 2010 10:54 |