View Single Post
Old 08-06-2021, 01:44 PM
gregg gregg is offline
Registered User
Join Date: Oct 2010
Posts: 75
The limiting speed factor here is the communication channel to the remote device. The difference between a switch/case and if/else will be greatly overshadowed by the communication.

A switch/case of a boolean value would only ever have 2 possible cases. And in the case of this code, the options are "continue working" or "error, get out of here", except for your switch/case "get out of here," the reader has to parse the entire sub all the way to the bottom to see that this is what is happening.

Unless absolutely critical, I lean towards code readability/maintainability over execution speed. Especially for things that just run once or minimal times. If you start looping over a piece of code 100 thousand times, then we can talk about optimization.

Indents are important, but being nested so many levels deep hinders readability "where's the end of this thing, oh wayyyy down here."

These observations are of course personal preference from years of experience. Though, there are tons of books and talks on the subject.
Reply With Quote