Architecting Error Free Enterprise Mobile Apps

Architecting Error Free Enterprise Mobile Apps

I am not sure if you are aware or not, we recently built and launched C# Corner on iPhone and C# Corner on Windows Phone mobile apps. While initial architecture wasn't as smooth as it should be, we got it right the second time.

The Architecture

Let's look at a typical architecture of C# Corner shown in Figure 1. There is a database server, SQL Server 2008 R2 hosted on a Windows Server 2008 R2. Web Server IIS is hosted on a Windows Server 2008 R2 as well. On IIS, we have C# Corner website hosted that is building in pure C# and ASP.NET. All code is writing by us.

AppArch1.jpg
Figure 1

We also have a WCF service hosted on the Web service that exposes all the functionality needed by our iPhone and Windows Phone apps. The iPhone app is developed using iPhone SDK. The Windows Phone app is created using Silverlight and C#. Both apps call same WCF service.

The Problem

So what's the problem with this architecture? Alright, let's think about it. A mobile device may have following problems.

  • It may not have an Internet connection.
  • It may have a slow Internet connection.
  • The internet connection may be dropped while you are publishing a blog.
  • Initial app load time was not instant.
  • What happens when WCF service is down?
  • What happens when the server is down?
  • What if some articles are too long to load?

The Solution

So what is the solution? In our new architecture, see Figure 2, we introduced a local database on both devices. When first time application is downloaded, it is also shipped with a local database that has the latest data.

AppArch2.jpg

Figure 2

So when first time app is started, data is loaded from the local database and it helps app to load faster. After that, we have a timer that gets latest updated data.

We also check if Web service is not responding, load data from the local database. If you want to post something and the Web Server or Web service is not responding, the data is loaded to the local database and sync later when the service is alive.

Local Data Storage

So what should you store on local device? Anything you think does not change often. For example, a member profile and member settings. They do not change often. You also need to have a flag and last updated time in your database that will set to true every time a member settings are changed. Your app will check this flag and last updated time and if it is different than the local device data, then download the latest settings and set flag to false. 

In our app, besides the member profile, we also store latest 100 articles, 100 blogs, 100 forums and anything latest. Once latest data is fetched, we delete old records so you do not take too much space.  

In this second approach, no matter what, your app will always work J

Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.