Category: Apple Core Labs

Passion Project: Mixing C++, Objective-C++, and Swift

I know a lot of folks have had to go through the process of bridging to C++ so you can use it from Objective-C or Swift. In my case I’m using it from Swift, so I thought I’d share what the middle Objective-C++ layer looks like. If you’ve done any Objective-C it will look like straight Objective-C, until you look a little closer. That’s when you’ll notice a C++ namespace, new, and delete statement. This code is a straight passthrough to the underlying C++ code — it’s here so Swift code can communicate with the C++ code.

Here’s the code that bridges to our Creatinine Clearance calculation.

You’ll notice a class called PKMConvert that has a class method called genderFromPKMGender. I created a set of mirror enums. One on the iOS side the enums use NS_ENUM syntax, on the C++ side they’re straight C style enums, so this code converts between the two. It’s just a simple mapping.

Another thing you’ll notice is I’m still using “old” C++ syntax to create and destroy objects. I’ve been thinking about updating the syntax to C++11 so I’d use unique_ptr instead. We’ll see if that happens. It’s not a big deal.

Something I’ve been mulling over is releasing the entire PKMath C++ Library as an open source project once I have it working for iOS/Mac, Android, and Windows. I don’t know that it would be overly useful for anyone, but there you go.

Since I haven’t actually written any Swift code in the new RxCalc to use the Objective-C++ code I thought I’d share one of my unit tests for the Creatinine Clearance example above.

Here’s how the different layers look from 30,000 feet. I like pictures, don’t you?rxcalc2layers

Passion Project: Update One

I’ve made a couple runs at the freelance iOS developer life. The first time things went really well, but I was offered a gig by one of my clients and it too good to pass up. A couple years into that position — leading a team developing a Windows video decoding SDK — I got the itch to go back to iOS and the Mac. Around the same time our oldest daughter decided she wanted to move back to California. I took a week off to help move here, and think on this idea of going back out on my own. I decided to give it a go. This time around I failed, miserably.

My attempts to go indie have always been predicated by a desire to develop a product. I thought I could bootstrap my indie life doing freelance work. This was definitely a mistake. Once you start doing client work you’re on that hamster wheel of how do I get my next client? Drumming up work is difficult. I failed at that and I’m also a slow developer. I don’t crank out code quickly, which you need to be an effective freelancer. Get it done so you can move on to the next deal.

When I finally found a full time job I decided I’d work on passion projects and see how that worked out. I’ve had many starts and stops on various projects, but I keep coming back to RxCalc. It was my first iOS app. My brother, Jerry, and I worked on it together. Jerry is a clinical Pharmacist and wanted an iOS app to help him do Pharmacokinetics Calculations. He did all the math and designed the workflow and I turned both into Objective-C. We shipped in June 2009 and RxCalc went live in the store July 4, 2009 (nice bonus.)

I’ve been slowly working on a rewrite of RxCalc. My first iOS app was messy, but it has proven stable — I haven’t had a crash report since the 1.0 release in 2009 — but the code is cringeworthy. I’ve cleaned it a bit over the years as well as shipping a 1.2 release that included some new functionality. That release included much cleaner code, but I’ve wanted to add IAP to it for additional calculation models and port it to Android, and maybe even a Universal Windows App.

When Jerry and I originally started developing what was to become RxCalc it began life as a Palm app in C++ and the Pharmacokinetics math library was portable C++. It built on Palm, Windows, and iOS — it built first time on iOS with zero change. When I was learning Objective-C I decided it would be best to port PKMath from C++ to Objective-C. That was really easy. It didn’t take long at all.

Here we are in 2016 and I decided I’d better get started with my grand plan to make PKMath portable, again, and build for iOS, Android, and Windows. Why? Just because. Remember, this is a passion project. I don’t make any money on RxCalc, but I do have a plan to change that with this new version.

Will write C/C++ for foodThe new C++ PKMath library is written. I’ve built a small layer of Objective-C++ over the top of it so I can write the new UI in Swift. The old RxCalc was 100% Objective-C, the new one will be a mix of C++, Objective-C++, and Swift. That sounds kind of weird, but there is a means to an end.

Android is my next target. I’ve started working on JNI wrappers around the PKMath library. This has proven to be extremely difficult. It’s going to take some time to wrap my brain around how this all works. I’ve managed to write a simple sample that uses PKMath to calculate an Ideal Body Weight and display it in an Android view, but that’s as far as I’ve gotten.

As for Windows it’s the thing I’m most familiar with. I’ve spent most of my 25+ years as a developer building Windows applications. The downside is I’ve never built a Universal Windows App and I’m not sure how to properly build PKMath for it. I’ll figure that one out and I imagine it will be as easy as wrapping C++ in Objective-C++.

Progress is slow and I’m easily distracted. We’ll see how it goes. More updates to come.

P.S. — I find Swift to be the most enjoyable language I’ve ever used. Doing the new RxCalc UI has been a lot of fun.

Into the Fray

I Have Failed

