• 0 Posts
  • 144 Comments
Joined 1 year ago
cake
Cake day: June 21st, 2023

help-circle
  • Write comments that explain why the code isn’t obvious just by reading it. Why did you do things the long way? What did you need to work around? Why didn’t you do the thing that anyone reading the code would expect you to do?

    Also write comments that explain the purpose of the functions you use, in case the names of those functions don’t make it clear on their own.



  • The fact that the loop is doing “find first driver matching these strange criteria” seems most obviously obscured by the pattern of assigning a value, then killing the loop or not. This strikes me as the part that makes the algorithm tedious to test, since it forces us to use a collection to test the intricacies of the inner conditions.

    Once we isolate “find first driver matching condition” from computing the condition for each driver, I consider the rest a question of personal taste. Specification pattern, composition of filters, something like that. Whatever you find easier to follow.


  • I understand it to mean what’s called a “deduction”. This is an amount that you are allowed to claim that reduces your taxable income, which reduces the tax you pay. “Writing it off” means claiming the deduction.

    Generally speaking, to be a valid deduction, an expense must be necessary and ordinary to running your business. In practice, a valid deduction is whatever your tax authority decides is allowable.

    I am answering from the point of view of the Canadian income tax system, but what I describe here is pretty common throughout the world.




  • The mode can’t hope to answer how much money the average person has, because there are far too many possible values.

    The mean answers how much money people have on average, but the outliers exert too much influence to answer how much money the average person has.

    The median moderates the influence of both the very rich and the very poor, so it better approximates the amount of money that those in the middle of the population have, which is what 'the average person" tends to be.

    For populations where the number of possible values is much lower, the mode and the median tend to be closer to together. Emphasis on “tend”.




  • Mode is a kind of average. I infer that you mean “mean” when you say “average” here.

    The mean takes into account outliers in a way that the mode doesn’t.

    The joke about the average number of legs among humans being less than 2 describes a situation where mode provides more meaning than mean. In the case of scattered values, mode makes less sense, such as the average net worth of the people in a country.

    I don’t know why the mean is the “default” average. In many situations, the mode or median makes more sense.





  • People will probably keep asking until they learn that you don’t want to answer. This is just how most people work and I understand your frustration at being an outlier in this way.

    You can’t control them feeling offended. You are behaving strangely to them and they’re struggling to make sense of you. The most reasonable explanation to them is that you dislike them, which they’ll construe as rude.

    If you are direct with them, they might at least be able to make sense of you. “When I’m at work, I only want to work, then get out of here as soon as I can. That’s why I don’t socialize here. It’s nothing personal.”

    Either they believe you or they don’t. You can’t make them believe you.

    One last thing: just like you wish they’d stop making wrong assumptions about your motivations, you might consider challenging the assumptions you’re making about them.

    Good luck.




  • I don’t think of it as developing a thicker skin, but after some weeks of practising metta meditation, I noticed that I found it easier not to take personally the actions of others. This is also known as loving-kindness meditation. It sounds very strange and yet it seems to help.

    I used to think similarly and wonder how not to let these things bother me. Then that changed to letting them bother me, but for shorter periods of time. Now I tend to think of it as letting them bother me, but then not feeling bad about letting them bother me, which allows me to let go of those feelings sooner.

    It’s not a quick fix, but it might help you very much over the rest of your life. Even basic mindfulness meditation, such as breath meditation, might suffice to start.

    Good luck.


  • “B if and only if A” is a shorthand way to write “B if A and B only if A”. It’s like how “He is young and thin” means “He is young and he is thin”. We could write it the second way without trouble, but the first way is shorter, we agree that they mean the same thing, and we prefer to conserve energy when writing.

    The form “if and only if” is merely a convenient shorthand. Shorthand is usually more convenient for the writer than for the reader. 🤷‍♂️

    Imagine these natural language sentences and analyze how they are different:

    • I’ll go outside if it’s not snowing
    • I’ll go outside only if it’s not snowing

    Hint: what do you do in each case when it’s snowing?