Monkey Business

By Peng Xie

Let the monkeys out!



Of course we’re talking about monkey tests here… There are actually two types of monkeys — the smart monkeys and the dumb monkeys.

A smart monkey, knows the application it is testing, and follows a certain set of rules when it comes to doing its job. A dumb monkey, like its name suggests, knows pretty much nothing and behaves more randomly. One can think that a monkey in real life is probably somewhere between our smart monkey and dumb monkey.

There are advantages and disadvantages for both types of monkeys. A smart monkey, while being more effective to find bugs, does require more effort to “train”. The developer needs to create the said knowledges and rules for the smart monkey before it can start the tests. A dumb monkey is more likely to find random, out-of-the-box bugs. But thanks to its unpredictability, the bugs found by a dumb monkey may be harder to reproduce. Some would even question the value of monkey tests since it may take a long time before they can find any bugs.

“But why?” 

I think monkeys are important friends of developers. Here’s a story:

Xuanzang finished his app. He used test-driven development procedures and wrote all the unit tests for all components of his app, including “comprehensive” UI tests. (At least that was what he thought.) His app passed all tests with flying colors. He were happy and released it to the public. A day later, weird UI related crash reports started to show up in his inbox. People had given his app negative reviews. And he were no longer happy.

“Why? The app passed all tests!” exclaimed Xuanzang.

His monkey friend came and touched a part of the UI that “a normal user would not think of touching.”

The app crashed.

The monkey friend relaunched the app and long pressed a button that “a normal user would just tap.”

The app crashed again.

You see, the monkey is not a “normal user.” As developers, it’s easy (and absolutely normal) to assume a certain user behavior when making test cases. Because we designed the app to function in a set boundaries, we may be blind to some behaviors outside of the box. A wise man once told me, when it comes to test cases, if you think you are already crazy enough, the real life will always out-crazy you. To save our sanity (and time), we need to ask our monkey friends for help.

“Where can we make friends with the monkeys then?” 

A lot of places actually. Not in the zoos though…

If you are an Android developer, your monkey friends are actually living right in your Android Studio! They run on your emulator or devices to produce random streams of user events.

For iOS developers, Apple has yet to introduce us any monkey friends. But we do have SwiftMonkey that lives in GitHub. It even has a framework called SwiftMokeyPaws to let you see where your monkey friends have touched in real time in your app’s UI.

Those are only a few examples. If you search, you can always find a monkey friend with a very particular set of skills…

Ethical Dilemmas of Technology: Privacy

By Xinye Ji

“Arguing that you don’t care about the right to privacy because you have nothing to hide is no different than saying you don’t care about free speech because you have nothing to say.”

-Edward Snowden

It’s difficult to overstate how much privacy we give up to have access to services such as Facebook, Twitter, Instagram, Google, or even Amazon. With every click, whim, or action, we tell the services we interact with a little about ourselves bit by bit. As time goes on a clearer profile of each person is created, and interesting conclusions can be drawn from these profiles.

The movie Yes Man satirizes the worst case scenario when Carl, Jim Carrey’s character, is arrested on charges of potential terrorism due taking flying lessons, studying Korean, approving a loan to a fertilizer company, meeting an Iranian woman, and buying plane tickets at the last minute. While the situation was comically exaggerated, the film brings up an interesting social commentary of the state of our privacy. We run the risk of pushing ourselves further into a surveillance state.

Speculatively, one could argue that applying this data aggregation comes from a place of good will. In fact, terrorism prevention is a frequent argument that the US government makes to continue the activities of the NSA. Aside from crime prevention, there are many different applications to utilize aggregate data. For example, aggregated data now informs us about real-time traffic. Our aggregated profiles can tell us about possible car repair. Are these conveniences worth giving away your information? What about if Target could tell you if you were possibly pregnant based off of your purchases? Or what if Facebook could tell if someone was about to commit suicide? Or what if Microsoft could tell you that you have pancreatic cancer a month before you knew it yourself? Are these advancements in technology worth the loss of our privacy?