Will code for...Back in June I decided I’d jump back out into the Freelance iOS world and make a go of it. I had a couple contracts lined up so it seemed like a good time to make another run at it. Boy, was I wrong. About that time a number of well known Indie software developers were writing about their experiences in the App Store. The market for Indie work has kind of collapsed and I can tell you the Freelance market has bottomed out in many ways. It’s difficult to get folks to understand a mobile application is a real application. I hope someone is studying the psychology surrounding this phenomenon. I know every freelance developer has experienced this in their field. You give an honest estimation of time and an associated dollar value, and you never hear from them again. I hear fellow developers saying “Yep, been there, done that.” It’s just how things work.

Some of the contract work I’ve taken over the past couple of months are jobs I should not have taken. The pay was substantially less than it should have been and at least one of the applications was so substantial in size I really should have walked away, but I didn’t. That’s a big mistake on my part, something I regret, and a mistake I cannot make again. I took the work because I needed it. It’s a horrible position to negotiate from. You have zero power.

I also had a contract that went about as sideways as one could go. That is a cautionary tale and one I hope to tell someday, but not now.

All of this is, of course, a self made disaster. I chose to take the work, it’s something I’ll have to struggle out of, in the meantime I’m back out on the market, looking for a full-time gig.

What Do I Offer?

I’m a seasoned developer. You can call me old, that’s fine, I am not a 20-something. I have a wealth of experience shipping software. I’ve lead teams of developers and I’ve been an individual contributor. I know how to ship software. I’ve been there many times.

Most of my experience lies on the client side of the world. Windows desktop and iOS primarily. I’ve written code in C, C++, Objective-C, and C#. I have had a couple of stints writing software that ran on the server; Paramount Farms and LEVEL Studios come to mind. Both times the server side code was developed using a full Microsoft stack; C#, .Net, and SQL Server.

I believe connected services are the obvious thing to be doing. Along those lines I have experience developing and consuming services. REST and JSON based services are where it’s at today, but I’ve also consumed SOAP/XML based services. It’s all data, but I really do like the simplicity of REST/JSON.

I still like writing software but I’d also be more than happy to take on a Development Lead or Program Manager role. My last full-time position, with Pelco, was leading a team of 8-12 folks (it fluctuated in size and I’m counting contracted developers) developing a C++ and C# SDK for use with the Pelco VMS and I really loved what I was doing. I didn’t leave because I was unhappy, I left because iOS was calling me.

I’d love to continue working on iOS Applications, if possible, but I’d be equally happy working on desktop or server side software. I will warn folks up front. My SQL skills are pretty crude, but doing application logic and user interface isn’t a problem and is something I quite enjoy.

Career Highlights

I’m not much of a salesman. I don’t interview well (Whiteboard code? Instant fail, test anxiety.) I say this because I’ve had some of these moments recently. That’s the bad side of me.

I thought I’d share some things I have done and are in use by millions of people worldwide.

  1. Visio – I worked on Visio for over 10-years. QA, Setup Developer, Developer Support, and Visio Engine Development. When I left in 2003 Visio was used by over 9-million people worldwide.
  2. Pelco Endura – I worked on the Pelco line of Decoders for five years. This included the Workstation, VCD, and our shared pipeline component framework; MPF (Media Processing Framework.)
  3. Pelco SDK – I worked with a talented group of folks to create a reimagined SDK. We were able to design a new object-oriented C++ and C# SDK. I love creating code for others to use.
  4. LEVEL Studios – While at level I contributed to web services used by a large Android handset manufacturer. At the time the project was handed off our client it was supporting over 8-million people worldwide.
  5. Freelance – While freelancing I helped with a few applications, some are no longer in the store, and I have created a couple apps of my own (both in desperate need of a facelift, I know.)

If I were to sum up what I can offer I’d say this. I know how to ship software, how to make those tough decisions, and I can see the big picture. I know, and understand, that business needs play a big role in product development. I can lead or follow.

The Pain of Change

Apple Core Labs LogoA few weeks back I decided it was time to update the Apple Core Labs website. Since I’m now making my living doing Freelance Development I figured it would make sense to have a portfolio look. This would allow me to show, and talk about, some of the applications I’ve contributed to.

Finding a Theme

Since I’m a fan of WordPress it made sense to find a provider of professional quality WordPress themes and buy one. I’m not a web layout professional and my HTML and CSS knowledge is minimal. In the past I would’ve tweaked and poked at the page until I was happy enough with the outcome and leave it at that. Witness the current Apple Core Labs page. It’s minimal at best, which isn’t a bad thing, but now I’d like a bit more.

During my search I considered quite a few Professional WordPress Theme shops but decided I’d go with The Theme Foundry. Why? I love their style. Their themes have an ascetic that’s pleasing to my eye and they’re very functional and professional looking.

In the end I chose the React theme. When I viewed the live demo I knew it was the them for me.

Updating

Now comes the hard part. I have to set aside time to install WordPress as my main site on Apple Core Labs and make sure I maintain all the static pages that are important to me, like RxCalc. That’s where it gets tricky, I think.

