What is the meaning of OR?


  • Considered Harmful

    @Gribnit said in What is the meaning of OR?:

    @Steve_The_Cynic said in What is the meaning of OR?:

    With a generic type <O extends Ogglefloggle> and a similar fleening type scheme, you can of course prevent that.

    Isn't that what God gave us interfaces and factories for?



  • @MrL said in What is the meaning of OR?:

    I worked at a company where his ideas were treated like gospel. It was a nightmare.

    Rentrak?


  • Notification Spam Recipient

    @Captain said in What is the meaning of OR?:

    @MrL said in What is the meaning of OR?:

    I worked at a company where his ideas were treated like gospel. It was a nightmare.

    Rentrak?

    No, local startup noone heard of.



  • @topspin said in What is the meaning of OR?:

    It should either be previous_conditions.or(new_condition) or items.or(list, of, conditions). But not both. That makes zero fucking sense.

    Agree....but

    .or('a').or('b').or('c')
    

    collapses into

    .or('a','b','c')
    

    And thus endith the world.



  • @Arantor said in What is the meaning of OR?:

    once you go beyond 5 or so temporary variables it's actually harder to reason through because you're having to keep track of all the mental inventory as to what each of the things is.

    But see, that's the beauty of his method! You don't have to keep a mental inventory. All the variables are named for exactly what they're holding! 🍹



  • @Gąska said in What is the meaning of OR?:

    And how much coverage do those tests provide? 90%? 95%? As I mentioned before, anything short of complete full coverage is useless.

    Unit test coverage is a (nearly) useless metric, imo. A lot of code doesn't need a test to cover it, because if it doesn't work, then neither does the program. And the code that can have a test will often change frequently due to bugfixes and feature enhancements, which necessitates changing the tests every time as well, effectively at least doubling or tripling the development time. But even worse, code that could make goodokay use of a test requires that the programmer think of every possible fail condition and account for them in the test(s); and if you can think of the ways it could fail, then you'd write the code so it doesn't fail that way. In that regard, testing via logging or error handling is at least as good as unit testing at finding logic errors.


  • ♿ (Parody)

    @djls45 I often think that the biggest advantage of high coverage is that it's easier to adapt existing test code than to write it from scratch. In addition to the possibility of catching regressions when you have actual tests that aren't just there for the coverage.


  • Discourse touched me in a no-no place

    @djls45 said in What is the meaning of OR?:

    Unit test coverage is a (nearly) useless metric, imo.

    As a summary? Yes. The detail of what is covered and what isn't is much more useful though. In a big project, it's far too easy for substantial chunks of code to be completely unexercised by either tests or operational use, leaving it festering away, sucking up maintenance effort while not delivering anything in return. Testing stops code from breaking utterly, provided the tests are right and actually run, and coverage lets you make sure that tests are checking what you think they are.

    Some types of code are harder to test than others. Testing GUIs is particularly difficult, and testing stuff that integrates with the outside world is pretty bad too. But it doesn't make testing useless. (Yes, tests may need to change when the code changes. Expected changes to tests are OK; unexpected changes aren't.)



  • @djls45 said in What is the meaning of OR?:

    A lot of code doesn't need a test to cover it, because if it doesn't work, then neither does the program. And the code that can have a test will often change frequently due to bugfixes and feature enhancements, which necessitates changing the tests every time as well, ...

    The counterargument (which I don't agree with more than I do) would be that (a) bugfixes should be fewer since they should have been caught during testing in the first place — and when they do happen, write some new tests because you obviously missed some, and (b) feature enhancements should first be documented by changing the tests to the necessary new behaviour, and then treating the fact they are now failing as a measure of how far from implementation the feature is.

    My counter-counterargument addresses (b), but (a) is affected as well, and this is the part that impacts on development time: the amount of work required to analyse the feature in terms of the existing test suite; atomising it into a stream of low-level changes of the form "this method does this and now it needs to do that" on methods that don't have any immediate bearing on the feature itself.



  • @Kamil-Podlesak said in What is the meaning of OR?:

    @Gąska said in What is the meaning of OR?:

    @MrL said in What is the meaning of OR?:

    @Kamil-Podlesak said in What is the meaning of OR?:

    @MrL said in What is the meaning of OR?:

    @Gąska said in What is the meaning of OR?:

    It's especially great for refactorings - since refactoring is supposed to change nothing at all, behavior-wise.

    We have different definitions of refactoring.

    If we do, then your definition is wrong. If you change behavior, you're not refactoring, you're adding a feature.

    No.

    What is your definition of refactoring?

    Like I said: changing stuff so it looks/works better.

    :wtf_owl: That's approx. 50% of all software development.

    Specifically: changing stuff so it does the same thing but looks/works better.

    That's much better.

    Not even that, really. You don't necessarily want it to do the same thing(s).

    Refactoring is changing stuff so it produces the same effect(s) but looks/works better.

    I mean, that's sorta what "works better" means, but made explicit.



  • @Gribnit said in What is the meaning of OR?:

    @Arantor ah, fair, that's irrecoverable. Try day-drinking.

    What can a teetotaler do instead?



  • @Arantor said in What is the meaning of OR?:

    Even PHP gets this less wrong: every statement ends in a semicolon, even if multi line, without any need for continuation characters. Even if using the weird heredoc/nowdoc multi line string embeds.

    Isn't that the same rule as C? It's only these newfangled languages with lazy coders who don't want to put a semicolon after each statement that run into these problems with semicolon auto-placement. Why, if a C programmer missed a semicolon, it would almost certainly be caught by the compiler, with the exact missing placement shown in the error message. :belt_onion:



  • @da-Doctah said in What is the meaning of OR?:

    Anyway, there's an easy compromise for the two paradigms you describe for multi-line statements (you and the "main Java guy"): new line after the identifier or closing bracket, put the operator on a line by itself indented a couple of spaces from the previous line, then continue with the next operator or opening bracket on the line after that with the indent reverted.

    I'm a kinda visual guy. You mean like this?

        int value = navigation.to.function.call()
                        +
                    variable_or_collection_access;
    


  • @dkf said in What is the meaning of OR?:

    Some types of code are harder to test than others. Testing GUIs is particularly difficult, and testing stuff that integrates with the outside world is pretty bad too.

    Maybe this is the driving issue for my earlier-stated opinion on testing, because I'm currently working on a GUI application to read some data from a database (the GUI lets the user pick which database and data), do some fairly trivial changes to it, and then save the data back to a database (not necessarily the same one that it read from, and also picked by the user).


  • Considered Harmful

    @djls45 Golf?


  • Considered Harmful

    @topspin I've actually been trying to figure out how to sanely emulate friend access in Java for about two decades.


  • ♿ (Parody)

    @Gribnit said in What is the meaning of OR?:

    @djls45 Golf?

    Skipping the 19th is a cardinal sin.



  • @djls45 said in What is the meaning of OR?:

    @da-Doctah said in What is the meaning of OR?:

    Anyway, there's an easy compromise for the two paradigms you describe for multi-line statements (you and the "main Java guy"): new line after the identifier or closing bracket, put the operator on a line by itself indented a couple of spaces from the previous line, then continue with the next operator or opening bracket on the line after that with the indent reverted.

    I'm a kinda visual guy. You mean like this?

        int value = navigation.to.function.call()
                        +
                    variable_or_collection_access;
    

    Just so.



  • @djls45 said in What is the meaning of OR?:

    @Arantor said in What is the meaning of OR?:

    Even PHP gets this less wrong: every statement ends in a semicolon, even if multi line, without any need for continuation characters. Even if using the weird heredoc/nowdoc multi line string embeds.

    Isn't that the same rule as C? It's only these newfangled languages with lazy coders who don't want to put a semicolon after each statement that run into these problems with semicolon auto-placement. Why, if a C programmer missed a semicolon, it would almost certainly be caught by the compiler, with the exact missing placement shown in the error message. :belt_onion:

    PHP started life as “I want to use C but with memory safety and some conveniences for web use”. It even originally stood for “personal home page” back in the day.

    And now it runs a scary amount of the world. Fuck.


  • Java Dev

    @djls45 said in What is the meaning of OR?:

    Why, if a C programmer missed a semicolon, it would almost certainly be caught by the compiler, with the exact missing placement shown in the error message.

    And the PHP programmer will be told during the parse phase with similar accuracy. For such reasons, we have a checkin hook which invokes php -l.


  • Discourse touched me in a no-no place

    @Gribnit said in What is the meaning of OR?:

    I've actually been trying to figure out how to sanely emulate friend access in Java for about two decades.

    Use the package scope for that. Putting things within the same class (including as member classes of the same outer class) and using private also works; I've no idea what visibility constraints are actually put in the class files in that case, but it works.

    If you're trying to get classes in different packages to get friendly, that sounds dirty…



  • @PleegWat said in What is the meaning of OR?:

    For such reasons, we have a checkin hook which invokes php -l.

    Me too!



  • @djls45 said in What is the meaning of OR?:

    @Gąska said in What is the meaning of OR?:

    And how much coverage do those tests provide? 90%? 95%? As I mentioned before, anything short of complete full coverage is useless.

    Unit test coverage is a (nearly) useless metric, imo. A lot of code doesn't need a test to cover it, because if it doesn't work, then neither does the program. And the code that can have a test will often change frequently due to bugfixes and feature enhancements, which necessitates changing the tests every time as well, effectively at least doubling or tripling the development time. But even worse, code that could make goodokay use of a test requires that the programmer think of every possible fail condition and account for them in the test(s); and if you can think of the ways it could fail, then you'd write the code so it doesn't fail that way. In that regard, testing via logging or error handling is at least as good as unit testing at finding logic errors.

    Good argument, with one important caveat: it actually has to be tested. Which can be done manually, of course, but that is harder than it looks...

    What I like about coverage is that it shows which lines and branches were missed. Then I can review them and (in the best case) say "ok, yes, that's a case that I haven't tested". But occasionally I say "huh, weird, this is definitely something that should be triggered by the test case X and maybe Y and Z... what's going on?" (spoiler: a devious bug is going on!)

    Even if this happens once every few months, the bugs found this way are definitely worth it. YMMW



  • @Kamil-Podlesak said in What is the meaning of OR?:

    Even if this happens once every few months, the bugs found this way are definitely worth it. YMMW

    One additional point: sometimes we hear a :trollface: question "How do you test your tests? Do you write unit tests for unit tests?"

    The answer is: no, we validate unit tests by the real code and its coverage. Plus, of course, other tests (including manual ones).


Log in to reply