This blog post might seem a bit eclectic and contrarian to itself. I don’t intend to draw any conclusions of this topic as we could go on forever about it. However, I do believe this ethical dilemma is something that we, as a society, have to decide on in the near future. For the time being, however, I hope that the average citizen considers and understand how to protect one’s liberties in the digital age.

WWDC 17: Why am I excited as a developer?

By Peng Xie

WWDC 17: Why am I excited as a developer?

It’s been a week since WWDC and I finally got time to write this blog post to express my excitement as an iOS developer. I won’t be talking about the keynote, since it’s pretty much the same every year. Instead, I’ll be focusing on the real deal, WWDC 2017 Platforms State of the Union.

For the non-iOS-developer readers, Platforms State of the Union is a session in WWDC that gives attendees a more technical overview of what’s coming to Apple’s platforms, as its name suggests. Just like previous years, Apple made some really big announcements to its developer community. Let’s see some of my personal favorites.

Xcode 9 Source Editor

As an iOS developer, I use Xcode everyday, which sometimes can be a pain. Xcode’s performance and features are not that strong comparing to some of the competitors. This year, Apple introduced one of the most welcoming changes to Xcode in my opinion – they have re-written the whole source editor from ground up in Swift! The result? 3x faster file opening seed, 60fps scrolling and up to 50x faster jump-to-line action. On top of that, they also implemented an integrated markdown editor, improved coding issue presentation and tokenized editing. What’s even better? A brand new refactoring engine and workflow that is powered by an open-source transformation engine. IntelliJ users may not be that impressed with these improvements. But to me, the all new source editor will give me a huge boost in productivity. I can’t wait for it to come out of beta… (Rule of thumb, don’t use beta Apple softwares on production development works.)

Swift 4

Not surprisingly Swift 4 will be there with Xcode 9. Apple has vastly improved one of the most widely used classes in Swift, String class. In Swift 4, String is now a range-replaceable bi-directional connection, meaning it behaves and can be used like an array of characters now without any sort of conversions. Thanks to the underlying improvements, String now provides 2.5x-3.5x faster processing depend on the language it’s in. Another welcoming news is the introduction of “codable” type. The new type will be synthesized by compiler and has the ability to perform 100% type-safe JSON encode/decode with only one line of code. Apple also made it easier to adopt Swift 4 in Xcode 9. The compiler now supports both Swift 3.2 and 4.0 and allows developer to mix-and-match 3.2 and 4.0 targets. All these improvements makes Xcode 40% faster building large mix-and-match Swift/Objective-C projects. Moreover, building projects using multiple Whole Module Optimization targets is now 2x faster!

iOS 11

One of the biggest announcements in WWDC 17 is iOS 11. For users, iOS 11 blurs the line between a desktop and a mobile OS, which will finally make iPad Pro a viable productivity tool. For developers, this means new APIs to play with. Starting with the new Drag-and-Drop feature, Apple did a phenomenal job making it easier to integrate in apps. It’s automatic for text and web content, and has delegate protocols for customization similar to other iOS APIs. With its cross-process, system-wide multi-touch support and built-in data security, I’m sure developers will start to provide this new feature in their apps to users as soon as iOS 11 becomes available.

Good news for everyone

Along with Xcode 9, Swift 4 and iOS 11, Apple also introduced CoreML for machine learning, Metal2 graphic engine and ARKit for virtual reality. These are only a few that caught my eyes. I am really excited to learn more about CoreML and hopefully can put it to use in one of our apps someday. I truly think Apple has given us developers really good tools and platforms to provide users best features and experiences. This is good news to developers as well as users. A better Apple will surely push its competitors to step up their game, which is something I really like to see. Whether or not you’re a developer or iOS/macOS user, you should be excited too. As consumers, we will always benefit from the competitions.

Properties and KVO

By Peng Xie

The other day I came across a bug when I tried to use Key-Value Observing to observe the change of a property in some not-so-modern Objective-C class. The observer was never notified when the property’s value changed. It took me a long time to figure out what was wrong and I just want to share my findings, so you don’t have to be upset should you ever run into a similar situation.

