|
I would rather my shell's source code came with a picture of Guy Fieri than that
|
# ? Nov 30, 2016 03:34 |
|
|
# ? Apr 27, 2024 06:33 |
|
Reminds me of this little gem, one of the winnners of the 2000 International Obfuscated C Code Contest .
|
# ? Nov 30, 2016 03:57 |
|
My recent favorite for this is the mintty source code which has:C++ code:
|
# ? Nov 30, 2016 04:53 |
Suspicious Dish posted:My recent favorite for this is the mintty source code which has: For posterity, the link to the current version of that file is https://github.com/mintty/mintty/blob/2e4e620b86a69dadfe1ca1e8f34b421c7e89ec53/src/std.h#L124-L126. Also that's equal parts ingenious and horrifying. I'm not really sure why you would do that.
|
|
# ? Nov 30, 2016 05:04 |
|
I wonder if anyone does horrible things with the C Preprocessor while writing in languages that aren't C, as in running a non-C source code file through gcc -E as part of a compilation step.
|
# ? Nov 30, 2016 05:13 |
|
hosed up things are basically all #define enables you to do. Look at the Linux kernel. It's the ability to define your own syntax sugar that resists tooling and validation of what the code is actually doing.
|
# ? Nov 30, 2016 05:48 |
|
Fergus Mac Roich posted:I wonder if anyone does horrible things with the C Preprocessor while writing in languages that aren't C, as in running a non-C source code file through gcc -E as part of a compilation step. I once built a static HTML site using the preprocessor. I was crunched for time and didn't have time to learn something like Jekyll.
|
# ? Nov 30, 2016 06:22 |
|
Fergus Mac Roich posted:I wonder if anyone does horrible things with the C Preprocessor while writing in languages that aren't C, as in running a non-C source code file through gcc -E as part of a compilation step.
|
# ? Nov 30, 2016 07:15 |
|
Fergus Mac Roich posted:I wonder if anyone does horrible things with the C Preprocessor while writing in languages that aren't C, as in running a non-C source code file through gcc -E as part of a compilation step. Haskell uses CPP
|
# ? Nov 30, 2016 12:42 |
|
Fergus Mac Roich posted:I wonder if anyone does horrible things with the C Preprocessor while writing in languages that aren't C, as in running a non-C source code file through gcc -E as part of a compilation step.
|
# ? Nov 30, 2016 13:07 |
|
I once made a joke about writing an interpreter for a simple functional language entirely in C macros, which happened to taken seriously ... I got the idea from reading http://conal.net/blog/posts/the-c-language-is-purely-functional I'm sure there's a couple on github now ...
|
# ? Nov 30, 2016 14:29 |
|
Made the mistake once again (I should know better) of Googling "Oracle alter table". One of the top results is a page hosted on oracle.com that actually relates to "JavaDB", which I've never heard of before today but is obviously some other thing Oracle does. Of course there is no obvious indication on the page what product it relates to, or at least none that you'd detect if you are just skimming the information. I should know better because I've been bitten by this in the past when searches containing "oracle" came up with pages they were hosting that were actually about MySQL. Oracle's website is clearly considered a high-quality search result by Google, despite the fact that they don't take the time to make it clear which product their high-scoring web pages relate to...
|
# ? Nov 30, 2016 14:58 |
|
fleshweasel posted:hosed up things are basically all #define enables you to do. Look at the Linux kernel. It's the ability to define your own syntax sugar that resists tooling and validation of what the code is actually doing. As a kernel dev; can confirm. Although it's getting better, the true horrors are all from embedded manufactures. Freescale (now NXP [now Qualcomm]) in their 3.0.35 kernel for the imx6 processors had up to 3 layers worth of macros for some of their pad initialization code. poo poo was a absolute nightmare to dig through.
|
# ? Nov 30, 2016 15:55 |
|
Doesn't Torvalds work for e: I got freescale confused with transmeta somehow ... ... and according to http://www.linfo.org/linus.html he doesn't even work there anymore, and hasn't for awhile ... dougdrums fucked around with this message at 18:17 on Nov 30, 2016 |
# ? Nov 30, 2016 18:12 |
|
dougdrums posted:e: I got freescale confused with transmeta somehow ...
|
# ? Nov 30, 2016 18:32 |
|
i'm two versions of assert-plus and three versions of async, only on this screen. the entire list is much much longer. node.js, never change and just kill me now
|
# ? Nov 30, 2016 19:03 |
|
C macros are a local minima. Just enough functionality to never bother improving anything.
|
# ? Nov 30, 2016 22:12 |
|
canis minor posted:i'm two versions of assert-plus and three versions of async, only on this screen. the entire list is much much longer. node.js, never change and just kill me now
|
# ? Nov 30, 2016 22:47 |
|
Spatial posted:C macros are a local minima. Just enough functionality to never bother improving anything. For some reason I thought K&R didn't have a preprocessor but I looked it up and although it wasn't part of the earliest version of NB/C but it appeared shortly thereafter. Apparently the original implementation didn't even invoke the preprocessor unless you had a "special signal" at the beginning of the source file and half of what it does was just accidental implementation details and quirks of various compiler vendors. Ritchie cites this as one of the reasons it fits so poorly with the overall language - half of them weren't even using it.
|
# ? Dec 1, 2016 08:51 |
|
All semblance of good coding practice seems to disappear when the developers here are asked to write unit tests. I'm also pretty sure that none of the devs here actually know what a unit test is, since the 'unit' tests that have been produced do no mocking at all, and require databases to be configured so that almost completely useless tests like this can be run (I've obviously modified some of the variable/method names to remove company info):code:
They also love to copy & paste the same test many times, simply to change a single value: code:
Surprisingly, the actual code for the projects themselves is fairly reasonable; I get that devs might not like to write tests, but it would be nice if they'd at least make an effort to write tests that look like they were written by a sane person (and actually do something worthwhile other than trick test coverage plugins).
|
# ? Dec 1, 2016 13:31 |
|
It just seems like the utility of unit tests is lost on a lot of developers. I've seen a lot of the same things on my current project and previous ones. What I think it comes down to is just a fundamental misunderstanding of the purpose and goal of unit testing. I joined my most recent project and walked into a pile of 'every class is interfaced, and huge swaths of our unit tests were just mocks that implemented those interfaces, with methods being copy-pasted from the real code and *slightly* altered to allow them to run under test circumstances. I've had some luck in trying to explain unit testing as a matter of branch-exploration: When a method contains an if(), then you're going to need to write a test that dodges that and one that hits it. But in general it just seems to require some fundamental eureka moment that a lot of folks just get to in their own time.
|
# ? Dec 1, 2016 15:05 |
|
Unit tests seemed useless to me until I wanted to rework some implementation details and realized I could do so without unknowingly screwing everyone over. If you never (or only superficially) need to maintain the code, I can understand never seeing the value.
|
# ? Dec 1, 2016 15:35 |
|
pokeyman posted:If you never (or only superficially) need to maintain the code, I can understand never seeing the value. This code is changed on a weekly basis according to the git commit history.
|
# ? Dec 1, 2016 15:40 |
|
I'll speak for the unpopular opinion: Writing unit tests ahead of time IS useless. You can only write tests for what you can foresee going wrong, and you're going to test that manually during development anyway. Writing _testable_ code is important, because it correlates well with good architecture practices. And writing tests for issues that pop up after deployment is good, since that's something that you didn't foresee and is probably a corner case that's easy to overlook and therefore might break again on refactor. Testing for testing's sake is stupid. The point of the code is to accomplish something, not to have a badge that says that it passes some test suite.
|
# ? Dec 1, 2016 16:05 |
|
Cuntpunch posted:I've had some luck in trying to explain unit testing as a matter of branch-exploration: When a method contains an if(), then you're going to need to write a test that dodges that and one that hits it. But in general it just seems to require some fundamental eureka moment that a lot of folks just get to in their own time. This seems... wrong to me. Sounds like you're testing the specific implementation of the method. What if the implementation changes, are you supposed to rewrite all the tests?
|
# ? Dec 1, 2016 16:12 |
|
5TonsOfFlax posted:I'll speak for the unpopular opinion: Writing unit tests ahead of time IS useless. You can only write tests for what you can foresee going wrong, and you're going to test that manually during development anyway. i agree regression tests are good
|
# ? Dec 1, 2016 16:17 |
|
Yeah but writing tests first and then writing or changing code and the tests pass gives me a good high
|
# ? Dec 1, 2016 16:41 |
|
HappyHippo posted:This seems... wrong to me. Sounds like you're testing the specific implementation of the method. What if the implementation changes, are you supposed to rewrite all the tests? If you have a test for 'this one weird edge case' that comes up in a particular implementation, and then the implementation changes, that test should still be perfectly valid, just not necessarily interesting anymore.
|
# ? Dec 1, 2016 16:45 |
|
5TonsOfFlax posted:I'll speak for the unpopular opinion: Writing unit tests ahead of time IS useless. You can only write tests for what you can foresee going wrong, and you're going to test that manually during development anyway. You're missing the part where I can make changes to the code, and then instead of manually testing the code, I can just punch in the unit test, and fifteen seconds later I'll know down to the function level where I broke it. Sure I could have discovered that by manually running a regression suite, discovering the results didn't match what I wanted, and doing the whole debugging process until I figure out what went wrong...but that takes a lot longer. With a little practice, it doesn't take much time to write the tests, and they save so much time in the form of developer testing that realistically they'll have paid themselves back inside of a month at worst. Stealth edit: of course that doesn't excuse you from having integration tests, but considering how much of developer time is spent on fixing broken code, anything you can do to speed that process up is a good thing.
|
# ? Dec 1, 2016 16:55 |
|
Guys guys guys guys. Maybe we could have unit tests AND regression tests?
|
# ? Dec 1, 2016 17:01 |
|
ratbert90 posted:Guys guys guys guys. BUT THERE'S NO TIME TO WRITE TESTS!!!
|
# ? Dec 1, 2016 17:13 |
|
I saw, during a code review, a bit of code that relied on another bit of code outputting an exact sequence of characters. I asked my coworker to write a unit test that verified the functionality, in case we ever rewrite the code to output a slightly different sequence of characters. What I really wanted to ask was, "How come you didn't write that unit test already?" Then the coworker asked where to put it, how to run unit tests, etc.
|
# ? Dec 1, 2016 17:51 |
|
CPColin posted:I saw, during a code review, a bit of code that relied on another bit of code outputting an exact sequence of characters. I asked my coworker to write a unit test that verified the functionality, in case we ever rewrite the code to output a slightly different sequence of characters. What I really wanted to ask was, "How come you didn't write that unit test already?" Really, that's awesome and you should be happy to help someone learn. It was well after I was out of college when I had finally been burned enough by not having testing that I 'got' unit tests and why it was worth spending the energy. I wish I someone had mentored me on it earlier. The question is, though, did it stick?
|
# ? Dec 1, 2016 18:07 |
|
HappyHippo posted:This seems... wrong to me. Sounds like you're testing the specific implementation of the method. What if the implementation changes, are you supposed to rewrite all the tests? Sure. Unit tests are white-box (well, transparent-box), implementation-aware tests. I would also accept leaving all the existing tests (which should continue to pass under the new implementation) in place and writing additional ones to cover the new implementation.
|
# ? Dec 1, 2016 18:49 |
|
taqueso posted:Really, that's awesome and you should be happy to help someone learn. It was well after I was out of college when I had finally been burned enough by not having testing that I 'got' unit tests and why it was worth spending the energy. I wish I someone had mentored me on it earlier. It clearly didn't stick the last handful of times I recommended during team meetings that we should all be writing more unit tests (and said coworker was nodding along).
|
# ? Dec 1, 2016 19:13 |
|
HappyHippo posted:This seems... wrong to me. Sounds like you're testing the specific implementation of the method. What if the implementation changes, are you supposed to rewrite all the tests? I'm thinking about it from a "write unit tests after the fact" sense. If you're TDD'ing this probably doesn't quite apply. But the logic behind it seems sound. Consider: code:
But imagine the usual massive methods with cyclomatic complexity in the double(or, god forbid, triple) digits. What I tend to see is people who write these monstrosities to 'just work', and then they only end up bothering to write a unit test or two around a 'happy path' through the code, leaving coverage at a sad state.
|
# ? Dec 1, 2016 21:05 |
|
TooMuchAbstraction posted:You're missing the part where I can make changes to the code, and then instead of manually testing the code, I can just punch in the unit test, and fifteen seconds later I'll know down to the function level where I broke it. Sure I could have discovered that by manually running a regression suite, discovering the results didn't match what I wanted, and doing the whole debugging process until I figure out what went wrong...but that takes a lot longer. They also force you to eat your own dog food, which is never a bad thing.
|
# ? Dec 1, 2016 21:11 |
|
Cuntpunch posted:I'm thinking about it from a "write unit tests after the fact" sense. If you're TDD'ing this probably doesn't quite apply. But the logic behind it seems sound. Consider: Yeah if you mean it more as inspiration for test cases that makes sense (although if I asked you to test an abs function without showing you the code you'd likely come up with the same test cases), and you make a good point about not just testing the "happy path".
|
# ? Dec 1, 2016 21:37 |
|
Unit tests should test behaviors that your code relies upon being consistent. While unit tests != regression tests, the way that unit tests are oftentimes implemented overlaps heavily with the needs of regression tests. If your test structures and validity depend unintentionally upon changes in implementation of a code path this doesn't invalidate your tests. If your code guarantees that you will only call a function within an integer range and the function you depend upon supports a lot more, you don't need to cover more than you're using.... until you decide to increase the integer range support. That wouldn't be a regression in behavior as much as catching inputs (or sometimes states) that cause unanticipated behavior. In my experience I see bigger problems with confusing integration and unit tests. If your tests depend upon a database existing and it's supposed to run constantly, it probably shouldn't belong in a unit test.
|
# ? Dec 1, 2016 22:54 |
|
|
# ? Apr 27, 2024 06:33 |
|
Okay, I need to step back for a second. Isn't every test a regression test? Under normal circumstances, every test should pass, and if a test fails, there's been a regression, right?
|
# ? Dec 1, 2016 23:41 |