Friday, December 02, 2011

Mobile Application Architecture, Part 1

The boom in mobile applications has been fueled by excellent application frameworks from Apple and Google. Cocoa Touch and Android take some very different approaches on many things, but both enable developers to create applications that end users enjoy. Of course "excellent" can be a relative term, and in this case the main comparison is web application development. For both experienced and novice developers, it takes less effort to be more productive developing a native mobile application than a web application (mobile or not.) This despite the fact that you really have to deal with a lot more complexity in a mobile app (memory, threads, etc.) than you do for web applications.

Despite having significant advantages over web development, mobile applications often have some similar qualities and this often leads to similar limitations. Most mobile applications are network based. They use the network to get information and allow you to interact with other users. Before mobile applications, this was the realm of web applications. Mobile apps have shown that there is not necessary to use a browser to host an application that is network based. That's good. However the way that mobile apps interact with servers over the network has tended to resemble the way that web applications do this. Here's a picture that shows this.
Traditional mobile app architecture
This diagram shows a traditional mobile application's architecture. In particular it shows an Android app, hence that little red box on the right saying C2DM, which we will talk more about later. Most of this is applicable to iOS as well though. Most apps get data from servers or send data to servers using HTTP, the same protocol used by web browsers. HTTP is wonderfully simple in most ways. Significantly, it is a short-lived, synchronous communication. You make a request and you wait until you get a response. You then use the response to update the state of your application, show things to the user, etc.

Now since HTTP is synchronous and network access is notoriously slow (especially for mobile apps), you must inevitably banish HTTP communication to a different thread than the one where you respond to user interactions. This simple paradigm becomes the basis for how many mobile applications are built. Android provides some nice utilities for handling this scenario like AsyncTask and Loaders. Folks from the Android team have written numerous blogs and presentations on the best way to setup an application that follows this pattern, precisely because this pattern is so prevalent in mobile applications. It is the natural first step from web application to mobile application as you can often re-use much of the backend systems that you used for web applications.

Before we go any further, take another look at the diagram. I promised to talk more about it. That is the cloud-to-device messaging system that is part of Android (or at least Google's version, it's not available on the Kindle Fire for example.) It provides a way for data to get to the application without the usual HTTP. Your server can send a message to C2DM servers, which will then "push" the message to the device and your app. This is done through a persistent TCP socket between the device and the C2DM servers. Now these messages are typically very small, so often it is up to your application to retrieve additional data -- which could very well go back to using HTTP. Background services on Android can makes this very simple to do.

Notice that in the previous paragraph we never once used the word "notification." C2DM was seen by many as Android's equivalent to Apple's Push Notifications. They can definitely fulfill the same use cases. Once your service receives the message it can then choose to raise a notification on the device for the user to respond to. But C2DM is not limited to notifications, bot by a long shot. Publishing a notification is just one of many things that your application can do with the message that it receives from C2DM. What is most interesting about C2DM is that leads us into another type of application architecture not built around HTTP. In part 2 of this post we will take a deeper look at event-driven architectures.

21 comments:

  1. waiting for the 2nd one hehehe

    ReplyDelete
  2. excellent blog! thanks for sharing your experience of mobile applications....
    Download Mobile Software

    ReplyDelete
  3. It is for the first time, I have visited the blog and it is good to have a useful post regarding mobile application architecture. The company I am working with is named as Kualitatem also offers mobile application development as well mobile app testing all around the globe.

    ReplyDelete
  4. Perfect work you have done, this blog is really cool with fantastic information.

    ReplyDelete
  5. Nice pair of bonding...!
    http://www.mobilyala.com/

    ReplyDelete
  6. OfficeSetupOffice is an independent provider of remote tech support services for software, hardware, and peripherals.And we provide support for Microsoft office setups & Installation related services.
    For Technical Support:Microsoft Office Setups
    Or Call Toll free Now : +1-844-777-7886

    ReplyDelete
  7. NortonComSetup is an Independent technical support service provider for a large variety of THIRD PARTY PRODUCTS, brands and services. If the product is under warranty, the repair or replacement service may be avaliable free from the Brand or vendor.read more:Norton Setup

    ReplyDelete
  8. Do not Disturb
    Welcome, Do Not Disturb!
    The use of Smartphone has made it easy for a lot of users to stay connected, but it can be a serious risk when you use your Smartphone when you are driving.

    Research shows that the use of cell phone while driving leads to 1.6 million crashes each year, out of which 330,000 injuries occur from accidents caused by texting while driving.

    ReplyDelete
  9. Nice post I really like these types of articles where you can get a lot of data with few examples to continue writing like that and many people choose your content.

    DedicatedHosting4u.com

    ReplyDelete
  10. There can be a lot of reasons that cause error 3371 status code 11118 in QuickBooks. If you need an immediate solution at your door-step, then our experts can help you out. We have been resolving this problem for our clients for quite some time. Do you know what causes error 3371! It happens due to corrupted QBregistration.dat files, damaged MSXML components, and virus or malware intrusion. How do we deal with it! That’s pretty simple. We just make sure that your Windows is running with the latest version, rename the entitlement data file, install the QuickBooks tool hub to fix the problem and in the end manually resolve the error code 3371 by fixing the Microsoft.net framework, MSXML components. Connect with us for more advanced troubleshooting tips.

    ReplyDelete
  11. Not sure where to start and how to write an essay? Do you have many questions about writing? You should take advantage of this https://essaysprofessors.com and pass your work perfectly without any problems!

    ReplyDelete
  12. Global Polyglycitol Market size is set to witness an exponential growth in the forecast years owing to its wide use as a bulking agent in sugar-free, dried, and frozen foods. The product is also known as hydrogenated starch hydrolysate and is found in the form of viscous, transparent, odorless, and colorless liquid or in white crystalline lumps.

    ReplyDelete
  13. Hello gentlemen, the name is Sneha and I am a genuine 23-year-old independent call girl. I am willing to do everything with great affection and offer you for our delicious sex encounter.
    Relationship
    Call girls
    Call girl
    Female
    Call girls for party
    Hotel call girls
    Model
    Incall girls
    Outcall girls
    Escort service
    Female call girls service
    Erotic massage
    Call girls number
    Call girl number
    Call girls WhatsApp
    Call girl WhatsApp

    ReplyDelete
  14. Nice information.

    Global mobile banking market will reach $4,680.3 million by 2030.

    ReplyDelete
  15. This is an amazing read, it shows that you actually know what you are talking about, thanks a lot for sharing the elucidated contents. admiralty university departmental cut off mark

    ReplyDelete
  16. Perfectly put together work for mobile app development architecture! Check out Pyramidion’s mobile app development services to offer businesses unique and feature-rich mobile architectures and solutions!

    ReplyDelete
  17. Very nice!!! This is really good blog information thanks for sharing.

    If you getting issues with your mac computer for quicken do not worry call Quicken Assistant Help for Mac at +1 800-213-6058 USA/Canada


    Quicken Remote Support for Mac
    Quicken for Mac User Guide
    Quicken Assistantance Help for Mac +1-800-213-6058
    Quicken Assistant Help

    ReplyDelete
  18. Great information you have shared about Mobile Application Architecture, thanks for sharing this type of information, please keep continue to sharing this great content. Also, please read more about the top mobile application testing companies here...

    ReplyDelete
  19. Find QuickBooks Online Accountant and choose ProAdvisor Training... live trainings led by Advanced Quickbooks Certified ProAdvisors. Quickbooks Certified Proadvisor

    ReplyDelete
  20. I really enjoy reading your article it is very interesting Check esut teaching hospital general nursing admission form deadline

    ReplyDelete