It all started with a simple “@synthesize” statement.

Some background first. In “Adopting Modern Objective-C” document, Apple recommends using properties instead of instance variables (or iVars) in “as many places as possible”. One of the benefits listed is “Auto-synthesized getters and setters”. If you still remember all the “@synthesize” statements in stone-age of Objective-C, I believe you will just love auto-synthesizing feature in modern Objective-C as much as I do. (Almost) No more “@synthesize”! Isn’t that sweet?

Even though synthesizing is no longer required (most of the cases, and usually not even recommended), you can still use it to synthesize a property with a backing iVar (Compiler will create an iVar with the same name of the property if there isn’t one created by developer.) and custom setter and getter. However, if you don’t make your setter KVO-compliant or just simply ignore setter and change backing iVar’s value directly, KVO will obviously fail to observe the change in property’s value.

A well-designed custom setter or a setter created by auto-synthesizing calls “willChangeValueForKey:” and “didChangeValueForKey:” methods at appropriate moments to send observer notifications so that observers that implements KVO methods know when a property is changed. If new value is directly assigned to a backing iVar, the setter is never called and hence there will be no notification sent for KVO. Not only will your own KVO code not work, any framework you may have used in your project that depends on KVO will also not work.

You can find a demo project here. In the demo, if a property’s value is modified without using the accessor (setter in this case), KVO won’t be able to observe the change.

TL;DR Listen to Apple and use properties wherever possible.

Opposite View: WWDC15 Keynote from a Developer’s Perspective

By Peng Xie

OS X El Capitan

  • Oh the new name, good luck translating it into other languages…
  • Pinned Sites in Safari: It’s gonna be useful when browsing Facebook, Twitter, etc. at work, class… Apple’s engineers really understand what we want after all.
  • Enhanced Spotlight: I actually didn’t know you couldn’t check weather and search things with your own words with Spotlight in Yosemite.
  • Mail App: I’m gonna write emails to all the people I know with all the tabs I can have in new Mail app’s compose window and still ignore emails from Phil Schiller because I can search for all emails I ignored from Phil!
  • Spilt View and Window Management: Seems like Apple learned something from Windows 7?
  • Metal for Mac: RIP Open GL… While the PC gamers are playing GTA5 with awesome graphic, Mac gamers are still stuck with games like vegetables vs zombies. Let’s see if these big game companies can convince PC gamers to buy Macs.
  • Have I mentioned that El Capitan is faster than Yosemite?

iOS 9 and WatchOS 2

  • Siri now has a new animated interface. I wonder what will you see if you look at it with red-blue 3D glasses…
  • Siri can also do way more than it (she?) could before based on its (her?) soundings.
    • “🎵It sees you when you’re sleeping… It knows when you’re awake…🎵”
  • Like in OS X, Spotlight on iOS has received a new interface and can now look into your apps for search results.
  • Apple Pay now works at more places than ever! And apparently Apple and Google seem to have reached some agreement to switch the names of their payment app. Yes, I’m looking at you, Android Pay and Apple Wallet.
  • Happy drawing in the new Notes app!
  • Maps app can now tell us which bus/train to take to go to places!
  • Apple now lets you choose what news you wanna read in its new News app, as long as you’re in US, Australia or UK.
  • People have been asking for an “iPad Pro” for some time now. Apple’s answer to it is a new QuickType keyboard with shortcuts plus touchpad capability and a more powerful multitasking feature (Samsung, get your lawyers ready!).
  • You’ll be able to use the awesome Picture in Picture and Split View feature if you have the latest iPad Air 2.
  • Swift 2 will be open source later this year, available for iOS, OS X and Linux. I feel sorry for Windows because it won’t get all the wonderful new features comes with Swift 2.
  • It seems like WatchOS 2 can finally do what it suppose to do a long time ago. Apple has finally given access to normal frameworks and features like animation & layout for Apple Watch.

