iOS (Swift) – Binary Solution


In the past few months, I had the opportunity to help a seasoned, senior engineer on my team at work solve a unique problem. He was given a hexadecimal string that represented some data to determine whether employees would be enrolled on certain devices for time keeping or not. He knew what needed to be solved but couldn’t solve it. During the President’s day weekend, I decided to tackle the problem in C++, then later solved it in Java, then Swift. I presented him this type of code below to help him with his solution –

He still struggled even though I gave him the pattern. I don’t blame him completely because he was under time pressure and had the desires to create a solid, valuable solution. I worked with another engineer to put this solution into a PL/SQL function which he could call for his solution. It was sad to see how his original solution, even though it worked, was not very scalable and was very costly. He basically put together 40 – 80 lines of code that did string/character comparisons to determine which groups a binary value belonged to.
I am grateful for the knowledge and experience of binary operators such as the binary AND (&) operator to making this solution very solvable, easier to handle, perform faster, but importantly be scalable. This is knowledge and experience that I treasure because it was something well thought-through and has longer-lasting value than to hard-code string comparisons.