Home‎ > ‎articles‎ > ‎

Making Mobile Fast

Mobile app adoption is accelerating at a dizzying pace.  The demand is certainly there - how will we supply it?

This is a brief survey of the current state of affairs - and a big opportunity.


Client Platforms (choose wisely)

Mobile starts with the device, and right off the bat you need to consider the (inevitable) platform battle - native or platform-independent?
  • Android Native is a variant of Java
  • iOS Native is Objective/C
  • Standard Platform-independent is typically centered around Javascript + HTML5 + CSS, championed by vendors such as Sencha and PhoneGap
  • Some vendors provide cross-technology bindings so that one code base can run natively across platforms, such as provided by Accelerator (also based on Javascipt)


Mobile Servers

Mobile apps run inside a device, but virtually all apps need to access a server - a mobile backend service (MBaaS).  Beyond the mobile interface, more is expected from a mobile app than a web app, including:
  • Social Integration - to connect with friends and colleagues (e.g., by mail, messages etc)
  • Push integration - to collaborate with friends and colleagues
  • Data access - Cloud-based data storage is a key requirement (discussed further below)

The recent acquisition of Parse by Facebook is a clear indication of the strategic value of a mobile backend.


Mobile Data Access

Given the widely divergent views of client technology, it’s surprising (and welcome!) that there is broad agreement on data access: REST/JSON.

REST is a language-independent approach for data access, designed to operate in the context of web by using HTTP as the transport layer. REST can thus be used by any language, since it basically HTTP with some additional conventions. If your language can access the Web, it can access REST.

The message body is JSON.   JSON looks like a simplified XML format, but the real clever idea is that it is Javascript, so can be natively consumed by a wide array of clients. There are powerful libraries in virtually all languages (Java, C##, Ruby, Python etc) to create native objects from JSON (and vice-versa).


Mobile Unstructured Data

Mobile app data storage incurs additional storage requirements than traditional web apps.  Mobile apps often include simple and relatively unstructured data (photos, simple lists), but can require very high scalability.

A common approach is for Mobile Back Ends to provide a REST/JSON interface to a NoSql server such as Mongo.


Mobile Structured Data

NoSql is effective for simple, scalable data, but often has significant limitations in ACID support for concurrency and transactions. While there are many situations where NoSql is sufficient, many applications rely heavily on SQL databases. Richardson argues that Polyglot DB (using both) is a very reasonable approach.

Building a REST/JSON server to front-end SQL data is not a trivial task. You may need to address Enterprise concerns for accessing multiple servers. In addition to defining an API, you have to address scalability (caching for multiple Backend Servers, pagination for large result sets), and Data Integrity.


A Valuable API

One of the super things about REST/JSON is that it provides a Web-based API to your data. This is remarkably significant:
  • SOA layer - a Service Oriented Architecture is an accepted paradigm for integrating multiple databases across an enterprise, empl coarse-grained for performance, and technology independence (e.g., accessed from Java, .NET, Ruby, etc)
  • Public API - even bigger, business opportunities are unlocked since the API is available to business partners across the Web. This enables systems to be developed that both provide a superior customer value, and build business relationship partnerships.


Integrity is a requirement

An API this valuable has not only has the responsibility to expose your data, it must protect it. The Business Logic for integrity and security must be encapsulated into the API so the server enforces the logic without requiring client cooperation.

Server-enforced has always been an Enterprise requirement. Not that it’s been well-followed. In days gone by, the complexity of logic partitioning has lead to failures (“fat client”) that are most certainly being repeated today.


Business Logic manually coded

So, how do we provide this logic? We code it! While it makes sense - domain-specific must require domain-specific code, right? - it is a big assumption.

For a large class of SQL-dependent apps, this can represent as much as half the effort. This has a strategic impact on the business, reducing agility, raising costs, and lack of transparency to Business Users. And that’s a problem - a big one.

Mobile Backend Automation

So, if the problem is time and complexity, the right question is: "how simple and fast can we make it?"   What if it were as simple as:
  1. Server By Convention - simply identify your database, and select custom resources as required
  2. Logic By Expression - automated dependency management keeps it simple and fast
  3. Security By Injection - assign security filters to roles/tables to control access at the row/column level
We can illustrate these below.

Server By Convention

Automation technology begins by leveraging the concept of Convention over Configuration.  Here, it means that if you specify the location (url) of your database, by convention the system will create default REST resources for each table.   Such resources can be used to build Admin applications with simple 1-table displays.

You can also create Custom Multi-Table Resources that combine data from multiple tables and servers.  This enables you to begin mobile client application development, literally within minutes.

So, a server without code.  And, these are Enterprise-class resources, with support for pagination, optimistic locking, discovery, single-trip refresh, etc.

And, they automatically enforce the Logic and Security provisions described below.








Logic By Expression

Instead of writing code, you define your Business Logic as a set of unordered spreadsheet like expressions for computations and validations.  The example shown at left is executable logic.

These are very powerful, providing support for multi-table transactions.  As in a relational database, optimizations to eliminate / minimize SQLs are the systems' responsibility.  As in a spreadsheet, dependency management is automated, so you maintenance simply entails adding new logic.  The system automatically recomputes a valid order of operations based on the new dependencies.

This logic is encapsulated into the Resources, and automatically re-used over all access.  So the logic shown here, perhaps conceived for Place Order, is automatically applied to all related transactions, such as delete order, pay order, move order to different customer, change line item products or quantities, and so forth.

This declarative automation of re-use and dependency management eliminates pages and pages of conventional code.  These 7 rules replace 500 lines of code.  Beyond simple examples shown here, this logic can automate complex business logic like a budget rollup, a bill of materials explosion, a order cloning / auditing, or the application of a payment to outstanding orders.

And logic is extensible.  You can use Javascript to complement declarative expressions, and even define your own rule types.

Security By Injection

You can assign table filters to control table access down to the row and column level.  You simply define predicates (filters) for a given role / table combination.

The system automatically injects these filters into every request, whether from default or Custom Resources.  Update privileges (e.g., what columns can be changed) are similarly enforced.

Here, we ensure a SalesRep can read only their own orders.  We also ensure that only the paid column can be read.


Summary

This article has illustrated a new technology now being brought to market.   If you'd like to give it a try, join our Beta at espressologic.com.




Internal Notes...

Title? Making Mobile Fast

Mogility?

Zones:
MicroZones: Cloud, Agile, Mobile, HTML5, .Net
Zones: JavaLobby, Web Builder, Architects, Server
All Languages

“10X reduction in time/cost for Mobile SQL Backend Services”