Everything about Music

  • For $9.99 a month, you get another Spotify alternative. That’s it.
  • And the crazy developers at Apple are developing an Apple Music app for Android as well!

Overall impression
I am not happy about this keynote and it’s not because there’s no new Apple TV or other new toys. WWDC is a developer conference and it should focus on new operating systems and SDKs, not music. Unlike previous years’ WWDC, Apple rushed through announcements and demos and spent what seems like forever for their new music streaming service. I understand it’s important business for Apple but they really should have spent more time talking about WatchOS 2 and Swift 2.

Not Impressed

Not Impressed


How to learn iOS Development (Part 3)

By Peng Xie

[You can read previous parts of this series here: Part 1  Part 2]

It’s been a long time since the second part of this series was posted. Hopefully my experience on note taking is helpful. In this final part of the blog post, let’s talk about how a developer can evolve from “just being a developer.”

Sky’s the limit

It’s common sense to keep learning for professions like developer. I’m at no position to tell someone what he/she should learn but I think there really shouldn’t be any limit on what a developer can learn. Making an app from scratch involves efforts from different aspects such as design, project management and so on… For instance, basic image editing skills are easy to pick up and will make things way easier when you want to make some small changes to an image you want to use in the app. And knowledge on project management can help you better plan and estimate your development work. In my opinion, having those knowledges and skills can be extremely useful for any developer works independently or in a team. After all, you don’t always have a graphic designer or a project manager in your team.

Always something new

iOS (or Cocoa in general) developer community has been active for a long time and there’re tons of awesome things that satisfy all kinds of needs for developers. For example, ReactiveCocoa framework provides additional APIs for functional reactive programming using Objective-C. And tools like Reveal makes tasks such as debugging user interfaces much easier and efficient. The geeky side of me always like to spend free time to discover and play with new frameworks and tools. It’s an interesting way to learn about new coding styles and enhance your own apps from those open source frameworks. I usually visit Ray Wenderlich’s tutorial website, NSHipster and to learn about new frameworks and tools. Websites like CocoaControls are also good places to discover UI related frameworks.

One for all, all for one

We benefit a lot from other developers with all their fantastic works on different frameworks and tools. As members of the developer community, we should give back to the community and help other developers whenever we can. Contributing to open source projects and answering questions on websites like Stack Overflow are good ways to learn from other people. We can learn about types of issues other people encountered and discuss different approaches on fixing all kinds of issues. Moreover, having a good profile on GitHub and Stack Overflow also makes you stands out from other people when you try to find a new job.

Where to go from here?

It’s actually never possible “just being a developer.” Sometimes you have to be a graphic designer or a project manager. And if you want to, you can also be an adventurer, a contributor or a tutor. Let us know in comment section what you think about this series and what other topic you want to see in the future.

Keep learning and happy coding!


How do I learn iOS Development (Part 2)

By Peng Xie

(Part I of this series can be found here)

In Part One of this blog post, I mainly talked about how I got started with iOS development and some ways I find useful for learning iOS development. At the end of Part One, I also promised to share a habit of mine that has benefited me a lot on iOS development. If you haven’t read the last part yet, you can find it here and see if my experience can be a helping hand to you. Otherwise, sit back relax, grab yourself a drink, and let me unveil my secret habit on iOS development.

The Situation(s) and The Solution

  • Have you ever encountered a bug in your app that makes you think you’ve seen it somewhere before (but you forgot how you solved it)?
  • Have you ever worked on an old project of yours and wanted to travel back in time to hug yourself or beat yourself with the keyboard?
  • Have you ever wanted to mimic a design from an app or a library but forgot which app or library is it from?

I have been in all those situations and even more. Every time I’m in those situations, I wish I could remember but I simple can’t. I think as normal human beings, our memory is highly limited and new things will replace old ones as time goes. Therefore there has to be a solution to this. For me, it’s simply to write down things I want to remember. Yup, it’s just taking notes.

What to take notes for and how do I learn from them?

