Swift 2 ReactiveCocoa MVVM Quest

The Quest

For a software developer (especially at CARFAX), the quest for cleaner code is worthy and eternal. In Swift and Objective-C, two main battlefields where clean code is threatened are View Controllers and client network code. View Controllers get big and client network code suffers from the Pyramid of Doom. The Pyramid of Doom is where there are many nested statements as shown in this Traditional asynchronous code slide. Following the advice of a smart friend named Mike Groner, I looked into ReactiveCocoa (RAC) and revisited MVVM.

Since we have looked at MVVM before and MVVM’s roots go way back to the Presentation Model via Martin Fowler, its concepts are not foreign. It’s true that one does not have to use RAC to do MVVM. As Natasha The Robot showed in her Swift Summit presentation and related Protocol-Oriented MVVM (POMVVM) article, one can manually follow the discipline of doing POMVVM without a framework. So, that’s great. One concern is that it requires the team to relentlessly apply discipline to do POMVVM well.

Shifting our attention to the Pyramid of Doom, how can RAC and Functional Reactive Programming in general help? To answer that question, I checked out Javier Soto‘s Back to the Futures Swift Summit presentation. It was eye opening. It discussed how we typically handle asynchronous callbacks (thus the Pyramid of Doom), error handling, and the concept of Futures as a way of getting rid of “…all the noise related to the asynchrony itself.” Easier to write, read and maintain code through Futures / Promises or better yet Signals sounds good! At the end of the talk, he also recommended ReactiveCocoa aka RAC.

So, What About ReactiveCocoa (RAC)?

OK. The message is loud and clear: Check out RAC! Natasha-The-Robot, guided me to Ash Furrow. Ash helpfully shared Functional Reactive Awesomeness With Swift So, RAC is impressive and RAC may even help one do MVVM. Which version of RAC should I investigate?

For an upcoming project, using Swift 2.1 is a no brainer. Can RAC or something similar be used in a Swift 2.1 project?  NachoSoto comes to the rescue on Twitter and Stackoverflow:  How to Add Production Ready ReactiveCocoa … Into Swift 2 iOS. So, the answer is yes!

Getting ReactiveCocoa 4.0

Being more than ready to dive into ReactiveCocoa 4.0, the question was now “how to get it?” I tried using CocoaPods, but the unofficial podspecs were out of date. it seems like a good answer is using Carthage with a Cartfile of:

github "ReactiveCocoa/ReactiveCocoa" "v4.0.0-alpha.3"

Since I have been a CocoaPods user, it didn’t immediately occur to me to copy the frameworks as per the RAC README page:

On the “General” tab of your application target’s settings, add ReactiveCocoa.framework and Result.framework to the “Embedded Binaries” section.

Success!

RAC and MVVM?

Could RAC or something like it also help with MVVM? Both my friend and Ash Furrow’s presentation above suggested that it could do so beautifully. Searching the web for the most recent ReactiveCocoa Swift examples, I found MVVM With ReactiveCocoa 3.0 by Colin Eberhart and Migrating to Swift 2 and ReactiveCocoa 4 by Martin Richter. So, it certainly seems so.

With ReactiveCocoa 4.0 and examples at hand, the journey has just begun and the quest for clean and well crafted code continues!

Meditating on Meditation Mobile Apps

For a long time, I have watched meditation apps come and go. I feel the apps have crossed a threshold of quality and reliability such that it’s ok to pony up some cash for what I see. Two have served quite well, 10% Happier: Meditation for Skeptics and Headspace.

10% Happier: Meditation for Skeptics

The content is fascinating and top notch. The daily video and meditations are short enough and thus bite sized for the busy person.

They hit on topics I care about deeply and didn’t see anywhere else. Specifically, I wanted to know if meditating would keep me from hitting goals I want to go for. I wanted to know if I would become complacent. They answer that question head-on and many other pragmatic topics. One can also replay the videos as often as desired.

Besides the Q & A sessions between Dan Harris and highly respected meditation experts such as Joseph Goldstein, it comes with guided meditations and even a personal coach who can send and receive messages.

It’s especially nice to have someone who can respond to your individual questions or an experience you want to share. Also, there is something nice about how easy it is to just send a message in the mobile app as opposed to sending emails back and forth.

