<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by James on Medium]]></title>
        <description><![CDATA[Stories by James on Medium]]></description>
        <link>https://medium.com/@james._.watson?source=rss-afad224a1eb4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*x2PWfs2NNPJYc-2MqBEJ_g.png</url>
            <title>Stories by James on Medium</title>
            <link>https://medium.com/@james._.watson?source=rss-afad224a1eb4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:27:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@james._.watson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Logical Fallacies: 'Haters']]></title>
            <link>https://medium.com/@james._.watson/logical-fallacies-haters-025bd8c228ae?source=rss-afad224a1eb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/025bd8c228ae</guid>
            <category><![CDATA[reasoning]]></category>
            <category><![CDATA[debate]]></category>
            <category><![CDATA[logical-fallacies]]></category>
            <dc:creator><![CDATA[James]]></dc:creator>
            <pubDate>Sat, 28 Feb 2026 18:50:06 GMT</pubDate>
            <atom:updated>2026-05-14T00:29:30.540Z</atom:updated>
            <content:encoded><![CDATA[<h3>Logical Fallacies</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xIg2qTuzoUOv-DO9dOkxkQ.jpeg" /><figcaption>Credit: <a href="https://commons.wikimedia.org/wiki/User:Hindustanilanguage">Muzammil</a> via <a href="https://commons.wikimedia.org/wiki/File:Stop_making_stupid_people_famous.jpg">Wikimedia</a> Liscense: <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons v4</a>.</figcaption></figure><p>To continue my short series of articles that I am informally referring to as “Screaming Into the Void”, I’m going to try to write shorter articles and not agonize over them so much. The amount of views I get per hour of time spent isn’t adding up for me. Maybe this is a terrible idea, but here we go:</p><p>I’ve been thinking about bullshit a lot lately. Our daily lives are crammed with bullshit. And by that I don’t mean something like “the stuff I believe in isn’t bullshit but everything else that people believe is.” I mean, people are just bullshitting each other all the time. It’s almost as if bullshit is a requirement in any discussion. In my paranoid imagination, high school debate judges must now have part of their rubric dedicated to bullshit (and score it positively.)</p><p>I’ve long understood that many people are fond of using specious logical fallacies as rhetorical weapons. I’ve also been aware that many people are absolutely convinced by these terrible arguments. But I don’t think I appreciated until recent years, just how large that contingent of people is. Another thing I didn’t really appreciate is how many people almost unconsciously jump to logical fallacies when pressed to support their arguments. There are various reasons people might do this, but I’ve started to feel that a lot more people actually believe that using logical fallacies is part of effective argumentation than I realized. Not in the sense of ancient Greek <a href="https://en.wikipedia.org/wiki/Sophist">sophistry</a>, where people are trained to use these techniques, but that they don’t even realize that these types of arguments are fundamentally unsound.</p><p>And, to be fair, why should they? These arguments are thrown around constantly and almost no one points out that they are bullshit. The public education system takes puts almost zero effort into teaching logical reasoning, in my experience. I should probably note that I am speaking from the perspective of the US. We’ve got logic problems up in here. I can’t really speak to the situation in other countries.</p><p>There are many kinds of bullshit being tossed around. The sort of common, everyday, variety is just making up stuff. Basically lying, but so carelessly that you can’t even call them on it, because it’s such obvious bullshit you seem ridiculous taking it seriously. I’m sure you’ve got someone in mind already.</p><p>The kind of bullshit I’ve been thinking about is a little more subtle. I’m talking about the kind where a specious argument (one that ‘sounds’ good, but isn’t) is made. There are some well known arguments of this type. <a href="https://en.wikipedia.org/wiki/Ad_hominem">Ad hominem</a> attacks are quite popular with the most elite <em>untellectuals</em>. While a lot of people fall for that, it’s not catching any clever people. But some of these arguments, I’m a little surprised by the people that are buying them.</p><p>I’m trying to keep this short so I am only going to talk about one simple example here. If this goes well (how well can screaming into the void really go?) I’ll probably follow up with more.</p><h3>Haters</h3><p>I’m not sure what name this is fallacy is normally given. There’s <a href="https://en.wikipedia.org/wiki/List_of_fallacies">probably some name for this</a>, but I’m too lazy to figure it out right now. Feel free to let me know what it is called in the comments, if you know.</p><p>Anyway, I’m going call this the ‘haters gonna hate’ argument for now. It has this basic form:</p><blockquote>People said X was impossible, then X was eventually proven to be possible. People say Y is impossble. Therefore, Y will eventually be proven to be possible.</blockquote><p>It should be obvious what the issue is. Some people have <em>incorrectly</em> predicted that things won’t happen in the foreseeable future and then they do. More people have <em>incorrectly</em> predicted things will happen that never happen. Many people have <em>correctly</em> predicted that something won’t happen and it doesn’t. Some people have <em>correctly</em> predicted that something will happen and it does. Plucking an anecdotal example from one of these scenarios doesn’t tell you anything about the correctness of a given, independent prediction, and has no bearing on the arguments made for that prediction, period.</p><p>You’ll see same basic logic in a lot of varying plumage. For example something like this:</p><blockquote>People say data centers in space won’t work from a financial perspective. In the not too distant past, people also said the internet was a fad.</blockquote><p>Now the trick here is that the illogical conclusion isn’t actually stated but it’s still there, clearly implied. We can assume that’s the implication because, if you weren’t implying that the second sentence weakens the claim in the first, it would be a ridiculous non-sequitur. Not stating the false conclusion is also useful if you wish to deny making that argument, but a lot of the time, many (most?) people don’t seem to even notice. They just accept this as a ‘good point’.</p><p>This kind of thing is often used for promoting crypto scams. I recall when I was (irrationally) obsessed with the <a href="https://resources.cryptocompare.com/asset-management/9913/1742380585554.pdf">DRIP crypto scam</a> which I encountered here on Medium. I’m not going to waste a lot of time explaining the idiocy of that but basically the idea was you would deposit money and get 1% daily returns on 90% of it for a year. There’s more obfuscating nonsense to the scheme but that’s the essential idea. Now, it should be obvious to any adult who finished primary schooling that, in order to make that work, the number of ‘coins’ would need to inflate infinitely. You can’t take a 10% “tax” and pay out a total of more than 10% any other way than increasing the supply. Of course that ponzi collapsed/rug-pulled, and a lot (but not all) the articles promoting this have been removed from Medium. One of my favorite pro-DRIP articles was a detailed explanation about how you, as an individual person, could reap more coins from the system than were initially created, yet the author was quite insistent that the system was sound and that it was unlikely to ever need to inflate the supply of coins. And that author is supposedly a graduate of Stanford! But, I suppose, <a href="https://en.wikipedia.org/wiki/Elizabeth_Holmes">why graduate</a> from Stanford anyway? Simply attending for a short period of time appears to fully qualify you as <a href="https://en.wikipedia.org/wiki/Sam_Altman">an expert money incinerator</a>.</p><p>In any event, when I pointed this out (repeatedly,) numerous people would respond that ‘people said bitcoin was worthless’ (disclosure: I believe it is in fundamental sense and I have some money on it crashing) or ‘people said NFTs were a bubble’ (LOL.) And, while I’m not sure all of those people were sincere (they may have been in on the pump-and-dump scheme,) a lot of people put money into DRIP and really seemed convinced by that kind of ‘logic’. Then the whole thing imploded (because it was inevitable) and they lost their money. Did they learn a lesson? I’m not so sure. I think many of these same people are still losing money to similar scams.</p><p>There’s not really much more to say about this fallacy. It’s a really dumb argument. If you find someone making it, or find yourself making it, you should probably, stop, step back and think about what’s happening. You may be getting scammed in the former case, or rationalizing in the latter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=025bd8c228ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Sleeping Beauty Paradox Redux]]></title>
            <link>https://medium.com/@james._.watson/the-sleeping-beauty-paradox-redux-f8c05ea1fbd3?source=rss-afad224a1eb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8c05ea1fbd3</guid>
            <dc:creator><![CDATA[James]]></dc:creator>
            <pubDate>Sat, 10 Aug 2024 17:37:06 GMT</pubDate>
            <atom:updated>2024-08-16T21:23:42.208Z</atom:updated>
            <content:encoded><![CDATA[<p>Usain Bolt versus Taylor Swift in a footrace? Can you be fooled into choosing the latter as the favorite to win?</p><p>If you are one of the handful of people who’ve read my previous article about the <a href="https://medium.com/@james._.watson/the-simple-answer-to-the-sleeping-beauty-paradox-19b14826d112">“Sleeping Beauty Paradox”</a>, you may have looked at one of the links near the end of the article to a Scientific American article named <a href="https://www.scientificamerican.com/article/why-the-sleeping-beauty-problem-is-keeping-mathematicians-awake/">Why the ‘Sleeping Beauty Problem’ Is Keeping Mathematicians Awake</a>. by Manon Bischoff<strong>. </strong>I happened upon this article as I was finishing the last draft of that article. I was just looking for a reliable source to demonstrate a point about how much has been written about the ‘paradox’, which I think it did. Also, it was written quite well, and published in a well-known scientific magazine. The end of the article caught my eye, though and I think it describes a really good problem to expand upon the concepts in my previous article. If you haven’t read that, please at least give it a skim. If you are familiar with ‘the Sleeping Beauty paradox’ and don’t think the answer is clearly 2/3, you should definitely <a href="https://medium.com/@james._.watson/the-simple-answer-to-the-sleeping-beauty-paradox-19b14826d112">read it first</a>.</p><p>I will now continue to scream into the void.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*pjWDTSkLkRdNDusNBxSc_w.jpeg" /><figcaption>How these ‘paradoxes’ make me feel: <a href="https://commons.wikimedia.org/wiki/File:Edvard-Munch-The-Scream.jpg">“The Scream”</a> by Edvard Munch</figcaption></figure><blockquote>For example, instead of a coin toss, a sports bet could be used, such as a footrace pitting retired sprinter Usain Bolt against singer Taylor Swift.</blockquote><p>Okay. Sure, why not?</p><blockquote>In this scenario, if Bolt, a world record holder in multiple running categories, defeats the pop star — as most people would anticipate — Sleeping Beauty will only be awakened once on Monday. But if, contrary to all expectations, Swift proves swifter, Sleeping Beauty must wake up every day for a month, 30 times in a row.</blockquote><p>It’s either one day (Bolt wins) or 30 days (Swift win) instead of either one day (heads) or two days (tails) as in the original. Got it.</p><blockquote>The probability of Bolt losing to Swift is very low.</blockquote><p>100% agreement.</p><blockquote>But if we apply the same logic that motivated the ⅓ response, we need to treat those scenarios with equal weight. Sleeping Beauty would still have to bet on a Swift victory after waking up …</blockquote><p>There’s no point in continuing with the rest of this sentence because it’s based on the non-sequitur that it begins with. We absolutely <strong>don’t</strong> need to treat those scenarios with equal weight. And we should not bet on Swift upon being awoken. Suggesting that we do implies a gross misunderstanding of conditional probabilities. It would <em>only</em> make sense to assume a Swift victory if you assign a <strong>much</strong> greater probability of Taylor Swift beating Usain Bolt in a foot race than I do. Unfortunately, Bischoff doesn’t say what specific race they would be running or give any (unconditional) odds for a Swift victory in a that race. I think we can make reasonable assumptions about these two elements of the problem, however.</p><p>If a sports betting operation would give me even odds on a (fair) Swift/Bolt match-up, I’d wager real money that Usain Bolt could beat Taylor Swift in <em>any</em> track event. But, for the sake of simplicity, I will assume we are talking a 100 meter or 200 meter dash, since that’s the race that Bolt dominated.</p><p>I’m entirely ignorant of how fast Taylor Swift can run and I’m not going to search for an answer or ask some confabulating AI about it. I have not seen anything that suggests that she is fast and I have no reason to think she is. It’s, simply, not something that she’s know for. Usain Bolt on the other hand, is the world record holder for both the 100 meter and 200 meter dash (per <a href="https://en.wikipedia.org/wiki/Usain_Bolt">Wikipedia</a> at the time of writing.) For the sake of argument, lets assume we are talking about roughly the same performance a when he set those records or at least that he is still a world-class sprinter when this hypothetical race is to happen.</p><p>Think for a moment what chance you would assign to Taylor Swift winning this race. One out of a million? If I were pressed for an answer, I’d probably just blurt that out because a ‘million’ is shorthand for ‘big number’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*e8AoW75fisMDHe2c8pfxaw.gif" /></figure><p>Realistically, Swift’s odds might be one-in-a-billion. Humans aren’t good at estimating unlikely probabilities. No rational person thinks Taylor Swift has a real chance, right? The only real question is how <em>insignificant</em> her chance is. I would love to hear what odds a bookie would give Swift in such a match-up.</p><p>I’m going to give Swift a very generous 1% chance of winning in the explanation that follows. That is, out of a 100 races between them, I’m saying she would win 1 of them and Bolt would win the other 99. To be clear, I think the actual odds of Swift beating Bolt in such a race are much, much, lower. Giving her 1% is simply convenient for the explanation and visualizations that follow. But, even if we grant these overly optimistic odds to Swift, it’s easy to show that we don’t have to ‘give equal weight’ to these options, even in the ‘extreme’ 30 day versus one day scenario. Upon being awakened, we should still think that it’s unlikely that Swift won the race.</p><p>I’m going to use the same general approach as in <a href="https://medium.com/@james._.watson/the-simple-answer-to-the-sleeping-beauty-paradox-19b14826d112">my previous article</a>. But we need to be slightly more sophisticated due to the fact that we are <strong>not</strong> talking about equally likely unconditional odds. That is, in the simpler version of the ‘paradox’, the odds of heads or tails is even or 50/50 and the odds of it being either Monday or Tuesday is also presumed to be even. That means all four quadrants in the original problem have the same raw, unconditional probability of 25%. That’s absolutely <strong>not</strong> the case here. To get started, here’s a diagram comparing the chance of a Swift win to a Bolt win given the assumption that Swift has a 1% chance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0CD4-HZ_MbpoFZ29wlBIow.png" /></figure><p>The diagram above is drawn to scale and shows a thin slice of red representing Swift’s chances and a large area of blue representing Bolts chances. To make things easier to see (and verify,) I have divided this diagram into 100 equal slices: The first line is Swift’s (red) and the next 99 are Bolt’s (blue):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*TVFUnDSTpBSMUU42_Qh1OA.png" /></figure><p>Now we can address the 30 days of potential awakening. That is simply done by dividing the cells vertically into 30 equal parts like so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*bP7zsqUM-LprLigfxMgE9w.png" /></figure><p>We now have 3000 <strong>equally sized</strong> cells representing each racer’s chances under the 1% Swift win assumption. 30 for Swift and 2970 for Bolt.</p><p>Similar to the simpler version of the problem, if Bolt wins, the awakening only happens on day 1. So we know that if we are awakened, it’s either day 1, or Swift won the race (or it’s day 1 and Swift won.) As in the previous problem we can eliminate all cells in the diagram which correspond to a Bolt win and being awakened on any day after the first. Based the way the problem is defined, we’d be doing something else in those cases (or still asleep) and therefore we know none of them are possible if we have been awakened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*CrhJRKwc-DZFLScj074MSw.png" /></figure><p>All the cells shown in gray are the scenarios which, upon being awakened, we know are impossible. Great, we are now ready to determine who we, upon being awakened, should guess won the race. Looking at the last diagram, which color seems to take up more area? If you said the blue cells, you are correct. The red cells correspond to the 30 cells associated with Swift winning the race and blue cells correspond to 99 cells associated with Bolt winning and being awoken on day 1. In the following diagram, I have arranged the cells so they are more easily comparable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*PiGGR7Rjh36qJk4hY13N4w.png" /></figure><p>There are 33 blue cells in each of the first 3 columns, which represent the odds of a Bolt win (when we are awakened) and 30 red cells in the last column representing the odds of a Swift win.</p><p>Using the logic of conditional probabilities, we then conclude that the chance Bolt won is 99 out of 129 or around 77%. Therefore, even in this “extreme” scenario, the odds are are still that Bolt likely won. The break-even chance for Swift in this 30 day scenario is an unconditional chance of a Swift win of 3.23%. So, as long as you agree with me that Swift has no significant chance of beating Bolt in a footrace, you should guess Bolt won if you are awakened in this experiment.</p><p>If you are having a hard time accepting this result, I think it might come back to something I mentioned earlier: humans have terrible intuition about probabilities, especially when probabilities are small. Here’s an example of a problem that has the same general structure but I think is easier to reason about:</p><p>An experimenter flips a fair coin up to 30 times. As soon as tails comes up, the experimenter stops flipping the coin. 100 opaque and identical cups will be placed on a table. If the coin came up heads 30 times in a row, a ball will be placed under every cup. Otherwise, one cup, selected at random, will have a ball placed under it.</p><p>After this setup is complete, you are are brought in to the room, the procedure above is explained, and you are asked to select a single cup. It is lifted, and reveals a ball. You are asked to guess whether the coin came up heads 30 times in a row. If your answer is right, you’ll get $1,000 in cash.</p><p>What should you guess? It seems unlikely that you would happen to select the one cup out of 100 that had a ball under it, right? But if you think that must mean that all the cups have a ball under it, you are assuming a <strong>much</strong> more unlikely thing occurred. The chance of a fair coin coming up heads 30 times in a row is less than 1-in-a-billion chance. It doesn’t make sense to believe that a 1-in-a-billion event is likely because you think a 1-in-100 event isn’t. It’s 10 million times more likely that you happened to select the one cup with a ball than that a fair coin came up heads 30 times in a row.</p><p>Perhaps you might think this is some sort of scam or set-up. And in a real-life situation (e.g.: crypto ponzinomics,) that’s a pragmatic mindset. But that kind of thinking isn’t useful when discussing or reasoning about a properly defined thought experiment.</p><p>What if there’s a million potential awakenings? It’s an absurd hypothetical scenario given that 36,000 days is considered a long life, but, I’d still go with Bolt. I think her chances are negligible i.e., nearly indistinguishable from zero. That brings up another issue with this kind of ‘paradox’: it’s ill-defined. Are we considering the wildly unlikely but technically possible <a href="https://en.wikipedia.org/wiki/Black_swan_theory">tail-risk</a> events such as a meteorite striking down Bolt during the race? We are left to determine the odds on our own.</p><p>When crucial details are not clearly specified in these problems, people may make make very different assumptions. And people can come to very different but correct logical solutions. When those assumptions are not explained, some people may incorrectly think that probability is all squishy guessing and treat wildly incorrect explanations of basic probability as if they are on the same footing as correctly reasoned ones. The normalization of such sloppy thinking by people who should know better is not just embarrassing, it’s irresponsible.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fj95kNwZw8YY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dj95kNwZw8YY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fj95kNwZw8YY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/59b9dbd984d98a6ec8d091f2fe5e9fa3/href">https://medium.com/media/59b9dbd984d98a6ec8d091f2fe5e9fa3/href</a></iframe><p>Why is a theoretical physicist who, I must assume, has much better mathematical understanding and capability than I, making such a basic error when considering a relatively simple problem? I say ‘relatively’ because, compared to what physicists normally contemplate, this should be a walk in the park. I really don’t have an explanation for this, but I find it worrisome. If people with the education and skill level of Bischoff can be swayed but such obviously dubious reasoning long enough to write and publish an article for a major scientific magazine, what hope does the average person have in a world of specious half-truths and fallacious arguments?</p><p>Maybe it’s the excessive use of <a href="https://www.fitelson.org/probability/lewis_sb.pdf">over-wrought jargon and notation</a> used to analyze something so simple that leads smart people to fool themselves. I understand the need for formal proofs but maybe we should start with a more obvious and intuitive explanation first, when possible. I think, perhaps, we as a society don’t flex these statistical ‘muscles’ enough that they become reflexive. If I could wave a magic wand and change our primary education system, I would greatly increase the resources and attention given to probability/statistics and logic/reasoning.</p><p>In order to make time for that, we could drop the years of tedious rote calculations that we (at least in the US) condemn innocent children to for no real purpose. Unless the goal is to make kids despise mathematics, I don’t understand why we continue to pretend this is a good way to teach. I’ve seen some improvement on this with my own kids’ schooling, but there’s always some photocopy of a photocopy of a photocopy with the ‘old way’ tucked into the homework folder. Teachers usually tell me that it has something to do with parents who have shitty math skills not understanding why ‘they’ need to “change math.” To the parents who think this: it’s because you don’t really understand mathematics and the reason for that might have something to do with being taught the ‘old way’. Sorry to be rude about it but please, stop getting in the way of progress just because it makes you uncomfortable.</p><p>Crucial topics with real world relevance, in contrast, are treated as being too esoteric, difficult, and unnecessary for most students. In the real world, the average person living today is drowning in an ocean of bullshit and the ability to do computations with pencil and paper is worth nearly <strong>NOTHING</strong>. Logic and reason are essential to cope with the endless deluge of nonsense. Understanding basic probability and statistics can allow us to get above it and see the world more clearly. We need to discuss it and write about it more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8c05ea1fbd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Simple Answer to the ‘Sleeping Beauty’ “Paradox”]]></title>
            <link>https://medium.com/@james._.watson/the-simple-answer-to-the-sleeping-beauty-paradox-19b14826d112?source=rss-afad224a1eb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/19b14826d112</guid>
            <category><![CDATA[nonsense]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[paradox]]></category>
            <dc:creator><![CDATA[James]]></dc:creator>
            <pubDate>Sun, 21 Jul 2024 15:42:54 GMT</pubDate>
            <atom:updated>2024-07-21T21:15:04.371Z</atom:updated>
            <content:encoded><![CDATA[<p>Don’t let the misdirection fool you</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*dbFwpH60Ln0WM7zC5qxhlA.jpeg" /><figcaption>Collage by author using images from <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><p>Over the last year or so, I’ve encountered the “<a href="https://www.princeton.edu/~adame/papers/sleeping/sleeping.pdf">Sleeping Beauty Paradox</a>” in articles such as <a href="https://medium.com/@theo.seeds/why-probability-isnt-real-df50b72a073e">“Why probability isn’t real”</a> and on Derek Muller’s “Veritasium” YouTube channel, that present a fairly straightforward probability problem as some sort of mind-blowing paradox. This ‘paradox’ has been floating around the interwebs for a while, I just wasn’t aware of it until I saw the article linked above. Initially, I was a little confused by the ‘paradox’. But after breaking down the problem using fundamental principles of logic, I realized that the problem is not paradoxical and when stripped-down to its essential elements, relatively simple to understand. I would like to share this analysis with anyone who will take the time to read it.</p><p>We live in a world where there a many competing and contradictory narratives. Blindly trusting any source is increasingly questionable and sometimes risky to your financial, mental, and/or physical health. I hope that the explanation that follows demonstrates how relatively simple logical reasoning can be used to clear the some of the fog of misinformation and misdirection. I do not ask anyone to take these claims on faith. The argument I am presenting here is based on reason and basic principles of probability. If you have any doubts about my argument, please ask for clarification in the comments.</p><p>First I need to introduce the ‘paradox’. Feel free to skip that section if you are familiar with it. I will then show that there is no paradox here. I will also explain that it is incorrect to assert that the answer to the question it poses is subjective or implies fantastical notions about our relationship with reality. I also hope to give the reader some tools for understanding such problems and identifying the kinds of tricks that make them seem paradoxical.</p><p>As an aside, I think there is a valid argument for the idea that probability isn’t ‘real’. For example, I believe (as many do) that mathematics/statistics isn’t real in the way that an overflowing toilet is real or a broken arm is real, but that’s a very different kind of argument about the meaning of ‘reality.’ I don’t want to go down that rabbit hole in this article, just acknowledge it.</p><p>Let’s get to describing the problem. Quoting the “<a href="https://medium.com/@theo.seeds/why-probability-isnt-real-df50b72a073e">Probability isn’t Real</a>” article:</p><blockquote>Here’s how it goes. An experimenter flips a coin on Sunday. Then, he puts his experiment subject, Sleeping Beauty, to sleep. When Sleeping Beauty wakes up, she won’t remember if the coin was heads or tails, and she won’t remember if she’s been woken up before.</blockquote><blockquote>If the coin’s heads, then the scientist wakes up Sleeping Beauty on Monday.</blockquote><blockquote>If the coin’s tails, then the scientist wakes up Sleeping Beauty on Monday, puts her back to sleep, and then wakes her up again on Tuesday.</blockquote><blockquote>So, suppose you’re Sleeping Beauty, and you wake up. You have no idea how the coin flip went and you have no idea what day it is. What’s the probability that the coin came up heads?</blockquote><p>So far so good. Now comes the author’s conclusion:</p><blockquote>There are two ways of looking at this problem. They both make sense when you explain them. They both seem equally valid. And they both give you completely different answers.</blockquote><blockquote>One way of looking at the problem is looking at the coin flip. The coin had a 50/50 chance of being heads. And you’re gonna wake up either way — the fact that you’re awake now gives you no new information about the coin flip. So the coin is still 50% likely to have come up heads.</blockquote><blockquote>Another way of looking at the problem is by looking at the fact you’ve woken up. Suppose you ran this experiment [2]00 times. Sleeping Beauty would wake up 100 times in a world where the coin was heads, and 200 times in a world where the coin was tails. So if you’re Sleeping Beauty and you’re waking up, there’s only a 1/3 probability that the coin was heads.</blockquote><p>This conclusion isn’t correct. Both views are not “equally valid.” Potentially, there are two different answers to two different questions, but I don’t think that’s the confusion. This ‘paradox’ is largely just a trick question. It is presented in a way that is unnecessarily confusing and adds a good amount of emotional baggage. It reminds me of one of the most (IMO) hilarious “<a href="https://cs.fit.edu/~kgallagher/Schtick/How%20To%20Write%20Unmaintainable%20Code.html">how to write unmaintainable code</a>” techniques called ‘Bedazzling Names’ where you use emotionally loaded (but irrelevant) concepts to distract the reader from what is actually important. That is, you name two variables something like ‘god’ and ‘superman’ and when you have conditions like ‘if superman &gt; god’, it distracts the reader from what the code actually does. In other words, if ‘Sleeping Beauty’ were replaced with ‘some guy’ or ‘you’, I think it would be more obvious that there’s not much of a puzzle here.</p><p>To demonstrate that there’s nothing mysterious or surprising about this, and that there is one correct way to understand this problem from a probability perspective, I have created an equivalent example which I think is more relatable and less distracting:</p><p>You are taking a class in school. The teacher is a little quirky and announces that the next test will be either:</p><ul><li>A one-hour essay</li><li>A two-hour multiple choice test</li></ul><p>However, the teacher will not tell you until the beginning of the test. They will flip a coin that morning and if it comes up heads, it will be the one-hour essay. If it comes up tails, it will be the two-hour multiple choice test.</p><p>On the morning of the test, you realize you have overslept. You race to class as fast as you can, without checking the time. When you get there, you can see that the test is in session but you can’t tell what kind of test they are taking. At that point, what is the chance that the coin was flipped tails?</p><p>To break this down we start with what we know. There is a 50/50 chance of flipping heads or tails. At the very least, you know you must have arrived within two hours of the beginning of the test because it is still in session. The chance that you have arrived in the first hour is equally as likely as the chance that you arrived during the second hour. We can represent these options as a 2-by-2 grid, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMKp_YOmSRZqkzGzqHb_1A.jpeg" /><figcaption>Grid created by author</figcaption></figure><p>If we don’t consider your knowledge (on arrival) that the test is in session, each of the 4 cells in the grid represents an equally likely scenario. 1-out-of-4 (or 25%) chance of being the actual situation. In probability/statistical terms, this is called the <em>unconditional</em> probability.</p><p>Now that you have your raw probabilities laid out, you can fully incorporate the knowledge you have (the test is still in session) into the analysis as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J44HATesQ9Yq1nZbvS2CBg.jpeg" /><figcaption>Grid created by author with images from <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><p>You probably noticed that there’s something different about one of the cells (aside from it being a different classroom.) There’s no test happening in the upper-right-hand cell. That cell represents the situation where the coin was flipped heads and you arrived in the second hour. Because when you arrived while the test <strong>is</strong> in session, you can eliminate that cell as a possibility. Only three of the cells are possible given what you know.</p><p>Out of those three remaining cells, which represent possible scenarios, we can easily see that one cell applies to a heads result and two cells apply to a tails result. So we can conclude, given the knowledge that the test is still in session, that there’s a 2-out-of-3 chance that the coin was flipped tails. There’s only a one-out-of-three chance that the coin was flipped heads. In probability/statistical terms, this is called the <em>conditional</em> probability.</p><p>We have now arrived at a result with a denominator of 3 even though we started only with even chances for both uncertain aspects of the problem. This should not seem mysterious or strange. The fact that four minus one is three isn’t exactly rocket science.</p><p>So now I return to the Sleeping Beauty problem. You may have already seen how, even though the scenarios are unrelated, it’s exactly the same from a probability perspective. To show this, I will use the same grid approach as above.</p><p>The rows stay the same (heads and tails.) The columns are changed from ‘hour 1&#39; and ‘hour 2&#39; to Monday and Tuesday. Instead of icons to represent Sleeping Beauty’s knowledge of the situation, I’m using words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8lsC356-f3C-eN8wcXMaww.jpeg" /><figcaption>Grid created by author</figcaption></figure><p>Note that in the 3 cells where we previously had students, we now have the word ‘awakened’. In the cell which held the empty classroom (upper-right) we now have three question marks.</p><p>The question marks are used here to highlight what I think makes the question seem paradoxical. There is no mention of what happens to Sleeping Beauty on Tuesday in the case that heads was flipped. We really know nothing about Sleeping Beauty’s schedule on a typical Tuesday (e.g.: when no ‘scientist’ is waking her from a drug-induced slumber.) Maybe she goes to work. Maybe she takes her dog to the vet. Perhaps she binge-watches Netflix. What ever it is that she does, if she wakes up at home instead of being awakened by some creep, er — sorry, ‘scientist’, she knows for sure that the result of the coin flip was heads.</p><p>Simply put: there’s no way 1/2 can be the right answer to the question because there are <em>three</em> equally likely and mutually exclusive scenarios to consider. The fourth scenario can’t be true because we have knowledge that excludes it.</p><p>In other words, what I think is confusing here and may make it seem paradoxical is that the fourth scenario isn’t described directly in the problem. It’s something like a logical <a href="https://en.wikipedia.org/wiki/Cups_and_balls">cups and balls</a> trick. Personally, I don’t even think this “paradox” is interesting as a probability problem. If anything, what’s interesting about this problem is that <a href="https://www.scientificamerican.com/article/why-the-sleeping-beauty-problem-is-keeping-mathematicians-awake/">it has generated so many debates</a>, despite the simplicity of the solution. I believe that, like the magician’s trick of misdirection, the problem is constructed in a way that diverts your attention from the obvious solution. I do think it, when combined with an explanation, is a simple introduction to understanding the much more interesting <a href="https://en.wikipedia.org/wiki/Monty_Hall_problem">Monty Hall problem</a>.</p><p>This kind of ‘paradox’ falls under what some people call ‘probabilistic fallacies’. In this case the supposed paradox is based on substituting an unconditional probability for a (correct) conditional probability. I’ve come to realize that this kind of specious argument is prevalent in a lot of nonsense that is presented as wisdom on the internet. I hope this article gives empowers some people overwhelmed by these baseless claims to make sense of them. Or perhaps I should say, make <em>non</em>sense of them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19b14826d112" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Oriented Programming and Design: a practitioners perspective.]]></title>
            <link>https://medium.com/@james._.watson/object-oriented-programming-and-design-a-practitioners-perspective-3a664cef00b2?source=rss-afad224a1eb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a664cef00b2</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[object-orientation]]></category>
            <category><![CDATA[misconception]]></category>
            <dc:creator><![CDATA[James]]></dc:creator>
            <pubDate>Sat, 21 Jan 2023 17:39:29 GMT</pubDate>
            <atom:updated>2026-10-22T03:06:30.019Z</atom:updated>
            <content:encoded><![CDATA[<p>Object Oriented Programming is not as bad (or good) as many people present it to be.</p><h3>Introduction</h3><p>I’ve read a bunch of articles over the decades about how Object Oriented Programming (OOP, or just OO) is ‘bad’ that follow a familiar pattern: describe OOP in a way that is largely unrecognizable and then rip that straw man to shreds. Maybe ‘straw man’ isn’t completely fair because I don’t think these authors intend to misrepresent OOP. Rather, it’s more likely that the authors don’t understand it or how to use it effectively. I also don’t think this confusion is their fault: there are so many bad explanations of OOP floating around that even many people who believe OOP is a good approach are mostly ‘doing it wrong’. I’ll even go so far as to claim that a lot of college-level courses (or bootcamps; is that still a thing?) explain it very poorly. While I can’t know why the authors are compelled to write these articles, I would wager a guess that most have studied in a ‘serious’ computer science program where functional programming (FP) was preferred and then went to work in the software industry where OO-languages are dominant. I can imagine that such an experience would be very frustrating.</p><p>I get the sense that ‘standard’ OOP feels awkward and foreign to these programmers and when they try to research it, they find a lot of bad (but widely-accepted) information. I also think that a large contingent of people who call themselves ‘OO programmers’ have never really understood how to use OO effectively. It’s perfectly understandable that someone who has learned to use functional programming concepts and then has to navigate this minefield would think OO is garbage. I empathize with those people: (effective) OO has been mischaracterized for decades by supposed experts and explanations of how to use it effectively are really hard to come by. But much of their criticism of OO is based on misunderstanding and therefore falls flat.</p><p>Before I really dig into this, I want to be clear that by OO, I do <strong>NOT</strong> mean Alan Kay’s definition. To be sure, Alan Kay is a genius and his contributions to Computer Science put him in a very elite group. I also think that smalltalk was very much ahead of its time. However, smalltalk is not what 99.99% of people mean when discussing OO. The best analogy I can think of is that the word ‘egregious’ in current usage means “outstandingly bad; shocking.” but it’s archaic meaning is “remarkably good.” Now, if someone used the word ‘egregious’ (now) in the archaic way and expected you to not only understand them but follow their lead, would you be impressed? I would think they were being obnoxious and communicating ineffectively. Did Alan Kay coin the term? Yes, I believe that is well documented. Did it get hijacked? Yes, I can accept that. Does that change what people mean by OO? No, and that history is almost entirely irrelevant when discussing OO as it is generally understood and used.</p><p>Also, I want to be clear about another thing: I don’t consider myself to be particularly strong with FP, but I do know a little bit, mainly from learning Clojure (which I believe is considered to be a fairly pure FP language.) For that reason, this article will focus on OO. And, in the spirit of full disclosure, I feel that FP has many techniques where the OO equivalent is inferior or wholly absent. However, there’s something valuable in OO. In this article, I will attempt to separate the wheat from the chaff. I also want to note that I have tried to avoid the innumerable tangents and caveats that have come to mind. To that end I have purposely kept this at a somewhat superficial level. There’s just too much to this topic for me to go into depth on each aspect. My arguments may come across as more absolute than what I actually think.</p><p>I’ll start with the basic concepts commonly listed such as when you search for ‘OO programming principles’ or ‘pillars of OO programming’:</p><ul><li><strong>Inheritance</strong></li><li><strong>Encapsulation</strong></li><li><strong>Polymorphism</strong></li><li><strong>Abstraction</strong></li></ul><figure><img alt="A colorful image of abstract shapes generated by craiyon.com when given the prompt ‘Inheritance’" src="https://cdn-images-1.medium.com/max/1024/1*ow2Q1LWTycUwnjvF8DlNAg.png" /><figcaption>Inheritance — via <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><h3>Inheritance</h3><p>Inheritance is a term that is mainly used to describe two different concepts in OO: the inheritance of interface/contract and the inheritance of implementation. The former is a very useful approach which isn’t well-described by this term. It is revisited later in the article. but in this section I will be focused on inheritance of implementation which is usually what you see ‘toppled’ in anti-OO arguments.</p><p>While this concept has always been part of the standard definition of OO, I argue that competent developers who develop software with OO tools and techniques don’t use this kind of inheritance much. In my experience, inheritance beyond one or two levels is almost always a bad thing. It is problematic for a lot of the reasons that OO-bashers give e.g.: brittleness. And they aren’t wrong; it’s just that to the experienced OO developer, there is no significant disagreement. A common refrain from experienced experts is ‘composition is preferred over inheritance’. I feel inheritance of implementation is limited or absent in good OO designs and deep inheritance hierarchies are a great way to make a project unmaintainable. There are superior ways to share implementations that are more flexible and lack the downsides of this approach. In a nutshell, it’s correct to say that this kind of inheritance is a flawed feature OO. However, it has minimal applicability and expert OO practitioners really don’t care about it or use it much anyway.</p><p>The biggest issue with inheritance of implementation with respect to OO in contemporary practice is that courses and articles continue to focus on it as if it were the primary feature of OO that you need to understand. It is not, and you probably should use it rarely, if ever.</p><figure><img alt="An image of unidentifiable metallic objects generated by craiyon.com when given the prompt ‘Encapsulation’" src="https://cdn-images-1.medium.com/max/1024/1*gXevzVEKLLwjKqq_iVHRoQ.png" /><figcaption>Encapsulation — via <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><h3>Encapsulation</h3><p>This concept isn’t bad, exactly, but I think it’s largely oversold and overly strict encapsulation can be problematic. I’ve see highly misguided claims that encapsulation is important for security which is dangerous because it can create a false sense of, well, security. Any OO design that depends on encapsulation as a security feature very likely contains exploitable vulnerabilities. The reasons for that are beyond the scope of this article.</p><p>The primary thing that encapsulation provides is a way to delineate between the parts of your code that are ‘the contract’ that you intend to support over time and implementation details that could change in updated versions without warning. It also can help to manage parts of the solution that have constraints around how they are used. How Python supports encapsulation is, I think, a decent middle-road approach: it simply allows marking things as ‘private’ and hiding them in some contexts.</p><p>The goal of encapsulation is to manage coupling and make clear how other parts of a solution should interact with specific types of objects. I think the biggest issue with encapsulation is when it is fake e.g.: making a variable private and then providing a public method to modify it. This kind of cargo-cult mentality is rife in JavaBean-style programming and it’s derivatives which is discussed in more detail later in this article.</p><figure><img alt="An image of a shrimp-like creature generated by craiyon.com when given the prompt ‘Polymorphism’" src="https://cdn-images-1.medium.com/max/1024/1*Ro5JJzcrhCZJhwP5cygvDw.png" /><figcaption>Polymorphism — via <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><h3>Polymorphism</h3><p>Polymorphism means ‘many forms’ and (somewhat ironically), this term is used to describe many fundamentally different concepts. Exactly one of these types of polymorphism is crucial to understanding OO and the most of the others are uninteresting, irrelevant, and/or useless. This is problematic because I’ve seen many descriptions of OO where the author talks about the ‘wrong’ types of polymorphism. For example, I’ve read OO descriptions that talk about ‘method overloading’ (where you can have multiple methods with the same name but different arguments) as if it were the kind of polymorphism that matters in OO. In most OO languages, that kind of polymorphism is close to meaningless and it’s not always even supported (e.g. in Python). Non-OO languages also support method overloading as well. In my experience, it’s a feature that tends to cause a lot of confusion and therefore bugs.</p><p>Parametric polymorphism <em>is</em> useful but not a core OO concept. It’s a more advanced concept that is mainly a distraction when trying to understand the essential concepts of OO.</p><p>The only type of polymorphism that is important when really trying to understand OO is sub-typing polymorphism. This feature is implemented in various ways in OO languages. In Java ‘interfaces’ are the purest form of this. In Python, ‘duck-typing’ is used. For a language to be OO, it needs to have some sort of mechanism that supports this approach.</p><p>Regardless of the mechanism, the essential idea is that you have a set of method names and some sort of specification for how they are expected to behave. We can then write code that interacts with that specification without knowing anything about the implementation(s) that will be used at the time of execution. This is getting to the heart of what OO is about and deeply related to the next concept.</p><figure><img alt="Wavy purple and blue shapes generated by craiyon.com when given the prompt ‘Abstraction’" src="https://cdn-images-1.medium.com/max/1024/1*3Hxi60PM8HJ1beTfUzOvEA.png" /><figcaption>Abstraction — via <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><h3>Abstraction</h3><p>Abstraction is the essential core concept of OO but unfortunately a lot of descriptions of OO either explain it poorly or ignore it entirely. Abstraction in OO manifests itself mainly as sub-typing polymorphism i.e.: inheritance of interface/contract. This is the only thing that matters about OO if you are trying to understand it conceptually. It’s the common defining concept of object orientation (as scoped in the introduction.) All of the other concepts that are typically thrown around with regard to OO are details which may or may not be relevant in a given OO language. Code that doesn’t use this approach is not object oriented regardless of what language is was written in or whether the author calls it OO. Simply put: anyone who talks or writes about OO and doesn’t identify this as the defining feature is describing, at best, a degenerate form of OO.</p><h3>Other Claims about Object Orientation</h3><p>Beyond the textbook descriptions of OO, there are some other criticisms of OO that I’d to address. This may come off as a bit of a rant despite my efforts to avoid it.</p><h3>Mutability</h3><p>Often articles about OO talk about mutability as if it were inherently part of object orientation. There’s nothing inherent in OO which requires objects to be mutable. Unfortunately, it’s true that mutability is almost always the default in OO languages and that many inexperienced developers write code where every object is mutable, even if that mutability is never used. So, while this not really part of the definition of OO, it has become ubiquitous in OO code. I think this leads to the idea that it is a core OO principle. Mutablity makes code harder to reason about and can be highly problematic. When concurrency is involved, extreme care is required when managing state changes and limiting such changes is a must. I won’t go so far as to say that mutability should never be used. It’s just that, for most developers, mutability in objects should be rare and junior developers should try to avoid using it entirely. Unfortunately, some languages like Python provide very limited support for immutability. In such languages, you should still limit changing object state, even if the language doesn’t allow for enforcing it.</p><h3><strong>Naïve</strong> OO descriptions</h3><p>A lot of descriptions of OO are highly misguided. This applies to pro-OO, OO-ambivalent, and anti-OO descriptions.</p><p>A common example people use when trying to explain polymorphism is the Animal-Cat-Dog hierarchy. You have super-class named ‘Animal’ with a method ‘speak’ and two classes ‘Cat’ and ‘Dog’ that extend ‘Animal’ and implement their ‘speak’ methods to print “meow” and “bark” respectively. At a really high level, this is an OK example that gives a simple-to-write working example of sub-type polymorphism. But beyond the first day of 100-level programming class, it doesn’t offer much instruction and far too many people seem to never get past this unrealistic and silly type of example.</p><p>Probably the biggest problem with this kind of thing that it leads to the take-away that classes primarily or only represent real-world entities. Even worse, it suggests that you should have a separate class for each kind entity in your design. A ‘Tree’ class for every species (e.g. oak, maple, elm) is another similar example I’ve seen. But, as described, neither would indicate the need for polymorphism at all. The most pragmatic and OO way to implement that would be to do something like this:</p><pre>class Animal:<br>    def __init__(self, sound):<br>        self.sound = sound<br><br>    def speak(self):<br>        return self.sound<br><br>cat = Animal(&quot;meow&quot;)<br>dog = Animal(&quot;bark&quot;)</pre><p>The Python code above is trivial and ridiculously silly. And that highlights the point I’m making: the idea that you would create a class for every species of animal or tree is brain-dead. That would mean writing a new class every time you wanted to add a new one, just to get a new string out of ‘speak’. Such a disastrous approach would never survive a code review by any reasonably competent OO developer. I’d call this an obvious straw man if it weren’t for the fact that I’ve seen such examples given in seemingly earnest articles attempting to explain OO.</p><p>A much more helpful example would be something along the lines of a simple ‘list’ or ‘collection’ type. In Java for example, there are many list types. These can be used mostly interchangeably and the implementations only differ because they use different approaches for storing references to objects. ‘List’ is probably the most ubiquitous type in Java programs and it’s a completely abstract concept with no real-world analog. No new list types are needed to change simple properties such as shown in these ‘animal’ examples. Such examples really have almost nothing to do with actual real-world OO programming and I think they tend to confuse more than enlighten. For example, I believe this kind of thinking leads to the common anti-pattern of creating (or generating) a class hierarchy that is isomorphic to the entity model of a relational database.</p><h3>Mutable State Redux</h3><p>As mentioned previously, while it’s highly unusual, it is possible to write an OO program with limited or no mutable objects. In fact, most contemporary OO experts will strongly advise against introducing mutable state unless there’s a distinct advantage to doing so. As I mentioned above, if you read articles about the flaws of OO, you would think that mutable state is not only necessary, but a core OO concept. I believe part of this misconception originates with the highly-flawed notion of <a href="https://en.wikipedia.org/wiki/JavaBeans">JavaBeans</a>. (I’d love to throw a ‘dancing duke’ gif in here but I couldn’t find one without restrictions.) This was originally an approach to class design where ‘properties’ were defined by creating ‘getters’ and ‘setters’ on a class. Reflection was then used to find these ‘properties’ and pass them to other parts of the code. This wasn’t really an OO approach, at least not in the narrow definition of OO this article is discussing. It worked as intended, I suppose, but there are more straightforward ways to accomplish the same goals using standard Java interfaces and method calls i.e.: without reflection.</p><p>This concept was somewhat awkward and I think it might have been dreamed-up at <a href="https://en.wikipedia.org/wiki/Sun_Microsystems">Sun</a> as a way to show off Java’s reflection features. But the real big problem came later. JavaBeans gave developers the idea that this was how you do OO in Java. As Java’s popularity surged, a huge swath of the world’s developers started writing JavaBean-like classes but, crucially, did not use JavaBean frameworks or any reflection at all. Developers created gobs of classes with nothing but getters and setters or what I like to call ‘property bags’. These types of classes typically don’t leverage sub-type polymorphism or abstractions. They don’t have true encapsulation.</p><p>Working with such classes is effectively like working with C-style ‘structs’. Popular frameworks like object-relational-mappers (ORMs) and similar tools for XML came along that generated or required you create classes in this style. Many developers have come to confuse this style of development with OO. Because this approach tends to lead to large teams, before long, there was a huge contingent of developers who ostensibly had experience with an OO language with basically no experience with real object orientation.</p><p>Then, to make things even worse, C# came along with a feature that automated this misstep with a convenient syntactical sugar. This terse syntax hugely improved the ease of using a bad approach and further cemented the idea that is how OO should be done. But good OO code looks nothing like that. For sure, it does sometimes make sense to expose a immutable object as a property through a getter. But to make it mutable with a setter? That is almost always a terrible idea but many developers do this and never question it. Some seem to have no idea how to do anything else.</p><figure><img alt="A gorilla holding a bunch of banana in a jungle generated by craiyon.com from the prompt ‘banana gorilla jungle’" src="https://cdn-images-1.medium.com/max/1024/1*6OtsKC0BEjEoyBQheMu3UA.png" /><figcaption>Banana Gorilla Jungle — via <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><h3>Banana Gorilla Jungles</h3><p>There’s a quote by Joe Armstrong, the creator of Erlang that I’ve seen in a few critiques of OO:</p><blockquote>… Because the problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.</blockquote><p>I honestly don’t know what he is referring to here. Take the most common object in a Java program: the lowly string. It’s an object that refers to a character array. Where’s the gorilla? Where’s the jungle? I found some context that says this is ‘problem’ limits reusability but I can’t find any concrete examples of how. I found <a href="https://medium.com/codemonday/banana-gorilla-jungle-oop-5052b2e4d588">this article</a> which seems to be an honest attempt to explain it but there’s nothing implicit in the example given. It’s necessarily contrived.</p><figure><img alt="A poorly drawn picture by the author of a jungle, gorilla, and bananas with arrows pointing from the jungle to the bananas and gorilla and one arrow from the gorilla to a banana." src="https://cdn-images-1.medium.com/max/699/1*cdsv5iZiG5zx_A-U-k2RSw.png" /><figcaption>Jungle Object Model — by the author (released to the public domain)</figcaption></figure><p>Setting aside the fact that gorillas don’t eat bananas in the wild, I’ve drawn an object model of a jungle with a gorilla some bananas which is shown above. The arrows show the references or pointers. (I know what you are thinking: “this artist missed his true calling”) Note that the arrows are from the jungle to the gorilla and the bananas and from one gorilla to a banana. There’s no reference from the bananas to anything. If you only held a reference to a banana, you would be hard-pressed to use it to get to the jungle. You wouldn’t know that there even is a jungle. You don’t need to. You can even use bananas in a jungle-free context. Perhaps you want to use the ‘Banana’ type to model a supermarket instead. Nothing is stopping you. Go nuts, er uh, bananas!</p><p>If you ask for the jungle, you’ll get something that might hold references to bananas and gorillas and the gorillas might also hold references to bananas (or can provide them to you.) But that seems pretty expected and isn’t what was claimed. Can you design things in a way where every reference is doubly-linked i.e.: the banana has a reference back to the Gorilla and the Gorilla back to the Jungle? Of course, you <em>could</em>. It makes absolutely no sense to me; why would the banana need to have a reference to a Gorilla? And, it’s a lot of extra work to manage that and greatly increases the chance of bugs. Without a specific reason or requirement to do so, why would someone do that? The assertion that such backward relationships are implicit in OO is clearly factually incorrect.</p><p>I’d love someone to explain what this is meant to describe. Maybe more context would help. As far as I can tell, it is an overstated, if not completely imaginary problem. Maybe he is referring to transferring an object representations over the network or sharing memory between processes? Perhaps this is about native serialization features? Inheritance of implementation? It’s very unclear to me what problem is being described by this supposed flaw.</p><figure><img alt="A group of human figures in a snowy field surrounded by leafless trees generated by craiyon.com from the prompt ‘Visitors’" src="https://cdn-images-1.medium.com/max/1024/1*zAK45GGsHdh4WZGPvByAdQ.png" /><figcaption>Visitors — via <a href="https://www.craiyon.com/">craiyon.com</a></figcaption></figure><h3>Visitors et al.</h3><p>Another criticism I’ve seen over the years is essentially that OO fails because objects cannot know about all the other kinds of objects in the program and therefore they cannot properly handle all the cases that arise when interacting with other objects. This leads to (in my opinion) weird design patterns such as ‘Visitor’. There’s something to this argument but I consider this whole line of thinking to be a flawed and not an issue with OO itself.</p><p>Instead of an example with elves or dogs or whatever, I’ll use a quintessential Java type: the Set. A set, just as in the mathematical sense, is like a list except that it doesn’t allow duplicates and (in general) doesn’t maintain any ordering. That first constraint is the key here that leads to the question: when are two objects duplicates? The answer seems to have an obvious answer to most OO developers: use the ‘equals’ method to compare the objects, and that’s what Set classes typically do in Java, for example. There’s a problem with this and decades ago, after many hours of trying to make it work, I saw the issue.</p><p>Consider the hypothetical situation of where you have a class ‘Circle’ and a ‘ColorCircle’. All ‘ColorCircles’ are ‘Circles’. The specific requirement at hand is that two ‘Circle’ objects are ‘equal’ if they are the same size and two ‘ColorCircles’ are ‘equal’ if their size <em>and</em> their color are the same.</p><p>Now, are a ‘Circle’ and a ‘ColorCircle’ with the same radius ‘the same’?According to ‘Circle’, the answer is “yes”. According to ColorCircle the answer is “no”. Who is right? Well, that depends on what you want in your set. You might want both in there. You might not. You might even want all kinds of objects to go in the set regardless of their properties. All of these scenarios might be needed in the same application. Isn’t this proof that OO doesn’t work? Not really. It’s proof that rigidly adhering to a misguided orthodoxy is self-defeating.</p><p>The fundamental error being made here is ignoring that the Set is also an object and the decision whether two specific objects are allowed to both be in a set should be a behavior of the Set, not the objects going into it. Just as passengers on a bus don’t determine its route, the objects in a set should not determine how it behaves. The idea that the Circle types should even care about Sets or know anything about them and how they behave is completely confused. It’s conceptually similar to letting one of the contenders in a boxing match decide who won. This seemingly intractable issue and the convoluted solutions that people come up with to ‘solve’ it vanish once you let go of the confused idea that the contents of the collection are responsible for evaluating other members of that collection.</p><p>As evidence of this, consider the standard Java interface ‘Comparator’ (i.e.: a separate object passed into an ‘OrderedSet’ whose job is to compare two objects and determine order and equality) is used and accepted. Want the items ordered in reverse? There’s a built-in Comparator for that. Want strings that are valid numbers to come first and be ordered like numbers? Easily done with a custom Comparator (it might already exist in some open-source project.) But for some reason applying the same exact approach to equality in simple unordered sets is treated as some sort of heresy. It’s this line of thought that leads to convoluted solutions such as the dreaded ‘<a href="https://en.wikipedia.org/wiki/Visitor_pattern">Visitor</a>’ pattern: there’s nothing about OO that precludes additional objects or routines to intermediate interactions between two (or more) objects. If you find yourself creating complex approaches to allow an object to determine how something else should evaluate it, you should probably step back and consider whether you need an additional perspective in the solution.</p><p>This kind of thinking is a problem for OO practitioners. But it’s not because OO is inherently flawed, it’s simply a flawed idea derived from misconceptions about OO that happen to be very common: that objects must be in control of everything that happens with them or it’s not OO.</p><h3>Conclusion</h3><p>OO is not as bad (or good) as many people present it to be. When you really boil it down, the key aspects of it are abstraction and polymorphism. It’s essentially a way to organize programs such that the code and the data that code acts upon are kept together and simplifies passing groups of function references as a unit. That’s really the whole thing. It’s a one-trick pony but it’s a pretty good trick i.e.: you can build very robust and performant software in this way without ever using any functional features.</p><p>Not using functional approaches, however, is <strong>NOT</strong> a valid goal. In fact, I think it’s a completely stupid idea and always has been. Luckily it seems that OO language designers have largely accepted that functional techniques should be supported. I know that the FP zealots will say that the functional features introduced in mainstream OO languages are a pale reflection of what is possible. I can accept that, but they seem to be missing that the conversation has shifted. Software engineers need to stop ‘rooting for the home team’ and move past this schism. I haven’t seen any evidence that OO and FP are fundamentally incompatible. Even if all the FP advocates convinced all developers that OO was a terrible idea, we would still need to deal with the immense amount of OO (or pseudo-OO) code that exists. It absolutely dwarfs the amount of FP-based software in existence. In my opinion, FP advocates should continue to infiltrate OO languages, not try to convince people to defect.</p><p>On the other hand, we probably don’t need new OO languages. New languages should not include problematic features. It’s silly, for example, to have mutability be the default and then have to manually make almost everything immutable. (Kudos to <a href="https://en.wikipedia.org/wiki/Rust_(programming_language)">Graydon Hoare</a> on that one.) But with regard to existing OO languages, we need to stop teaching people these dumb ideas. In particular, developers need to learn from day one that inheritance of implementation is largely a terrible way to (attempt to) reuse code.</p><p>If you’ve made it this far, thanks for reading my first article on Medium. As my parting words I want reiterate that, in my opinion, much of the code in a typical OO application would be better done with functional approaches and all OO developers should learn and embrace these techniques. However, that doesn’t mean properly designed OO doesn’t have a place, it just shouldn’t be the first tool you reach for.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a664cef00b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>