Creating pages that display on the home page will be the easy part. The Theme Foundry did a great job making that a no brainer. The thing I’m having trouble with is how do I feature a link to a random static HTML page on the home page without tweaking the template and messing up their fantastic scheme? The page I’m talking about is the beautiful RxCalc page, designed by my friends at Hundred10 Design. It’s a masterpiece and I’d like to keep it, but I’d like to give it a space on the home page, which means doing something special to the WordPress theme. At least I think that’s what I have to do?

What about my weblog?

The Apple Core Labs Weblog is WordPress based, but lives on a sub-domain. It’s easy enough to adapt that to use React. Thank goodness. At least that’s an easy change.

End of Line

Overall I’m really excite about the new look for the site and The Theme Foundry is a real class act. They’ve already been a great help. If you’re looking for a professionally built WordPress Theme I strongly recommend you visit The Theme Foundry.

If there are any React theme, or WordPress, experts out there and you read this, could you lend a fella some advice? How do I feature my static RxCalc page on the main React landing page? Is it possible without changing the template? If you have a suggestion leave a comment or send an email to rob.fahrni@gmail.com. Thank you.

Diving into the deep end

Anyone that knows me, knows I love movies. I love to watch them, talk about them, I even quote movies. What in the world do the movies have to do with this post? I’m glad you asked.

In the movie The Sandlot there’s a young man in love with the beautiful older woman. His name is Michael “Squints” Palledorous, her name is Wendy Peppercorn. To make a long story short, one day while swimming with his buddies at the local public pool, Squints, reaches the point where he can no longer stand watching Wendy, a lifeguard, from afar. He decides to take a drastic approach to get Wendy to notice her. He jumps in the deep end of the pool, sinks to the bottom, and waits for Wendy to rescue him. She does.

“Michael Squints Palledorous walked a little taller that day. And we had to tip our hats to him. He was lucky she hadn’t beat the *crap* out of him. We wouldn’t have blamed her. What he’d done was sneaky, rotten, and low… and cool. Not another one among us would have ever in a million years even for a million dollars have the guts to put the move on the lifeguard. He did. He had kissed a woman. And he had kissed her long and good. We got banned from the pool forever that day. But every time we walked by after that, the lifeguard looked down from her tower, right over at Squints, and smiled.”

Squints and Wendy go on to marry and live happily ever after.

Get on with it man!

All that backstory, for what? Three years ago I formed Apple Core Labs to go indie. At the last minute I got cold feet and decided I’d do it on the side. In July of that year my brother, Jay, and I released RxCalc. Later I worked with my friends at Hundred10 to deliver the Fresno Grizzlies app and more recently I’ve done some work for a company in Washington state to help them create their first iOS application.

What I’m trying to say is, I’ve loved every minute of it. The thought of going indie has been my Wendy Peppercorn. After three years, I’ve finally decided it’s time to leap into the deep end of the pool.

Beginning May 1, Apple Core Labs will be my full time job.

If you need an iOS developer, get in touch, we’re open for business.

Esoteric iOS

Apple Core Labs: “Since we have to integrate with multiple scanners we have to decide at runtime which scanner is being used. Using the SDK’s we could take a stab in the dark at initializing each one in turn and the one that succeeds to initialize is the winner. Not such a great way determine the one to use, but it would work.

What if there was a way to determine you had connected external devices without using a third party SDK? There is.”

I’m not sure many people know about the External Accessory Framework. If you’re working with third party devices that work with iOS give the piece a read.

How can I connect?

Apple Core Labs: “My frustration with the disconnect between us and our customers on the App Store continues to grow. For RxCalc we typically see ratings that have to do more with lack of features, or new features, than the features we actually have. Don’t get me wrong, that’s great! The problem is we have NO way of communicating with these users to find out what they really want. We can make an educated guess and hope we’re correct, but that’s the best we can do.”

I posted this back in early February. If there are any iPhone development shops out there that have resolved this problem I’d love to hear from you.

Oh, and if you’re a Pharmacist using RxCalc we’d appreciate your feedback here and at the App Store.

Thanks.

Now, we wait

RxCalc 1.2 IconI’ve been sitting on a new release of RxCalc for a while now. Jerry and I took a look at the code about a month ago and fixed up a couple of minor issues. For the first time we opened the door to beta testing. RxCalc is small but it’s getting to the point that it’s nice to have more eyes on it. We were able to enlist a great Pharmacist by the name of Robert Martin to help us verify our numbers were correct. Between Robert and Jerry we have over 30-years of heavy Pharmacokinetics experience. We’re very thankful to have Robert’s experience. He definitely helped make RxCalc 1.2 the best release ever.

Now we wait

The binary was submitted today, October, 3, 2010 at 4:35PM. Now, we wait.

Wanted: Beta Testers

Apple Core Labs LogoApple Core Labs: “We’re working on the next release of RxCalc and would like to open it up to some beta testers!”

If you’re a Pharmacist and are using RxCalc, or would like to test a Pharmacokinetics calculator for the iPhone, head on over and sign up!

© 2017 Rob Fahrni

Theme by Anders NorenUp ↑