Headspace

There are some really well done videos such as this “blue sky” animation titled Underlying Calm that is shown right in the app as you progress through the steps.

Other Noteworthy Items:

  • The mobile application gives you a sense of progress and accomplishment.
  • There’s a download manager in the mobile application which I found very useful.
  • You can try it for free and then subscribe to the later packs.
  • There are many other items that are great about it. I highly recommend checking out their How It Works webpage.

“Which One Should I Choose?”

Ah. Good question. I started with Headspace. However, I switched to the 10% Happier app after trying both for a year.  I found the 10% Happier app essential to getting answers to some questions I have had. If I had never tried either, I would suggest starting with the 10% Happier: Meditation for Skeptics. However, the choice is yours and you will come out ahead if you choose at least one.

Wrap Up

Although there are many meditation related apps out there, the best ones I know about are the two I covered in this article. Is there a fantastic one that I should try? Please feel free to leave a comment to share what you know or to just say hi. Good luck on your journey and be well!

Updated: December 7, 2017: I updated the Headspace video and content in this entire post.

(Unofficial) Mindful Minecraft Meditation

One day, my son looks up at me and says “Dad, I want to meditate too!”

How did my son get an interest in meditation? Through my example and having acquired a taste of meditation, the benefits of meditation had resonated. So, he asked for help.

Given his experience with games and exposure to Gamification, my son loves to “level up” in whatever he does. For those who don’t know, leveling up is achieving a related series of measurable goals and giving that achievement a name. It’s best done as part of a fun or adventurous narrative.

Unless made quite fun, being still and focusing on ones breath for any period of time can be torture for a child. It was time to cook up an appealing solution.

Combining his love of Minecraft, his desire to achieve, and the idea of “leveling up”, I made the following achievement levels for my little player:

  • Level 1 – Bow and Arrow – One understands the initial thoughts about meditation
  • Level 2 – Wooden Sword – Meditated one time
  • Level 3 – Stone Sword – Meditated for any amount of time 3 days in a row
  • Level 4 – Iron Sword – Meditated 5 days in a row. Diamond Sword level requirements were secret and are revealed at this time.
  • Level 5 – Diamond Sword – Number of days in a row required to meditate: 1 + (6 sided dice roll) for a chance to win the diamond sword. (In this case, 5 days since he rolled a 4.)

To get the diamond sword, he rolls a 6 sided dice after 5 days and he has a 1 in 6 chance of winning. If he doesn’t win, he does another 5 days but he will have a 2 / 6 chance of winning. If he doesn’t win, another 5 days go by and he’ll have a 3 / 6 chance of winning and so on.

Figuring out this Diamond Sword level required me to reach out to the wonderful Gamification Hub community for ideas. Which brought up some good questions such as “Is any of this tangible? Is this a Minecraft modification to the game?”

Simply, he does not receive anything tangible. There is no Minecraft game modification created for him. He simply knows what level he is at with respect to meditation. Although getting a sword is all in his mind, he’s quite happy knowing that he has achieved a certain level of recognized status.

Has meditation and this approach helped? Yes, it has helped. No matter where he is, it provides an escape hatch where he can reflect on what’s going on. In the long run, meditation yields a better brain. So, he is experiencing short term wins and also long term gains.

How long will such an approach last? For him, it lasted about two to three months. When someone pointed out that they don’t need levels, he declared he doesn’t need levels either. Yet, yesterday he was concerned that he lost some levels since he hasn’t meditated in awhile. Through future technology such as the Muse headband, I think meditation could be made more real to him. Until then, we can make the intangible tangible through a Mindful Minecraft Meditation.

Castle In Twilight

Authors note: The term “Unofficial” is used here in this post in order to comply with the Mojang brand guidelines.

Easy To Forget The Incredible and Virtual Reality Is Incredible

It’s easy to forget the incredible.

I’m wearing the Oculus Rift. It has been awhile and I wanted to revisit the Tuscany and Titans of Space demos. Although I have played the demos multiple times before, I still get an emotional charge when I play them.

The Tuscany demo made me laugh when a lint / seedling startled me when it floated into view. The fireplace almost made me feel warm. The butterfly made me smile. I felt peace while staring at the fountain.

