Less branching → Better code

Interesting confirmation of a gut feeling I’ve had for a while. With UIKit on iOS, I see a lot of developers write code that updates bits of the user interface as inputs change. As the code grows, the execution path becomes a convoluted flow chart of branches and conditional updates. Secondary dependencies often get lost, giving rise to bugs that can take hours to track down. And then you’re not really sure that you didn’t break something else with the “fix”.

But you can ditch all this complexity by just updating the whole interface every time. When the view opens, update the interface. When the user checks the box, update the interface. When the network query returns data, update the interface. Now you’ve got a simple linear method that does all the work which is both less likely to have logical errors and easier to reason about if any errors do occur. Through no coincidence, this is also how SwiftUI works.

I’ve written more tests than just about… | justin․searls․co:

... the single most important thing programmers can do to improve their code is to minimize branching (e.g. if statements)...

I’m shopping for an office desk and thought I’d check staples.com. Open up the app and it demands I download their new app. Okay whatever. New app is literally just a web view for staples.com, complete with the app banner to open the app. That I’m already in. LOL.

Last week’s Google: how to add git submodule

This week’s Google: how to remove git submodule

And the circle of life continues…

I’m working on breaking components out of my Swift project into local SPM packages. I’m really starting to like the architecture. But I’m having trouble with testing. I’d like to ⌘-T in Xcode and run both the app unit tests and the SPM tests, but I can’t make it work. All the posts online redirect back to this answer: developer.apple.com/forums/th… But when I try to follow along, the SPM test targets just aren’t in the list. Anyone have a clue?

In general, I’m skeptical about AI code generation, especially in the hands of inexperienced engineers who think it’s smarter than they are. But when you need it to do a menial thing? Fantastic! For a Swift project, I needed a bunch of constants that I found on GitHub in a Python file. I pointed ChatGPT at the URL and asked it to generate the corresponding Swift enum, but change the keys from snake case to camel case. And… it just did it! I think it might even be right.

TIL - the term ‘split horizon’ DNS. It’s a thing I’ve been doing for 20+ years to manage internal vs external DNS. I always called it ‘DNS jiggery pokery’, but I guess this is better.

en.wikipedia.org/wiki/Spli…

I’m 5+ years late to this party, but I finally started playing Breath of the Wild back in the fall. Videos always made the combat seem complicated, but it really isn’t. The complexity the world is amazing. I watched a cut scene where Zelda stood up and dusted the dirt off her pants. My brain is still trying to reconcile that level of detail with 8-bit blob at the end of the NES edition.

I’ve loved this game so much I hate to actually finish it. But it’s such a big thing, I don’t want to start Tears of the Kingdom right away. But I’ve still got a couple of shrines to find. And I’ve never been in battle on a horse.

Made a lot of progress yesterday with reverse engineering the messaging protocol for a USB powered light. Turns out Wireshark is not just for network snooping!

Today’s adventure – USB packet sniffing. Gonna throw the engineering contraption in reverse! 🤞

So if you’re wearing a Vision Pro and you see someone else wearing a Vision Pro, you just see the headset, right? Somebody at Apple is furiously working on recognizing other headsets and replacing them with Personas.

Leaked image of Apple’s forthcoming “Extended Battery” for the Vision Pro.

Four men with unlicensed nuclear accelerators strapped to their backs.

Our first Mac was a purple gumdrop G3 iMac DV with MacOS 9. We were in grad school at the time and my wife used it to write her thesis in Word. The iMac was a fantastic little machine, but Word would occasionally center her entire document so there was cursing and crying. I don’t think we ever had anything fancy enough to plug into those FireWire ports. #MyFirstMac

It’s the kind of day where you have to disable System Integrity Protection. I’m sure this’ll all turn out fine.

Merry #BunnyButtFriday to all who celebrate!

A brown and black bunny sits loafed up in front of a Christamas tree with her fluffy tail towards the viewer.

Somebody nicked our credit card number and Bank of America sent new cards. Cool. Then I have to manually update Apple Wallet on like 6 different devices… not as cool.

(HBO) Max app: If you liked “Julia”, you may also like “Rap Sh!t”!

Me: Sure sure sure.

TIL: AVCaptureDevice documentation says the ‘uniqueID’ is ‘a unique identifier that persists on one system across device connections and disconnections, application restarts, and reboots of the system itself’. Unless you plug that webcam into a different USB port. Then the Mac is all ‘Woah! WTF is this thing?!’

Because the good hay is on the bottom. Apparently. #RabbitsOfMastodon

A German Lop rabbit completely covered in hay as she digs for the best piece at the bottom of the pile.

I have a project that failed to build under Xcode 15. It links a 3rd party framework written in C++ but the link step fails with unresolved symbols. This classic mode flag for the linker fixed it right up.

mastodon.social/@jamestho…

Just working on some recreational Ansible. As you do.

Wait, Star Trek: Strange New Worlds s2e10 is the end of the season?

Oh no.

Python in Excel! But you have to write your python in the little Excel formula box? Like getting a Ferrari but having to drive it with an app on your phone.

techcommunity.microsoft.com/t5/excel-…

It’d be cool if the Apple Card (like the physical card) worked with Find My, so my wallet doesn’t have to have a dog tag.

That thing where the list of states on a web form is alphabetized by state name, but display text is the two letter abbreviation… so the list goes NV, NE, NH, NJ, NM, NY, NC, ND. Who looks at that and is like, yeah, we got it!

Am I reading this right?

techcrunch.com/2023/08/1…

Disney+ and Hulu are getting big price increases, $3 a month for both services on the ad-free tier. So if you subscribe to both, it currently costs $26 and that’s getting bumped to $32. BUT they’re adding a bundle of ad-free Hulu and Disney+ for $20. So if you subscribe to both (like me!), this is actually going to save $6?