I’d like to approach this from a leaning perspective. I usually take notes for the mistakes I made, the projects I worked on and the tricks or designs I leaned from other apps or libraries so that I can learn from mistakes, past and others.

Taking notes on bugs I encountered and solutions to them makes me able to learn from my own mistakes. It can be a boring task but I guarantee that you will not regret doing it. Sometimes I may find a bug that I’m 100% sure I had some time before. But I just can’t remember how I fixed it last time. If I don’t have my notes or for some reason it is not in my notes, I have to go through the process to fix it like a new bug, which can be a pretty time consuming and frustrating task. However, if I can find it in my notes, everything becomes much easier. Taking notes on my own mistakes has greatly reduced the time for debugging and the number of mistakes I may make while coding.

Just like learning from my old mistakes, I review my old projects on a regular basis and make improvements (or upgrades) if needed. While reviewing the old projects, I take notes on the bad designs I find and changes I need to make. This can keep my projects as well as my brain up to date and with the notes I can be more mindful when working on my next project. The notes make my projects more “future-proof” so that I can love, instead of hate, myself more when I have to come back to work on an old project.

In addition to taking notes on my own mistakes and projects, I also spend time checking out interesting apps and libraries from other developers. I take notes on things I want to do or use when I see them in other people’s apps or libraries. Therefore, I always have some sort of reference when I need them. I spend time checking out apps in App Store’s top lists as well as other popular and award-winning apps every now and then. It’s a good way to learn what kind of design is trending and it also gives me a rough idea on what users want from a developer’s perspective. I learned even more from open source libraries and projects. The source codes themselves can give you a pretty good picture on other developers’ design style and some good practices. And the issues page of the project is a good place to see what kind of issues other people had and learn something from how they solved it. Try to start with some popular and well-received open source projects. They have more people contributing to them and usually have some pretty good documents to help with learning.

Where to go from here?

Taking notes is a habit that is simple yet hard to keep. It is also a small habit that can make big difference. Leave a comment and let us know if this blog post is helpful to you. We will be also happy to hear from you about your development habit and how it helps you. Make sure to check back on the last part of the blog post, which I will share my thought on how a developer can evolve from “just being a developer.”


By Xinye Ji

Tunnel Vision

For those of you who may not have been following, Apple has been getting a lot of flak for the build quality of their iPhone 6+s. The phenomena has been aptly been dubbed bendgate. So what is the root cause? Is Apple at fault? How does this affect Apple in the grand scheme of things?

A Little of This, a Little of That

According to Apple, only a low number of phones have been reported to have bent. So in theory, the end users of the iPhone 6+ are simply breaking the phone through excessive use. Truthfully, only time will tell, as the new pair of iPhones have barely been out for a month. On the flip side, if we say that the structural composition is compromised this brings up an interesting argument. I personally believe it’s a mixture of both.



A lot of people are blaming the aluminum alloy of the phone. Certain users argue that it is actually the actual problem is the geometry of the phone. In other words, the physical structure of the phone is somewhat compromised. To be more precise about it, the stress is concentrated right at the bottom of the volume rocker. Even if Apple opted for a harder aluminum alloy, the point of failure would have still been the same.

If you look at other phablet devices like the Galaxy Note 3, they don’t bend. This is not necessarily because of the Note 3’s magnesium alloy chassis, but because of it’s I-beam shaped cross sectional frame. (You know, the same structure that holds up the foundations of buildings.)

Moving Forward

Was Apple blinded by the chase of the super thin phone? Yes. Were users who experienced issues with their devices somewhat wreckless? Perhaps. While we aren’t sure what percentage or number of people will experience bendgate first hand, perhaps putting a giant phone in your pocket isn’t the best idea. All we can really do is make sure to learn from those lessons and move on.

What can we learn from this fiasco? Well obviously for the hardware designers, don’t forget that engineering has it’s place in product design too. However, this lesson also can be extrapolated to companies like us at Cogent. Even though we don’t design hardware (yet?), we can take Apple’s oversight as a healthy reminder to not be blinded by tunnel vision when considering the design of our products.

