|
LOOK I AM A TURTLE posted:I actually generally prefer ¬P ∨ ¬Q to ¬(P ∧ Q), because my desire to have as few parentheses as possible trumps my desire to have as few negations as possible. In the first example it's easier to see at a glance that P = F implies that the whole expression is true, which is important sometimes. The second example technically also has one more token in it than the first one, so while you and others may find it clearer, it's hard to argue that it's simpler. But I view all this as mostly a matter of personal taste, so I probably wouldn't tell anyone to change it one way or the other in a code review.
|
# ? Oct 14, 2017 15:12 |
|
|
# ? May 14, 2024 12:56 |
|
Zopotantor posted:With ¬(P ∧ Q) you can swap the then/else branches and get rid of both the negation and the parentheses. In general, non-inverted conditions are easier to understand. If you have both a then and an else then yes, I agree. I always change if (!x) { a(); } else { b(); } to if (x) { b(); } else { a(); } if I have the opportunity.
|
# ? Oct 14, 2017 19:50 |
My logic with that particular example is more if either object or needed member are invalid or don't exist, stop execution of function I guess you could do if they exist proceed but I find the nested ifs can become unmanageable E: Or I could do if they both don't exist (i.e. !(x && x.y)) stop execution, and you could argue that is clearer? But then we're into preferences, and literally nowhere else in our system is it laid out like that. Also, you get into the problem of JavaScript needing to evaluate both and you get an error on x.y if x is null/undefined. But JavaScript is a horror unto itself with regard to these things. Joda fucked around with this message at 15:40 on Oct 15, 2017 |
|
# ? Oct 14, 2017 20:54 |
|
Joda posted:My logic with that particular example is more if either object or needed member are invalid or don't exist, stop execution of function I agree and prefer to write it like that. code:
code:
|
# ? Oct 15, 2017 01:19 |
|
Swift's guard is (I think) intended for exactly that purpose and I love it.
|
# ? Oct 15, 2017 01:24 |
|
There should be 'iftrue', 'iffalse' built in to all languages. Remove 'if' since it causes problems with de Morgan and kids/managers not understanding. For Perl we can retain 'unless', but also introduce 'but'
|
# ? Oct 15, 2017 01:33 |
|
Code that doesn't fail out fast is a horror. If you see nested-good-ifs instead of the return/next/continue/skip idiom, complain about arrow code in the review. If you ever see 'unless' used in Ruby/Perl with a complex conditional, complain because it's probably confusing. If it's not in a single line, it's probably too confusing. I once even saw someone post code with 'unless not thingy or something'. :/
|
# ? Oct 15, 2017 15:09 |
|
LOOK I AM A TURTLE posted:This is where someone should step in with a Fermi estimate of how many nearly meaningless bytes URG bytes have been sent over the wire since TCP was invented. I reckon a few hard drives full.
|
# ? Oct 15, 2017 23:07 |
|
return0 posted:I reckon a few hard drives full. More than a week or two of global hard drive production.
|
# ? Oct 16, 2017 01:07 |
|
pokeyman posted:Swift's guard is (I think) intended for exactly that purpose and I love it. Yep.
|
# ? Oct 16, 2017 03:48 |
|
quote:Hi [Dev Team] I open one of the solutions: Single monolithic project. No unit tests. No dependency injection. Handful of anti-patterns I've only ever seen as counter-examples in a programming patterns book.
|
# ? Oct 16, 2017 07:51 |
|
Xik posted:I open one of the solutions: Just game the code coverage number. Write a bunch of useless tests that inflate the number. And then explain that arbitrary code coverage % requirements are dumb and that code coverage is meaningless on its own -- all it can reliably tell you is what code doesn't have any tests attempting to test it.
|
# ? Oct 16, 2017 13:38 |
|
New Yorp New Yorp posted:Just game the code coverage number. Write a bunch of useless tests that inflate the number. And then explain that arbitrary code coverage % requirements are dumb and that code coverage is meaningless on its own -- all it can reliably tell you is what code doesn't have any tests attempting to test it. The first requirements are naive by design. Then the project manager writes better requirements and you'll have to write better tests to satisfy those reqs, rinse and repeat. Req-Driven Testing.
|
# ? Oct 16, 2017 13:48 |
|
Xik posted:I open one of the solutions: one of the projects i used to work on they wanted min 80% coverage and 100% on all new code, It meant we had to unit Test All Enums until i realised that if you check the parent enum,SOMEENUM.value()l it would complete all 100%
|
# ? Oct 16, 2017 13:53 |
|
https://twitter.com/internetofshit/status/919870551002353664TheresaJayne posted:one of the projects i used to work on they wanted min 80% coverage and 100% on all new code, The problem with code coverage is that it approaches 100% whether or not you test for correctness instead of existence. It is useless on its own. As such, I love the idea of just bullshitting the whole thing.
|
# ? Oct 16, 2017 14:55 |
|
A former coworker got grilled by his new team for taking too long to write unit tests. Turns out he was writing real tests that actually tested things, all they wanted was code coverage for contract compliance. So they actually had him go back and remove all the asserts in his tests. Now he's writing documentation, can't wait to see how they get mad at him for doing reasonable normal things. Rubellavator fucked around with this message at 15:47 on Oct 16, 2017 |
# ? Oct 16, 2017 15:44 |
|
Rubellavator posted:So they actually had him go back and remove all the asserts in his tests. w-what?
|
# ? Oct 16, 2017 16:37 |
|
Tomie knows me posted:w-what? Tests with no assertions are great, they never fail. Unless the code starts throwing unhandled exceptions, of course. But then you can just comment out the test logic and put "Assert.IsTrue(true)" in there and everything's cool again.
|
# ? Oct 16, 2017 16:59 |
|
Nah you wrap it all in try/catch so the coverage doesn't go dwon
|
# ? Oct 16, 2017 17:36 |
|
necrotic posted:Nah you wrap it all in try/catch so the coverage doesn't go dwon wouldn't that lose code coverage after the point where the exception happens? (assuming the try-catch block is in the test, since adding it into the code seems dangerously close to actually finding and fixing bugs)
|
# ? Oct 16, 2017 17:41 |
|
Replacing the entire test with assert.ok removes even more coverage
|
# ? Oct 16, 2017 20:06 |
|
We joked about autogenerating a class that is x times larger than the codebase that just counts to a million or something with a single test to cover it.
|
# ? Oct 16, 2017 20:29 |
|
This is weird, right? It's not just because I don't know C# very well?C# code:
|
# ? Oct 16, 2017 21:31 |
|
If I had to guess, the code:
|
# ? Oct 16, 2017 21:40 |
|
CPColin posted:This is weird, right? It's not just because I don't know C# very well? It has a bunch of unnecessary checks, as well as a possible localization bug. So, yeah, it's definitely not great. Why 1 jan 1900 wouldn't be valid, but a few nanoseconds later would be is also strange. A more succinct way would be code:
|
# ? Oct 16, 2017 21:45 |
|
Linear Zoetrope posted:If I had to guess, the Nope. catch { throw; } is exactly the same as not catching an exception at all. It's useless. throw ex would dump the stack trace.
|
# ? Oct 16, 2017 21:49 |
|
Linear Zoetrope posted:If I had to guess, the No, then you'd have to do code:
A bare throw is only valid in a catch scope, and rethrows while maintaining the stacktrace. The catch/rethrow here is most likely to have a place to attch a debugger.
|
# ? Oct 16, 2017 21:49 |
|
So, sloppy code.
|
# ? Oct 16, 2017 22:56 |
|
I'd consider a c++ file littered with #ifndef for a debugger to be "battle tested" rather than sloppy code.
|
# ? Oct 16, 2017 23:00 |
|
100% coverage seems like 100% availability: possible but not worth the cost for any system above a certain size.
|
# ? Oct 16, 2017 23:06 |
|
You're saying we should be targeting four 9s in our code coverage, right?
|
# ? Oct 16, 2017 23:50 |
|
It's the inverse of a "speed-up loop"code:
|
# ? Oct 17, 2017 00:24 |
|
JawnV6 posted:It's the inverse of a "speed-up loop" Ok, I shouldn't talk because I'm abusing a function to delay a set number of ms, but that's also with a fixed clock frequency.
|
# ? Oct 17, 2017 00:28 |
|
dwazegek posted:Why 1 jan 1900 wouldn't be valid, but a few nanoseconds later would be is also strange. Sounds like a sentinel value of some sort.
|
# ? Oct 17, 2017 06:15 |
|
January 1st, 1900 is the "epoch"-like zero-point that MS Office uses instead of 1970.
|
# ? Oct 17, 2017 12:36 |
|
Corla Plankun posted:January 1st, 1900 is the "epoch"-like zero-point that MS Office uses instead of 1970. Microsoft Excel uses "January 0, 1900", which is supposed to be December 31, 1899 (using a convention developed for astronomical observances) and the calendar for 1900 includes February 29 which didn't occur that year. Both of these are to simplify interoperation with old Lotus 1-2-3 spreadsheets, as the developers of that made the original mistake. The net result is the earliest date you can store in Excel is actually December 30, 1899 and that the first date you can store that's actually correct is March 1, 1900. And the same epoch is meant to be used in all Office applications, and gets used elsewhere in Windows some times. A variant of this where 1900 isn't incorrectly recorded as a leap year, and so the calculations aren't off by one for very old dates, is I think in use in VBA within office.
|
# ? Oct 17, 2017 14:18 |
|
Doesn't .xls have a flag that tells you whether dates are counting from 1900 or 1901 for compatibility with Mac dates or something like that?
|
# ? Oct 17, 2017 16:57 |
|
New Yorp New Yorp posted:Nope. catch { throw; } is exactly the same as not catching an exception at all. It's useless. That's not true, actually. throw; alters the line number in the stack trace for the method containing the throw; statement to point to the line of the rethrow rather than the line in that method where the exception originally occurred. That makes catch { throw; } strictly worse than not having a try/catch at all (if the performance waste isn't already enough). Plus, the stack trace changing behavior masking the true exception source is annoying as poo poo in cases where you actually want to do real error handling before rethrowing an exception. biznatchio fucked around with this message at 17:10 on Oct 17, 2017 |
# ? Oct 17, 2017 17:07 |
|
biznatchio posted:Plus, the stack trace changing behavior masking the true exception source is annoying as poo poo in cases where you actually want to do real error handling before rethrowing an exception. You could do this code:
|
# ? Oct 17, 2017 17:28 |
|
|
# ? May 14, 2024 12:56 |
|
Python code:
|
# ? Oct 18, 2017 04:23 |