When comparing our sun with much larger stars, the Titans of Space demo instilled a sense of awe and majesty. As Yakko of the Animaniacs said, “It’s a great big universe and we’re all really puny.”

Watching these scenes and listening to the associated sounds and music, filled me with inspiration and wonder for our future.

What incredible future shall we create?

Rubik's Cube

Meditation Yields a Better Brain

A hard thing about meditation is its acceptance by people as something useful. “What good is it?”, friends ask. Well, you feel better and it changes your brain for the better.

In my long journey towards understanding the brain better, I have meditated on and off for quite a while. It is only recently I found scientific studies highlighting the cognitive benefits of meditating.

For example, Sue McGreevey of MGH Communications wrote about a study where people meditated for about 27 minutes each day. As a result, there was “..increased gray-matter density in the hippocampus, known to be important for learning and memory..” as well as other tangible physical evidence of great changes in the brain. That’s right! Their brains changed.

Did you know kids can even benefit from meditation using certain techniques? Daniel Goleman, a psychologist well known for his work with Emotional Intelligence, discusses an experience he had when visiting a classroom where half the kids had special needs yet it was a tranquil and orderly classroom. The secret to such success? Watch the video below titled Daniel Goleman: Breathing Buddies:

In the above video and in an article titled How Focus Changed my Thinking about Emotional Intelligence, the technique of breathing buddies is for the kids to ” ..lie on the floor, each with a favorite stuffed animal on their belly, and count 1-2-3 as their breath rises and as it falls.” It’s that easy.

Is it that easy for adults to get started meditating? Yes, one can practice the vipassana, a mindfulness meditation. As described in the Huffington Post article by Sam Harris, one can meditate by focusing on the breath, recognizing distractions, and reverting ones attention back to the breath.

Given the significant scientific evidence of positive brain changes, the straightforwardness of a meditation technique such as the vipassana, and even the positive effect it has on relationships, I highly recommend people add meditation to their list of things they do each day even if only for a few minutes at first. Once you get past 20 minutes, you’ll never feel or be the same.

Rubik's Cube

Discipline Around Energy Yields Productivity

Leaping woman

Energy is a key component of being productive. It fuels ones attention, passion and ability to do anything at all. The saying of “Time is money” is only partially true. Energy is production capability. I could have all the time in the world, but without energy I will get nothing done.

Where I work right now, some of the departments have gotten many key things right when it comes to energy. One of them is having dedicated email breaks and even a couple of windowless rooms for meditating or resting. If people get done with their email early, they can go take a quick break. This can consist of meditating, relaxing, playing a game with a co-worker, or getting something to eat.

During their break, people are recharging their minds and co-worker relationships. What’s also interesting is that during these breaks, new ideas can pop up. New solutions can seem to come out of nowhere. This can be crucial in a high-tech or other knowledge worker company.

Now if you’re like me, you want take your productivity to the next level. According to Tony Schwartz in the New York Times, even higher productivity may come from doing “..daytime workouts, short afternoon naps, longer sleep hours, more time away from the office and longer, more frequent vacations.” Interestingly, it will take much discipline to adopt such activities.

Like other things revealed by science, it will take time to unlearn old outmoded ways of thinking around productivity and energy. For those that seize this new energetic productivity reality, new opportunities await!

Goodbye Smiling Blogger.com, Hello Finney Can Help!

As a place to blog, blogger.com served well for a few years. However, I ran into issues with how the blog posts looked. I spent more time fiddling with things and working with web designers than blogging! So, I decided to start this new site, FinneyCanHelp.com

After searching around for quite awhile and consulting smart people like Yu-kai Chou, I landed on two blogging tools to setup the blog right, WordPress and BlueHost. So far, so good. So time to just copy the old blog content over to my new site, right? Wrong!

I recalled how someone created a new website for a client, copied content over and then BAM, google dropped the websites from google search results completely. In short, they were dead aka a non-entity in the internet. This is because of a duplicate content algorithm google uses to make sure websites are playing fair.  Here’s a related article: Thin & Duplicate Content: eCommerce SEO.

Although I would love to bring over the older blog content, the older content will stay at http://smilingfinney.blogspot.com. Regardless, I’m still smiling and look forward to serving you here at this new site.