← Back to context

Comment by Aaargh20318

6 hours ago

I’m missing Curly’s Law: https://blog.codinghorror.com/curlys-law-do-one-thing/

“A variable should mean one thing, and one thing only. It should not mean one thing in one circumstance, and carry a different value from a different domain some other time. It should not mean two things at once. It must not be both a floor polish and a dessert topping. It should mean One Thing, and should mean it all of the time.”

> It must not be both a floor polish and a dessert topping.

I worked as a janitor for four years near a restaurant, so I know a little bit about floor polishing and dessert toppings. This law might be a little less universal than you think. There are plenty of people who would happily try out floor polish as a dessert topping if they're told it'll get them high.

  • Borax is an example of a substance that is simultaneously used for skin care, household cleaning, as soldiering flux, and ant killer. But I guess it is a constant with variable effects. Hard to be found in local shops anymore.

    • Really? It's at practically every hardware store I've been to (US, things may be different elsewhere).

  • It’s a reference to a very old SNL sketch called “shimmer”. https://www.youtube.com/shorts/03lLPUYkpYM

    It probably won’t be up very long but it’s a classic.

  • I worked for awhile as a janitor in a college dorm. Not an easy job but it definitely revealed a side of humanity I might not have otherwise seen. Especially the clean out after students left for the year.

    • > it definitely revealed a side of humanity I might not have otherwise seen

      It definitely revealed a lot of falsehoods and stereotypes.

    • We had a large green plant growing in an unused fridge. Fungus yes, but this was a new experience. As students we learned a lot.

  • I thought that you were about to write: "as a janitor in a restaurant, the dessert topping is sometimes used as a floor polish".

    • Something as expensive as dessert toppings would only be used as floor polish by the people who truly were high... and only if they could do it without the boss knowing what they were doing.

  • floor polish as a dessert topping if they're told it'll get them high.

    I think that would be called a drug, not a desert topping.

Oh! I didn’t have a name for this one, but it’s a lesson I’ve learned. E.g. if variable x is non-zero, then variable y will be set to zero. Don’t check variable y to find out whether x is zero. And definitely don’t repurpose y for some other function in cases where it’s otherwise unused.

  • For modern day web developers there are very, very, very few things that fall into the "if you do this you should probably be escorted out of the building on the first offense" category, but "reusing a variable because it's 'not being used'" might be on that list. I can maybe see the argument in very low memory embedded systems or similar systems where I'm not even qualified to come up with examples but not in anything that regularly shows up on HN for example.

Shellac is both a floor polish and a food additive, particularly in candy.

Used to be, anyway. Modern alternatives are much better. It's still used as glue in wind instruments though.