The Vital Guide to App Developer Interviewing
In a bipolar smartphone world where Android dominates devices and iOS dominates application revenue, it is impossible to ignore one platform and develop on another. To build and release an application on both dominant platforms, you need special breed of developers. Rare developers that are familiar with both iOS optimized border shadowing and flattened Android UI hierarchies using merge layout tags.
Here is a guide to help you find those rare masters of both Android and iOS platforms.
As smartphones gained popularity, many developers jumped on the trend and started creating iOS or Android applications.
Most of them had previous experience with web or desktop applications, and tried to copy old concepts onto new platforms, but they failed. Smartphone platforms differ from all other types of platforms in many aspects, most of them related to small screen size and how the user interacts with device.
After realizing that new platforms bring new concepts, good developers embraced them and started creating applications aligned with the platform they ran on.
Next, developers who created applications on one platform started working on the other one. Again, many didn’t realize how different Android and iOS are despite some similarities, and continued working with mindsets aligned to the platform they started with. Some recognized this difference and embraced another platform as completely new.
You want to find one of those rare gems - developers who natively understand both Android and iOS and can work on the same application created for both platforms, similar in functionality but differing in user experience and adapted to their platforms.
Although Android and iOS have the same main concepts, they also have many differences. Devices for both platforms are handheld and user input is touch based. But if we dig deeper, we will find more and more differences. They start with design of UI controls, continue with how they interact with the user, how new views are opened, or how users can navigate around the application and platform itself. Background differences are even bigger.
App developers versed in both platforms should know how each of them works, and on top of that understand the differences between them. Developer should know where to use platform specific concepts and also recognize similar concepts called with different names.
Questions and Answers
Q: Describe what classes are and how they used in Objective-C and Java. What about methods and functions? How are nil/null object pointers handled?
This is a simple question as every developer should know what classes are and how they are used. You can use this question to check how good a developer is at explaining concepts and how she/he can explain similarities and differences of two implementations of the same concept. Here is a shortened definition of class from the iOS Developer Library:
A class describes the behavior and properties common to any particular type of object. For any object, the class offers various ways to examine and convert the internal data that it represents. In the same way that multiple buildings constructed from the same blueprint are identical in structure, every instance of a class shares the same properties and behavior as all other instances of that class.
For a class to be useful, it needs a way to receive a message saying it should do something. The terms “method” and “function” refer to the same thing in Objective-C and Java. A method (function) is a section of code that can be called from elsewhere in our code, and the method (function) will perform some action and return some result that can be used by a caller. Method (functions) are used to organize class code into meaningful and understandable sections.
Variables that keep reference to one object, one instance of class, actually hold memory address where that object is located. Special address nil in Objective-C, null in Java signifies that there is no actual object. (This can mean that object was not yet created or that it has been removed from memory.) If you call method of such non-existing object in Objective-C nothing will happen, but if you do the same thing in Java, it will result with a runtime exception completely stopping your application. This is an interesting difference in otherwise very similar behavior of classes and objects in Objective-C and Java.
Q: What are the similarities and differences between protocols and interfaces? How and when are they used?
In Objective-C, a protocol is used to declare methods and properties that are independent of any specific class. On one side, one class can use protocol as definition of requirements that one of method parameters need to satisfy, and on another side, other class can choose to implement the same protocol. In this example, protocol is a list of requirements that method parameter needs to satisfy to be used as such.
Interface is protocol in the Java world.
Q: Describe the relationship between selector message and method in Objective-C. Is there a similar concept in Java?
In objective-C, Selector, message, and method are very connected concepts that build on top of another. A Selector is the name of a method. It does not imply class to which method could belong. A message is a selector and the arguments you are sending with it. A method is a combination of a selector and an implementation (actual code that can be executed).
In Java, there is a method reference that references defined method of defined classes and can be used for dynamic method invocation.
Q: What is category in Objective-C? When is it used?
Categories provide the ability to add functionality to an object without subclassing or changing the actual object. They are often used to add methods to existing classes created by other developers. The biggest problem with categories is the possibility that two categories define methods with the same name. In that case, it is not defined which method will be used.
Java does not have a similar concept.
This question was taken from Stackoverflow.
Q: What is runtime object type checking, and when is it useful?
During application run time, method or function can check type of passed parameter and decide how to treat it depending on its type. For example, a method expecting object of type Contact can inspect the received object to see whether it is PersonalContact or BusinessContact (in this example PersonalContact and BusinessContact are both subclasses of the Contact class).
Q: Explain differences in error handling between Android and iOS.
In Java (and Android), all problems that arise during the execution of a program are communicated through the concept of throwing and catching exceptions. Throwing an exception stops execution of the current function and continues in catch and finally blocks of try-catch-finally construct somewhere up in the function calling hierarchy.
Although the same try-catch-finally construct exists in Objective-C, it is not so widely used. Instead, Apple’s Cocoa handles problems by using objects of type NSError. The two most common approaches are:
- Pass a blank
NSErrorobject into a method and when the method completes, check to see if that object is still blank or contains an error.
- Pass an
NSErrorobject to some failure delegate method or callback method.
NSError objects contain information about the occurred error that error handling code can use to decide further actions.
Q: What is the source of exc_bad_access error in iOS?
exc_bad_access errors are a common source of frustration for iOS developers due to the lack of useful debugging information that they provide. They often occur when trying to access an object that was never initialized or has already been released. These errors can also result from passing a parameter to a message that the message is not intended to receive (such as passing a
NSInteger when an
NSString is expected).
To find the source of the problem, a developer can enable
NSZombies in Xcode and keep objects that would normally be released alive as “zombies”. After enabling
NSZombies, you can then follow what is happening in your code and receive a message when the application tries to access an object that has been released, thereby identifying the problem in your code.
Q: What can cause ANR error on Android?
We can find a perfect explanation on the Android Developer website.
The system displays an ANR if an application cannot respond to user input. For example, if an application blocks some I/O operation (frequently a network access) on the UI thread so the system can’t process incoming user input events. Or perhaps the app spends too much time building an elaborate in-memory structure, or computing the next move in a game on the UI thread. It’s always important to make sure these computations are efficient, but even the most efficient code still takes time to run.
Q: What are the advantages of Swift over Objective-C?
This is an open ended question, so you can use it to test how a developer handles conflicting situations by taking the opposite viewpoint of their claims. Almost any difference between Objective-C and Swift can be seen from both sides, either as a step in good direction or step in bad direction. You can find more information about Swift on our blog From Objective-C to Learning Swift
Q: Compare UITableView/UITableViewDelegate on iOS with ListViews/ListAdapter on Android.
UITableView (table view) is a part of
UIKit, used for displaying and editing hierarchical lists of information. A table view displays a list of items in a single column allowing users to scroll through the table.
UITableViewDelegate is a protocol that delegates of
UITableView must adopt. Methods of protocol allow delegate to manage data and presentation of data in the table view. We could say that object implementing
UITableViewDelegate protocol adapts data so it can be used inside table view.
On Android, ListView is used for displaying data in a scrollable table, and ListAdapter is an interface that needs to be implemented by class adapting data for ListView that displays it.
ListViews/ListAdapter are the same concept named differently.
Q: How are animations created on Android and iOS?
Android documentation gives a nice description of animation options on Android.
Android provides two mechanisms that you can use to create simple animations: tweened animation, in which you tell Android to perform a series of simple transformations (position, size, rotation, and so on) to the content of a View; and frame-by-frame animation, which loads a series of Drawable resources one after the other. Both animation types can be used in any View object to provide simple rotating timers, activity icons, and other useful UI elements.
Tweened animation is the preferred option, as it allows more granular programmatic control over what happens and is easier to adjust for specific requirements.
On iOS, the most preferred animation option is creating animations using
UIView class methods (
animateWithDuration:animations:, animateWithDuration:animations:completion:, and animateWithDuration:delay:options:animations:completion:) All three methods are block based, and as they are
UIView class methods, animations are not tied to any particular view so one animation can animate multiple properties of multiple views.
Q: How do Memory Management and Garbage Collection Function?
Objective-C keeps track of what objects are in use by keeping a retain count for each object. When an object is referenced, retain count is increased. When dereferenced, retain count is decreased. When count goes to zero, the object is removed from memory. Retain count can be managed manually (Manual Retain-Release - MRR) or automatically (Automatic Reference Count - ARC).
With MRR, developers had to worry about retaining and releasing an object. In contrast, ARC automatically takes care of updating retain count. As result of that, most iOS applications and developers are using ARC.
On Android, memory management is completely different. Dalvik virtual machine performs routine garbage collection and removes memory from all objects not referenced by other objects. This usually works as it should, but common sources of problems are Bitmaps. You can find more about Bitmap memory management here.
We just scratched the tip of the iceberg of knowledge needed to be a top Android and iOS app developer, although we highlighted some important core concepts and differences.
Taking into account the complexity of each of platform, it becomes clear that it can take years for developers to master all necessary knowledge. We hope that questions and answers presented in this post will help you find the right app developer for your project.