Your Favorite Phone now meets Your Favorite Car

By Phillip Garton

The average American spends 162 minutes on their mobile device a day and 101 minutes in his/her car. The likelihood of these times overlapping is ever increasing as mobile devices become more and more integrated with our lives. The need to stay in constant contact, get directions or find the nearest place to get a burger becomes an everyday need.

It is no surprise that the most prevalent phone operating systems want to make life easier by offering features in your car, but it is also no surprise that car manufacturers want to bring these features direct to you from your dealer. Both Apple and Android announced this year that they will be offering in car systems straight from the OEMs for integration to their devices.

Apple CarPlay

Apple has introduced CarPlay, a feature rich in dash information system for the OEM and Aftermarket that integrates with your iPhone 5/5C/5S/6/6 Plus. CarPlay extends many of the functions that you most commonly use while in your car to the cars in dash head unit making it easier to keep your focus on the road ahead.

CarPlay attempts to keep the road your main focus with putting controls within reach. Siri handles all your voice commands, allowing you to answer calls, send messages, ask for directions or request your favorite song. If you are more of a button pusher, CarPlay also allows for all of these controls to be accessed through on screen menus or operation through your in cars specific controls.

Apple knows that while driving you have enough to worry about so CarPlay brings you everything you need without having to search for it. Apple Maps is there to give you direction, traffic to make sure you get to your destination on time. Calling is there to make sure you never miss making that important call or taking one. In car Messaging is there to help you response to those texts or emails that just can’t wait and with Siri you never have to take your eyes off the road to respond. What would a car be without your favorite tunes playing over the radio, iTunes and iTunes Radio and there to make sure you never have to search the radio to find the music you want when you want it.

Apple also knows that your mobile device is personal and it’s not just used for placing calls and getting directions so CarPlay currently supports some of the popular iPhone apps such as Spotify, iHeartRadio, Podcast, Beats Music, MLB at bat, and CBS Radio to name a few with more to come.

CarPlay will be available in the aftermarket from Alpine and Pioneer, in addition some OEMs that have already signed up to offer this right from your dealer such as Ford, GM, Chrysler, Toyota and BMW to name a few. You will soon be able to take full advantage of CarPlay in your car old or new.

Android Auto

Android has introduced Android Auto an in dash information system coming for OEMs that integrates with your Android device running 4.2 or higher. Android Auto extends most of your mobile devices functions to the in dash screen keeping your hands on the wheel and eyes on the road.

Android Auto keeps you focused using voice and on screen in dash controls. Using hot words like “Hey Google” all your voice commands, such as answering calls, send messages, asking for directions or requesting your favorite song can be done. Similarly you can access all these functions through simple and quick interactions on the in dash display.

Android wants your car to become a natural extension of your phone, so Andorid Auto brings you everything you need and nothing you don’t. Google Maps is there to give you the reach driving and turn by turn navigation with lane guidance and traffic information you come to expect. Calling and Messaging are there too, so you never miss the contact when you need to make it most. Want music? Just ask Google and it will be served up to you right through your in car audio.

Android just like Apple knows that your mobile device is personal and your favorite apps can’t be ignored so Android Auto currently supports some of the best Android apps such as Spotify, iHeartRadio, Pocketcast, MLB at bat, and Pandora, to name a few, with more to come.

Android will be available for OEMs with no word on Aftermarket as of yet, but some OEMs that have already signed up to offer this right from your dealer such as Ford, GM, Chrysler, Volkswagen, Honda and Bentley, to name a few.

Your Choice Your Car!

The choice is yours! In rare form Apple and Android are offering very comparable products, the screens and interface are close in look and feel. The apps and functions of both products are almost the same and even the car manufacturers overlap between the two products with the only edge going to Apple for supporting the Aftermarket but with Google’s open sourced approach to software I would think this is only a matter of time before we see an Android based head unit on the market.

The only questions that really remains is how quickly will we see cars equipped with this great technology and which will you choose? Soon your choices will not only include what color paint or if you want leather, but what mobile device you use.