I believe that it is essential for developers to understand the synchronize mechanism since a client can go offline and you will need to think about the reconciliation of this data. When adding the synchronizing capability to your application, you can reduce the limitation of access to your application.
For example, In my mobile the weather application cannot work when its offline or when it is in the airplane mode, and the data is not synced as it is preferred, but if you have the ability to synchronize your offline application data, then the weather application can get the latest up to date weather information even when network connection is not available.
Developers may think of the synchronizing mechanism with an offline capability as a time-consuming mechanism, and that its benefit is not worth the investment. However, as stated in previous example it is an important feature and it is not expensive to adapt to your application, and also being offline should not be an error condition.
I have done several kinds of researches to find ways and technologies to establish data synchronization and I came up with two common ways to do it.
The first way is with the help of Kinto technology, which is a generic JSON document store with synchronization and sharing capabilities. Kinto will keep the local database up to date with the Kinto server, and the remote changes perform to the local data, and local changes are uploaded using headers to control concurrency and overwrite .
The second way that I choose for my final project is with the use of CouchDB, PouchDB and IBM Cloudant service, PouchDB will store data locally and when there is network connection it will start synchronizing to CouchDB with IBM Cloudant service to securely host the data.
I choose the second way since I was able to find more researches and information about it online, also because I struggled with configuring and implementing Kinto to my application, to that end I continued with the combination of PouchDB and CouchDB as it was a more widely used way to perform synchronization.
For my project, I have built an offline-first mobile application called Fitness with the use of Ionic framework; this application mainly focuses on adding your workouts data and enables you to review the analysis of your overall workouts.
The application works when you are offline as the data is locally stored until you reconnect again, and the application can work from any device since it has the offline capability and the sync mechanism. Later on, I will include all the details and analysis I have configured to complete this project.
2 Comparative Literature Survey
Daniel Sauble gives a great example about offline-first applications on his book “Offline First Web Development”, he stated that a VP designer called Susan is responsible for the company’s product design, development, marketing, sales, and others. Susan uses a simple to-do application to store all her lists to organizing everything in her life. Unfortunately, this app behaves poorly when it goes offline. When the internet connection goes down her to-do list fails to load, she doesn’t have confidence that her list is created on her other devices, the app shows scary messages that make her think she lost some data. When Susan has an important thing to write she usually takes fifteen minutes of work, but one day her conference’s WI-FI connection was bad, she continued writing and a few minutes later her to-do list app crashes and Susan loses all her work .
I choose CouchDB over other different databases like PostgreSQL or MySQL instead, because of the and sync mechanism. CouchDB communicates with the database directly from the client-side of the app with the use of also CouchDB is a cover from the bottom-up to enable easy synchronization between different devices and databases .
In my project, the greatest challenge was to perform replication and synchronization with PouchDB with CouchDB or Cloudant to the mobile application data. The main advantage of CouchDB and Cloudant is its ability to replicate the local data storage serving data once the connection is available, and being offline requires synchronization of data when a connection is available. Synchronicity and replication is the process of sharing information between multiple redundant storage sources. Documents in Cloudant are stored in a single structure of JSON format; this format simplifies the complex structure of objects, fields, arrays, and scalable types. Then, they are combined into a simple document record. Furthermore, there are several classifications of NoSQL databases, there is a key-value store that is distributed as a hash table, there is bigtable that is a multi-dimensional tabular system, and there is a graph-oriented database. Lastly, there is a document-oriented database such as CouchDB and Cloudant, which are the databases I chose for my final project .
From the Book “IBM Cloudant database as a service advanced topics”, I understood an important mechanism of Cloudant, and that is it supports replication for mobile devices. The definition of redundant is the ability to store data redundantly along with the cluster of the entire database and to replicate a subset of documents within one database to another, and there are different database replications types, there is bidirectional that deals with two databases. The continuous type that deals with instance up-to-date replication, and filterable that deals with a subset of the database documents, and many other types. By Cloudant, developers do not need to worry about managing the storage of data on the local device and the server. They do not need to think of how, where, and when to store their data. The API for mobile developers works to remove most of the backend complexity . In addition, Cloudant Sync libraries handle the mapping of JSON documentation to SQLite relational data store on the device. The main reason I worked with Cloudant is that Cloudant sync libraries allow you to push database from your Cloudant cluster on the cloud immediately to your mobile application for local read and write operations, this should work even when your network connection is lost. With Cloudant, you can synchronize your data to many devices by using IBM Cloudant and Apache CouchDB. There are two main types of Cloudant synchronize libraries with different features, a type with API library designed for mobile applications, and a type of an index and query layer that closely matches the requirements of an application over what CouchDB view model does .
I worked with PouchDB to satisfy the offline-first sync experience as stated on the research paper “Offline-First Design for Fault Tolerant Applications”, by storing the embedded JSON documents of PouchDB to the local application state while CouchDB on the server side. Many devices can use the application and it will always function based on its current state and synchronize when needed.
Furthermore, I have found helpful solutions to some of the problems I faced during the phases of building my project. Therefore, instead of showing error messages as your connection is not available, try to show the stale data when offline instead. Furthermore, when facing a problem with local data loss for example user overwrite something and as the connection is established the original data can be lost, the solution is to disable editing while offline or to report these actions while offline later on .
The hybrid framework I used to build my mobile application is Ionic 3; it is one of the most widely used frameworks. I have learned Ionic by following the steps of the book “Hybrid Mobile Development with Ionic”, the book mainly focuses on Ionic 3 that is
the official version I have used for my application. On this book, I covered how to set up and install Ionic, what are the Ionic components, what are Ionic platform and its services, how to run ionic on a local host, and how to finally build your application and connect it to your mobile device. Furthermore, Ionic frameworks enable you to add your application as a platform easily. For example, if you want to add it by terminal then run “ionic cordova: platform add android” to display this application on your android mobile device .
In addition, CouchDB + PouchDB and Cloudant are all NoSQL databases, and I have decided to work with NoSQL databases in the mobile application for several good reasons. On the paper “NoSQL in a Mobile World: Benchmarking Embedded Mobile Databases” it is stated that the popularity of NoSQL databases is increasing over the years for mobile applications, and the reason for this is because NoSQL database has the ability to replicate itself, cloud synchronization capability, and document data model. It stated that NoSQL databases work amazingly for large data centers and that we need to choose the right technology depending on the requirements of our application .
Therefore, Perrier and Pervaiz did a benchmark between different NoSQL databases as shown in their paper . The first step was to set up a large data set with random data, and then to create queries and documents depending on each database. After that, they defined a set of matrices to record the benchmark system. Next, they set up each database with an Android device. The result showed that the SQLite database performed great under a high load with complicated quires, and the CouchLite database performed decently on indexed lookups and queries, and DbO4 performed the best at creating and inserting because it was very fast.
To add up, NoSQL offers a lot more than just solving the problems of scaling. NoSQL offer speed even with a small amount of data and between different devices, it offers development time because you do not need to deal with complex SQL quires as joining multiple tables to create your final vision, and almost every NoSQL offer shameless data representation, which means that you don’t need to think too much for the data design structure, as adding new data and nesting an existing data. Lastly, plan for scalability that is to plan to never fall, which means your application can be elastic and it should be able to handle spikes of load .
A great advantage of NoSQL is that it ensures availability and partition tolerance to our data, and it ensures us data consistency by the replication approach. The main advantage of the NoSQL database is that it uses the scale-out approach. If many users start using the application then another server is added. There is no need to modify the application since the application always sees a single distributed database. Furthermore, usually relational databases are expensive, and you need to purchase the license, whereas NoSQL databases are generally inexpensive, free open source, and priced only to their additional services .
CouchDB NoSQL stores their data in the form of documents, it has many advantages as it supports complex data structure and it is easier for debugging, and conceptualizing data. Therefore, it is rather faster than the relational database because it stores an entire object as a JSON document instead of storing and retrieving data from interrelated tables. The conclusion of NoSQL is that it provides a schema-less dynamic flexible data model that is the most preferable for big data and users. NoSQL has the ability to scale dramatically, and it provides improved performance for many users expectations .
👋 Hi! I’m your smart assistant Amy!
Don’t know where to start? Type your requirements and I’ll connect you to an academic expert within 3 minutes.get help with your assignment