• 0 Posts
  • 236 Comments
Joined 2 years ago
cake
Cake day: July 3rd, 2023

help-circle





  • Code readability is important, but in this case I find it less readable. In every language I’ve studied, it’s always taught to imply the previous condition, and often times I hear or read that explicitly stated. When someone writes code that does things differently than the expectation, it can make it more confusing to read. It took me longer to interpret what was happening because what is written breaks from the norm.

    Past readability, this code is now more difficult to maintain. If you want to change one of the age ranges, the code has to be updated in two places rather than one. The changes aren’t difficult, but it would be easy to miss since this isn’t how elif should be written.

    Lastly, this block of code is now half as efficient. It takes twice as many compares to evaluate the condition. This isn’t a complicated block of code, so it’s negligible, but if this same practice were used in something like a game engine where that block loops continuously, the small inefficiencies can compound.





  • Apart from the bias, that’s just bad code. Since else if executes in order and only continues if the previous block is false, the double compare on ages is unnecessary. If age <= 18 is false, then the next line can just be, elif age <= 30. No need to check if it’s also higher than 18.

    This is first semester of coding and any junior dev worth a damn would write this better.

    But also, it’s racist, which is more important, but I can’t pass up an opportunity to highlight how shitty AI is.



  • Unrelated to this OG topic, but I was going on a snowboarding trip a few years ago and got a rental car via Turo, which is basically air bnb for vehicles. I met the owner at the airport and I took off after everything was loaded. 30 some minutes late I get to resort, turn off the vehicle and start getting dressed to hit the slopes. I realized I didn’t have the key, so we called the guy and he still had it. Since the vehicle was running, we were able to leave with no issue. He met us at the mountain to drop off the key.

    I had a similar experience another time on a snowboard trip, where I went down to the vehicle in the morning to warm it up and scrape the windows. I went back in inside grabbed my stuff and stopped at the gas station about a mile down the road. I noticed a light that said no key fob on the dash and thankfully without turning the car off, went back to the hotel and found it in the room. That one would have been tough because I went another hour out and didn’t have someone to call since it was a rental.

    I guess my point is, you shouldn’t be allowed to put a car in drive or reverse if the key fob isn’t detected.