What is the meaning of OR?



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

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

    :bikeshed:: I then tend to put the operator on the new line.

    Me too. It's much more readable to me when a line starts with "but wait there's more!" than when it ends with it. Unfortunately this style is impossible in many "modern" languages due to auto-semicolon.

    Is it?

    In JavaScript/EcmaScript the semicolon is inserted if the next line cannot be continuation, not if the previous line can be completed, so you can put the operator on the next line there. In fact I prefer the eslint "semicolon: never" style there where you put semicolon before statements starting with [, (, /, +, or - – there was an article explaining why that creates lowest risk of mistake given the existing grammar.

    And in Python it is a continuation only if the previous line ends with \ or there is unclosed bracket, so you can put the operator on the next line too.

    Unfortunately I couldn't find the exact rules for Groovy and Kotlin.


  • Banned

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

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

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

    :bikeshed:: I then tend to put the operator on the new line.

    Me too. It's much more readable to me when a line starts with "but wait there's more!" than when it ends with it. Unfortunately this style is impossible in many "modern" languages due to auto-semicolon.

    Is it?

    Sometimes, depends, it's very inconsistent and each language has its own rules, and it gets especially complicated when you include parser bugs. I've definitely had that problem with Scala. And the return thing in JS discourages me from trying anything even though I'm pretty sure this behavior is specific to returns.

    It's like operator precedence. Why worry if you've got all the details right if you can just ignore the problem by avoiding that situation entirely?



  • 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.



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

    Actually I'm quite convinced - that 🎉 Tests 🎉 are a religion. Or rather a cult. Huge waste of time, a lot of pointless motions and the only result is feeling good about oneself.
    Source: working on projects with tens of thousands of tests.

    I work on a project with a lot of tests, and worked on another before that and I think they are good. We do have a handful of tests broken all the time and we do spend quite a bit of time hunting down what's causing it, but they are indispensable in understanding what's it even supposed to do, because it's been running for a couple of years and adding features for multiple customers and it's really the only way to have at least some confidence you didn't break something for someone.

    But there is a caveat – only a handful of the tests are unit tests. Vast majority is functional tests. They actually start suitable simulation of the interfacing systems, trigger the application over the public interface and check it does the right thing, and the only instrumentation is checking logs to immediately observe something happens that would only be publicly observable much later.

    In practice too. We didn't always refactor, but having that as a fixed part of every sprint avoided the whole problem of convincing the management every time we really need to refactor something.

    Yeah, that's a big plus of such situation.
    In one and only place where we managed to negotiate something like this, when there wasn't anything obvious to refactor, we used this time to gradually transform whole project to new design. It took a year (3 times actually), but we got to design that better suited changing requirements - it would never be possible to convince decision makers to do it in one go.

    I am generally proponent of the “boy scout rule” – just include a bit of refactoring in whatever task needs to touch the part of code anyway and benefits (usually in reliability) in cleaning it up and simply don't offer the “quick hack” way of doing the task faster to the manager at all. The team has to agree on it though – in the other project around here they have a couple of people always willing to do the quick hacks and the code is turning to a huge ball of mud over time because of it.

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

    Right now I’m dealing with the fact that client and server both keep their state as the user flows through the key flow of the app… and this gets out of sync. Ain’t no tests going to help me cover the mess this caused.

    Well, they can. Have the client and the server running and do some action and check it succeeded if and only if it was supposed to.

    Also a vast amount of my app is external API driven and mocking that out doesn’t help me deal with the weird edge cases that spits out.

    Don't mock it, run it.

    Unit tests are what isn't going to help you here. Integration tests, however, could.

    I get that you feel tests would help. At this stage building tests is literally counterproductive because things change week to week such that what was the plan last week is now 180 this week, and tests just increase the drag factor on turning that tanker around.

    Yeah, if the use-cases themselves are not settled yet, it probably does not pay to automate them just yet. But when the UI is somewhat stable, automating the functional tests (with selenium or similar for driving the UI and maybe postman/newman for directly checking the server) definitely helps.



  • @Bulb that’s basically my point. Nothing about this project is in any way settled and until it is, tests are a hindrance to the customer getting things actually into production which is all the customer cares about since it’s literally the website that is their business.



  • @Arantor Yeah, if the use-cases are expected to change before next time you test them, just have someone test them manually. But hopefully they will stabilize when it's about to go in production.



  • @Bulb about to go into production?

    I inherited this mess after it had already been in production for 6 months.


  • Banned

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

    @Bulb that’s basically my point. Nothing about this project is in any way settled and until it is, tests are a hindrance to the customer getting things actually into production which is all the customer cares about since it’s literally the website that is their business.

    And that's the inherent problem of unit tests. They are very expensive to make unless you write them from the beginning, but writing them at the beginning doesn't look like adding much value at the beginning. Making people unwilling to even try, or quickly discouraged when they do try.

    Unit tests are much like religion in another way too. Following the word of God is a very hard path that often looks stupid and pointless, and doesn't really benefit you in any way until the very end when you enter heaven. The difference is, heaven doesn't exist, while fearless refactoring does.



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

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

    :bikeshed:: I then tend to put the operator on the new line.

    I used to put the operator mostly on the end of the line, exactly because that makes it obviously incomplete. But in one past project the main Java guy (we had C++, Java and JavaScript there) insisted that the standard convention is putting it on the next line. I feared it might not be compatible with JS automagic semicolons, but it actually inserts them based on what the next line starts with, so it is (but watch out of return statements). So I kinda got used to that since.

    Used to work in PL/1. Semicolon ends a statement, whether that statement is 23 lines long or there are six statements on a single line.

    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.


  • Banned

    @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.

    The best solution. Now everybody can hate the formatting style equally!



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

    I get that you feel tests would help. At this stage building tests is literally counterproductive because things change week to week such that what was the plan last week is now 180 this week, and tests just increase the drag factor on turning that tanker around.

    You need to beat people about the head with cluebats (or even just ordinary bats, or GAU-8s if necessary) until the change management problem is resolved.

    Or try drinking.

    Or run screaming into the night.


  • ♿ (Parody)

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

    The difference is, heaven doesn't exist, while fearless refactoring does.

    If you care less, you'll fear less, too.



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

    @Bulb that’s basically my point. Nothing about this project is in any way settled and until it is, tests are a hindrance to the customer getting things actually into production which is all the customer cares about since it’s literally the website that is their business.

    So the website is their business and yet they don't know what it should do?


  • ♿ (Parody)

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

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

    @Bulb that’s basically my point. Nothing about this project is in any way settled and until it is, tests are a hindrance to the customer getting things actually into production which is all the customer cares about since it’s literally the website that is their business.

    So the website is their business and yet they don't know what it should do?

    Have you met a customer before?


  • BINNED

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

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

    @Bulb that’s basically my point. Nothing about this project is in any way settled and until it is, tests are a hindrance to the customer getting things actually into production which is all the customer cares about since it’s literally the website that is their business.

    So the website is their business and yet they don't know what it should do?

    Sounds like the dotcom bubble. 🎆



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

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

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

    @Bulb that’s basically my point. Nothing about this project is in any way settled and until it is, tests are a hindrance to the customer getting things actually into production which is all the customer cares about since it’s literally the website that is their business.

    So the website is their business and yet they don't know what it should do?

    Have you met a customer before?

    I have, many times, although not in the context of web development, thank the Maker. For the most part, they understood the need to (...)ing know what they wanted. The best was some sort of equity fund management outfit, perhaps a hedge fund, back in 2006 or so, when I worked for a major provider of financial market information services. The particular project had a reputation for being the "project from Hell", and I insisted on having a chat with the customer.

    So, they came to our offices, and in this meeting room there was me, our sales guy, and three senior traders from the customer. I introduced myself, and said that I would explain, based on the currently-known requirements, what I thought they did in their daily activities, and then let them tell me how I was wrong. I got it mostly correct, although ===> that case (the most bothersome one, by all that's wholly) was something they never did.

    So yes, I've spoken to customers, and my view is that talking directly to customers (and, by implication, having enough domain knowledge to do so) is the mostest valuablest thing that a developer can ever do.



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

    The best solution. Now everybody can hate the formatting style equally!

    #include "my_first_math.H"
    
    int f()
    {
        Result<int> result;
    
          123456
        +  98765
        - ------
          result
        ;
    
        return result;
    }
    
    my_first_math.H
    template< typename T >
    struct Result
    {
        T value;
    
        operator T&() { return value; }
        operator T const&() const { return value; }
    
        Result& operator--() { return *this; }
        friend Result& operator-( T value, Result& res )
        {
            res.value = value;
            return res;
        }
    };
    

  • ♿ (Parody)

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

    So yes, I've spoken to customers, and my view is that talking directly to customers (and, by implication, having enough domain knowledge to do so) is the mostest valuablest thing that a developer can ever do.

    I don't disagree, but that doesn't mean that they understand what they're asking for and almost certainly not what they should be asking for.


  • Banned

    @cvi TIL you can put friend function definition in class body. And I'm sure that's not the last surprising bit of C++ I'll encounter.



  • @Gąska Yes, you can, and it's extremely useful when defining non-member functions (operators, swap etc.) associated with a class template with less than simple parameters because you don't have to repeat the monstrosity of the template declaration for each.



  • @Steve_The_Cynic oh, they know what it should do. It’s just that the exact definition of specific things changes with the wind.

    Agile development, yo.


  • BINNED

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

    @cvi TIL you can put friend function definition in class body. And I'm sure that's not the last surprising bit of C++ I'll encounter.

    There‘s more to it: this creates a “hidden friend” that’s not visible at namespace scope but only found via ADL.


  • Banned

    @topspin oh my fucking god I hate it.



  • @topspin Which is, of course, OK, since operators are always looked up using ADL…


  • BINNED

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

    @topspin Which is, of course, OK, since operators are always looked up using ADL…

    Unless when they're not. But it is in fact considered a feature:

    Summary

    Hidden Friends are a great way to add operations to a specific type without permitting accidental implicit conversions, [...]



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

    @topspin oh my fucking god I hate it.

    I try to include something in my code samples that triggers the crowd here (out over using C++ in the first place), but in this case the friend was just to save me some typing. I figured the whole example was terrible enough to begin with. 🤷

    Although I kinda hoped somebody would get upset at using an uppercase '.H' file extension to indicate a C++ header.


  • BINNED

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

    Although I kinda hoped somebody would get upset at using an uppercase '.H' file extension to indicate a C++ header.

    I just assumed you're typing on Windows. 🍹



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

    Although I kinda hoped somebody would get upset at using an uppercase '.H' file extension to indicate a C++ header.

    Why? It's the correct suffix 🐠.

    It somewhat surprises me that while everybody uses a specific suffix for the source files (they have to so the compiler knows it's looking at C++) – even if they can't agree on whether it should be .C, .cc, .cpp or .cxx – most just use the same .h for both C and C++ headers so you can't tell. The correct convention would be to match the source one, so .H with .C, .hh with .cc, .hpp with .cpp or .hxx with .cxx.


  • Discourse touched me in a no-no place

    @cvi You realise this requires that I post this now?

    fb22015c-d759-4eeb-9d0d-8809d4c5b059-image.png


  • BINNED

    @dkf this also quite well fits the OP "let's break or() in a minor version" and "let's monkey-patch string to provide an .america attribute" over :arrows:.


  • Java Dev

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

    they have to so the compiler knows it's looking at C++

    False. You either call a dedicated C++ compiler or pass a separate flag indicating C++ compilation is required.

    The special file extension is so the makefile can pick it up and do the needful.



  • @Arantor Sounds like they don't know, despite their protestations. After all, if the thing they want to do is :

    • Fleen an ogglefloggle

    but they change their mind weekly what "fleen" and "ogglefloggle" mean, then you can say with some certainty that they don't know what they want the thing to do.



  • @cvi That's horrible. Well played!



  • @Steve_The_Cynic well, their core business is x. The website does x and requires a number of pages’ worth of steps to collect all the data. But then they decide that instead of x being 4 steps, they want to rearrange which step gathers what data where, and make it 3 steps. So shuffling items between pages, including rendering and validations. And, of course, manage the informational dependencies introduced in so doing because some of these are conditional.

    But then they add y to their business which is superficially logically similar to x, but has a whole raft of special edge cases just for y. Of the kind where step 2 of 3 displays FooBar component instead of FooBaz component, and the second half of step 3 is not relevant for y.

    Then they add z to their business which in their mind is like x except for half the steps being prescribed as fixed values rather than the customer entering them, which also means we skip step 2 for that workflow even if the underlying data still needs to be shuffled to all the relevant APIs.

    Then it turns out that adding y introduces some super specific edge cases of usability and we need to tweak parameters that get introduced at the top level and have to be sorted through the hierarchy of components to update the bottom of the tree in the one case it matters.

    Then introduce localisation. Based on IP address lookup, but only to detect the US (everyone else gets a drop down). And adjust several UI components because the rest of the world can cope with not being first on the list, but the US can’t apparently. This also extends to localising product names and dimensions just for America because not metric.



  • @dkf I don't know if I ever got the necessary qualifications to answer that second part. Figure it's best not to worry too much about it.



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

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

    The best solution. Now everybody can hate the formatting style equally!

    #include "my_first_math.H"
    
    int f()
    {
        Result<int> result;
    
          123456
        +  98765
        - ------
          result
        ;
    
        return result;
    }
    
    my_first_math.H
    template< typename T >
    struct Result
    {
        T value;
    
        operator T&() { return value; }
        operator T const&() const { return value; }
    
        Result& operator--() { return *this; }
        friend Result& operator-( T value, Result& res )
        {
            res.value = value;
            return res;
        }
    };
    

    f424ff4c-eaf1-40fb-9d87-ca84d0197524-image.png



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

    Then introduce localisation. Based on IP address lookup

    Why by the Oh God of Gibberish? The browser conveniently provides it's selected language in navigator.language (and some alternates in navigator.languages) and it's extremely unlikely that will will have something the user does not actually understand, while proxy in foreign country with different language is somewhat common in large corporations (had that in my first job).


  • Considered Harmful

    @topspin do you want something less stupid to happen if you look for somestring.america? Hopefully it supports chained use...



  • @Bulb because too many people have en-US as their locale including in the UK. This is a business that is mostly UK for now but growing in the US and this is all about accommodating the US users who are apparently too stupid to cope unless the site is pre-set for their language, currency, imperial dimensions etc. when the UK (default) site has different currency and metric everything, and we want to 'give a first class experience to both sets of users'.


  • Considered Harmful

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

    @Arantor Sounds like they don't know, despite their protestations. After all, if the thing they want to do is :

    • Fleen an ogglefloggle

    but they change their mind weekly what "fleen" and "ogglefloggle" mean, then you can say with some certainty that they don't know what they want the thing to do.

    You can still make an oggleflogglefleener service, it just needs take take a fleening strategy at construction. The ogglefloggles are on the stack. If you don't keep your head on straight you'll end up floggling your fleens.


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



  • @topspin
    They could at least have called them "imaginary friends".


  • ♿ (Parody)

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

    And adjust several UI components because the rest of the world can cope with not being first on the list, but the US can’t apparently.

    The :kneeling_warthog: is real here.



  • @boomzilla I honestly don't know. I'm just outlining the customer's requirements to us.


  • ♿ (Parody)

    @Arantor I'm only being kind of snarky here. We're not really used to seeing international stuff, at least when we're going to a site where we're paying for something. We'd probably assume that you'd have to be in Europe or the UK or whatever to use the site (and maybe wouldn't trust sneaky foreigners anyways) and go somewhere else.



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

    accommodating the US users who are apparently too stupid to cope unless the site is pre-set for their language, currency, imperial dimensions etc. when the UK (default) site has different currency and metric everything

    Ok, that explains GeoIP for US only well.

    Myself I actually have en-GB set in Czechia because I know English well enough and the Czech translations are often trash (and Czech pages rarely have English versions at all, https://mapy.cz being a notable exception – and yes, that defaults to English for me due to that setting). But I also used to work in place where I accessed internet through a proxy in Vienna and Google trying to redirect me to google.at was really obnoxious, because I don't know much German.



  • @Bulb So far, I've only seen one or two sites that did manual language selection correctly. All the rest do it wrong. All of them.

    Which sites? And what does "correctly" mean?

    The sites were Fedex for sure, and I think UPS. Both allow the poor schmuck who has to navigate the site to independently choose:

    • Which country's Fedex services to display information about.
    • What language to display them in.

    I can read and write French well enough to get by if I have to, and I generally don't bother avoiding it, but if I'm in a hurry, I prefer to read about stuff in English since it's my native language. So, on Fedex's site, and the pîtifully small number of other sites that do the same thing, I can choose to read about their service offerings for people who are in France, and I can read about those offerings in English.



  • @Arantor You are in Hell. I know you probably didn't need me to tell you that, but I felt that I should relieve you of any trace of doubt.


  • Java Dev

    @Bulb I have en-US set as default language, in the hopes that any open source downloads will be more likely to give me their English versions instead of their mediocre and less googleable Dutch translations.



  • @PleegWat Basically the same reason, except en-GB gives me metric units where it makes a difference.



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

    @PleegWat Basically the same reason, except en-GB gives me metric units where it makes a difference.

    Wait, units based on locale? I've never seen a website doing that. Or application...

    But en-GB is very useful to get a sane date format.


Log in to reply