The Only Lars

Byte-sized adventures in software engineering

Swift’s Yolo Operator

I bought the domain and launched swiftyolo.com sort of as a joke maybe 6 months ago, but I still think it’s both funny and informative. It started as an office joke by me among the developers I worked with at Mutual Mobile, but it was really natural for people to reference the force-unwrapping pattern as a social anti-pattern. Half of me still thinks the name is stupid, but if it gets people to understand optionals and force-unwrapping, I’m all for perpetuating it. I was really just trying to drive home a “best-practice” (really just a practice) use of optionals and show how abused force-unwrapping had become.

As one of my co-workers, Eric Miller (@Xephos13), said: “It took all of like 9 seconds for most [everyone at work] to start saying it too”.

It’s like an infomercial for what I have seen in my past couple of years working with Swift (just picture half of the site in your head in black and white while reading it). Most people see optionals as a barrier to development, but once you truly think of them as an integral part of your development and architecture, you will write the safest code you’ve ever written. Just remember, this is just one guy’s opinion. Let me know what you think.

Please. Think of the kittens. Practice safe yolo.

Microsoft HoloLens and Your Everyday Future

Having not posted on here in over a year, it feels good to write again.

Yesterday, Microsoft announced and demoed a surprising, radical new project called HoloLens. If you haven’t seen it yet, please go the Microsoft site and glance at it to make the rest of this make sense. The essence behind HoloLens is a goggle-like device you wear over your eyes that projects holograms augmented into your perception of reality – wirelessly. Technology like this is significant for a few reasons that may not be immedately apparent when looking at the demos they have provided. This technology today, itself may look a little socially isolating, may just be a necessary stepping stone to what we will soon know as the ‘present’ of computing.

As much as it surprises me to say this to myself about Microsoft, but it’s a little refreshing to see Microsoft show off this kind of technology and not Google.

Close Your Eyes

Close your eyes. Now imagine what the future looks like to you. You may be picturing your favorite science-fiction movie like Minority Report or Blade Runner. Usually there are screens everywhere. Computing is so cheap we can make displays out of and integrate them into almost anything – giant displays on the side of a building, displays integrated into walls, clothing, or other materials.

Maybe this is the case. But what if the future of this functional reality is just a little bit closer than that?

Rapid Content Prototyping With PlaceKit

Last week I open-sourced MMProgressHUD, a small work-project that I’ve been working on for what seems like an eternity. I alluded in my last post that I was also releasing a personal project later in the week. I went ahead and open-sourced that project which I’ve been calling “PlaceKit” for the Objective-C “Back On the Map” hackathon this past Saturday.

What is PlaceKit?

Think of PlaceKit as a central, lightweight, dependency-less library for all of your content, placeholder, test data and random numerical needs that you might run into during prototyping or in the early phases of production development.

Let’s go through a couple of scenarios that you might find yourself needing PlaceKit:

  1. You want to try something out fast, but need some content to show how it might look with real text or images
  2. You want to create a demo application for some particular widget you are working on, and need a set of fake data to display. Ditto for needing randomized data and geometry for creating random views or random offsets.
  3. You are working on a production app, but the server API is not ready yet, so you now have to come up with a large dataset of fake data to populate a fake database that you can use in your application until it is ready.

These are the primary scenarios I built PlaceKit to make easier. We all know about using lorem ipsum, but when we need it, we typically will open up our favorite browser, google “lorem ipsum generator” and then copy/paste the text into the appropriate place we would like it to show up. This is all well and great, but it really isn’t scalable, isn’t randomized and also won’t simulate fetching from the network. This scenario is also true for images.

MMProgressHUD

This morning I open-sourced a fun side-project I’ve been working on for the past (almost) two years - MMProgressHUD. “Wow, that looks a lot like MBProgressHUD!” Yes, astute pupil, not only is it in the same category of control, it shares 95% the same letters in the same order as MBProgressHUD. This was merely a coincidence since Mutual Mobile’s official Objective-C class prefix is MM:

From the Ground Up

MMProgressHUD was built from the ground up with a primary focus on animation, presentation and to cover the status bar. I also wanted a framework to easily add new animations and secondarily accept extremely basic user input.

Check It Out

If you’re looking for a new HUD interface, just curious or merely want to check out the bits and peek under the hood, feel free to check out the repository on GitHub. As always, if you find a bug or would like a new feature, feel free to fork the repo and submit a pull request!

iOS 7

I’ve also got some fun things planned for MMProgressHUD and iOS 7 that I can’t yet share publicly, but it will play very nicely and fit right in with the new styling iOS 7 will bring. I can’t wait.

Up Next

This is one of two things I’ve been working to open-source recently. If I weren’t on vacation right now, I’d be working on releasing the other. If you’ve ever been working on an early or prototype version of an app and needed to fill it with content, you’ll really be excited about the next project I’ll be releasing. It’s nothing too too exciting, but I hope others besides me find it really useful.

Building Twitter #music’s EQ Slider

Semi-recently, Twitter came out with a cool new music app to discovery new music on (get ready for it) Twitter. They aptly named their new chicklet “#music”. Visually, #music is a very, very cool app. Everything is custom: transitions, collection views, collection view selection animations, media player controls, and one very cool volume slider. If you don’t have an Rdio or Spotify subscription, you probably don’t see anything cool about the media player’s volume slider, but when you have one of the aforementioned subscriptions, the slider turns into a full-on 2-channel equalizer. It’s very cool.

So I had to build it - and now I’m going to show you how I built it so you can build something similar. This isn’t a full-on tutorial, but some generics behind building it with some code samples.

LARSBar

The final product I’ve created is available as LARSBar on GitHub under the MIT license. Ignore the name. Seriously, despite trying to move away from my name as a prefix, my friends at work penned the name for this control when I showed it to them, and I couldn’t come up with anything better.

Design

When I first start a new UI component. I take a step back and look at the big picture of what it is I’m going to be building. This is what we’re going to be building if you haven’t seen the app:

A Screenshot of Twitter’s EQ Volume Slider:

Before I begin, I ask myself a couple of questions to help me plan and not waste time (note this is just implementation, designing a component involves a whole different set of usability questions):