Why so serious?

This morning at breakfast my wife and I were casually discussing the hypothetical question: “What possession of your partner’s would you like to throw away?”. Typically the answer might be that beat-up recliner left over from college days or an old, ratty (but much beloved) t-shirt. Our 7 year-old son, though interpreted the question differently and asked, “Mommy, wouldn’t you like to get rid of Daddy’s seriousness?”

That really took me aback. What, me serious? Why just last night while my wife was working late in the office, my son and I had a video game and ice-cream party at home. We even made an ice-cream run so that we could have seconds, and we went crazy with the sprinkles and toppings. How could he say I was serious, while my wife was the fun one?

A bit of background: my wife and I both work and we both take our work very seriously. While we may not be workaholics, we probably come close, and at a minimum we are both quite passionate about what we do. If anything, I think my wife is more serious at work than I am. Not that she’s mean or anything, far from it, it’s just that she expects the same competency and diligence from her colleagues that she demands from herself, and has little patience for ineptitude or lack of effort. The main difference I think is that while my wife works in an office, I have been working from home for the past 12 years.

I love working from home, and it would take a lot to convince me to return to an office full-time. I have worked from home for our son’s entire life, so for him that’s how the world works: mommy works in an office, and daddy works at home. But a downside that I hadn’t really considered before today is that this means that our son is exposed to my business side on an almost daily basis. I think many people who don’t work at home, imagine that the biggest challenge to working at home would be to remain focused and continue to work instead of spending all day goofing off. Perhaps that’s the case for most people. For me though, the problem is exactly the opposite: learning to leave work behind and have more life in my work-life balance.

My work-life balance issues have been compounded by the fact that for the past 2.5 years or so, I’ve been working harder than ever. I decided at the beginning of 2012 that I really wanted to get better at being an iOS developer, and began taking extra steps to achieve that goal. That meant that on top of my full-time development job I would write blog posts, work on open-source projects, read technical books and blogs, watch technical videos, work on the occasional consulting project, and work on conference presentations (create the talk, make slides, write sample code, and practice the talk). All of the above has already paid off for me: I feel I’ve improved at a much faster rate over the past 2 years than over the previous decade. It has brought me 2 jobs that have each improved my work satisfaction and additional consulting work which has done the same. But the cost has been many weeks of early mornings, late nights, and weekends spent coding instead of enjoying my family.

One of the things I love most about working from home is the flexibility it brings. Being there (almost) every day when my son arrives home from school is priceless. It’s the perfect time to take a break, head downstairs, get a hug and ask him how his day at school was. But somedays if I happen to be in the middle of a conference call or am deeply focused on a difficult task with a critical deadline looming, I can’t take that break, and if my son comes up to tell or ask me something, he glimpses my serious, focused side, and depending on what’s going on (e.g. conference call with a client) I may hardly be able to acknowledge his presence let alone have the conversation he wishes to have with me.

Why so serious?

This morning was definitely a wakeup call for me. I’m sure I’ll never be able to “throw away my seriousness”, but I can make an effort to not think about work outside of work hours, and to take every opportunity to appreciate and enjoy my wife and our son. After all, if I can’t take advantage of the flexibility that working at home affords me, then what’s the point? Kids grow up so fast that I need to savor every precious moment.

Speaking of which, it’s Memorial Day weekend and our pool has just opened for the season. It’s high time to close my laptop and go have some fun.



Device orientation vs interface orientation

Just today I got bit by confusing device orientation and interface orientation. I really should know better. Device orientation is of course the orientation that the device is currently being held in, while interface orientation is the orientation of the running app’s user interface.

What I was trying to do was to hide the status bar while in landscape mode and show it in portrait mode for an iPhone app that operates in the 3 principal orientations: portrait, landscape left, and landscape right.

To achieve that I was using code like this:

#pragma mark - Status Bar

- (BOOL)prefersStatusBarHidden
    return (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]));

#pragma mark - Orientation

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [self setNeedsStatusBarAppearanceUpdate];

This works fine at first blush, especially in the simulator, but not so well in practice. First off, the app doesn’t even support all 4 possible interface orientations (the fourth being upside down portrait), so what happens when the phone is held upside down? Well the interface orientation doesn’t change from its previous orientation (most likely landscape) but the device orientation is not landscape and so the status bar appears. Bug.

But even worse, there are additional device orientations (namely face up and face down) that are neither portrait nor landscape and have no matching interface orientation. If the phone was last in landscape interface orientation and then gets laid flat on the desktop, the device orientation is no longer landscape (it is flat), and so the status bar appears. Bug again.

Just for the record, here’s the definition of UIDeviceOrientation:

typedef NS_ENUM(NSInteger, UIDeviceOrientation) {
    UIDeviceOrientationPortrait,            // Device oriented vertically, home button on the bottom
    UIDeviceOrientationPortraitUpsideDown,  // Device oriented vertically, home button on the top
    UIDeviceOrientationLandscapeLeft,       // Device oriented horizontally, home button on the right
    UIDeviceOrientationLandscapeRight,      // Device oriented horizontally, home button on the left
    UIDeviceOrientationFaceUp,              // Device oriented flat, face up
    UIDeviceOrientationFaceDown             // Device oriented flat, face down

And here’s the definition for UIInterfaceOrientation:

typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {
    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,
    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft

It’s interesting that UIInterfaceOrientation is defined in terms of UIDeviceOrientation.


So what I should have been doing was this:

#pragma mark - Status Bar

- (BOOL)prefersStatusBarHidden
    return (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]));

This works as expected when the device is upside down or flat.