SlideShare a Scribd company logo
Mobile Web Apps
  Development
         Ivano Malavolta
    ivano.malavolta@univaq.it
http://www.di.univaq.it/malavolta
Roadmap

• Anatomy of a mobile web app
• Classes of Mobile web apps
• PhoneGap
What is a Web App?

An application built with web technologies
  that is accessible via a mobile browser and
  not exclusively through an app store

The browser may be either the standard device
  browser or an embedded browser (Hybrid app)
Anatomy of a Web App
Anatomy of a mobile web app

This is why HTML5 Mobile Apps are hard
                                  hard!

In many cases you will need to create every
  part of this diagram

If you don’t create it, you still need to test and
  debug each piece
Setting up the Server




As usual, it all starts with an http request

Then you need:
• Data
• A device detection mechanism [optional]
• The app itself
Data

Usually mobile apps do not talk directly with
  the database
    do not even think about JDBC, drivers, etc!

  They pass through an application server and
  communicate via:
  – standard HTTP requests for HTML content (eg PHP)
  – REST-full services (XML, JSON, etc.)
  – SOAP
Data 2

• Data can be stored in any classical way:
  – Relational
  – Graph
  – Key-value
  – Document-based
                                                 www.parse.com
                                                 www.kinvey.com
  Latest trend: backend-as-a-service
  – Data storage, users management, security,
    big files storage, scalability, push notifications…
BaaS
1.    Developers build a visual
      model of their DB

2.  The service generates APIs
    and client-side
    libraries(compatible with iOS,
    Android, Windows Phone 7,
    etc.)
3. The data produced/consumed
    in the app can be
    pushed/pulled to their DB
   – Communication is handled
        via REST or other
        protocols
Server-side device detection
All devices are unique
      you have to know on which device your app is running
      the app can adapt to the device capabilities

Many techniques, the most used are:
• Andy Moore’s browser detector
   – Works for PHP pages only
• Javascript          if (navigator.userAgent.match(/AppleWebKit/i) &&
                                 navigator.userAgent.match(/Mobile/i)) {
• External APIs       window.location.replace('/path/to/iphone/site/');

   – (DeviceAtlas, WURFL)
                         @media screen and (max-width: 980px) {
• CSS3 media queries     }
The HTML5 app

Keep code very semantic
Keep all the logic in Javascript
Keep (most of) the presentation in CSS3

Remember that the user may go offline
• Offline data storage, cache manifest

Progressive Enhancement
  Write all your markup first without any CSS or
  JavascriptThe resulting markup should always be
  perfectly usable in its lowest form.
Progressive Enhancement




Key concept. Graceful degradation
Progressive Enhancement Techniques

• Always code your markup semantically
   – ensure that the page is always usable, even with no stylesheet
• Have a device plan
   – Know which device classes you intend to support before you
     start to code
• Have both your LCD and high-end device designs before
                         high-
  you begin to code
   – Try to visualize a way to create both versions from one code
     base.
• Test on different mobile devices from the beginning
   – your incremental work must display correctly in the intended
     devices
• If you plan to add a desktop layer, always create the
  mobile version first
Anatomy of a Web App
Cache Manifest
Problem.
Problem Browsers have their own caches but they
  are unreliable and heterogenous

The Application Cache allows a developer to
  specify which files the browser should cache and
  make available to offline users

  CACHE MANIFEST
  /main/features.js
  /main/settings/index.css
  http://files/images/scene.jpg
  http://files/images/world.jpg
Cache Manifest
A cache manifest gives you the following benefits:
• Offline browsing
   – users can navigate your full site when they're offline
• Speed
   – cached resources are local, and therefore load faster
• Reduced server load
   – the browser will only download resources from the server
     that have changed


This solution does not cover dynamic data caching
  In that case you can use javascript to get your data
Javascript
Hybrid Scripts

These scripts bridge the gap between your
  core scripts and the device SDK

  – A necessary step if you plan to ship your HTML5
    app in a native wrapper like a standard iOS
    UIWebView or Cordova
  – They may need to be distinct for each platform
    you plan to support
     • For example, the cordova.js file for Android is subtly
       different from the iOS’s one
Core Scripts

The common components of your app

  – they implement the internal logic that your app will
    require to assemble and render your HTML5 pages
  – they will be the same in every platform
  – examples of duties:
     • REST API access
     • Domain entities representation
     • …
  – they include also JS libraries like JQuery and other
    microframeworks
Device Scripts

They work to emulate native behaviors of the
  device with Javascript

  – these scripts may be unique to each platform you
    plan to support
  – examples:
     •   JQueryMobile (JS part)
     •   JQTouch (JS part)
     •   SenchaTouch (JS part)
     •   iui-js
A note on Mobile Web Frameworks

Frameworks like JQueryMobile, JQTouch are useful
  since they give you the standard visual language
  the user is accustom to out-of-the-box

However, evaluate carefully what framework you need,
  you may have issues about:
   – performance (the UI may get slow)
   – stability, debuggability
   – customization problems (you may be forced in doing
     everything the framework-way)
   – your app may look like many others
CSS3
Device Themes

The presentation elements that will be
  required to mimic the platform aesthetic

  – it may be unique to each platform you plan to
    support
  – examples:
     • Sencha Touch (CSS)
     • JQueryMobile (CSS)
     • …
Core Themes
The presentation elements you use
  independently from the app and platform

  – Keep presentation essentials as a unique stylesheet
    that will serve as your core theme
  – They are the elements that should always be the
    same regardless of what platform you use
  – Examples:
     •   Resets
     •   Toolbar colors
     •   Layouts
     •   Typography
     •   …
App Themes
The presentation elements that are specific to
  your app

  – Basically, they are similar to a core theme, but they
    are specific to an app
  – Examples:
     •   Logos
     •   Toolbar colors
     •   Layouts
     •   Typography
     •   …
Roadmap

• Anatomy of a mobile web app
• Classes of Mobile web apps
• PhoneGap
Classes of Mobile Web Apps
A mobile web app will always be limited to the
  capabilities of the browser and device
  available

This environment cannot be assured at the time of
  development

The following classes of development can help to
  prioritize design and development effort
Class 1

It uses the latest innovations and capabilities present
  only in the iPhone (3GS and higher, iPod touch 4th
  Gen, iPad) and Android 4.0

Examples:
  Facebook for iPhone
  Flipboard for iPhone
Class 1
Advantages
• Best possible mobile experience
• Complex user interfaces, animations is possible
• Limited access to device features is possible
• The user experience can be very close, and in some
  cases on par with native iPhone apps
• Fixed headers and footers are possible with Javascript

Disadvantages
• They do not have backward compatibility and do
  not support other platforms
• Complex Javascript is required for data integration
  and is difficult to debug
Class 2

It supports high-end WebKit browsers with devices
            high-
  that have at least 1Ghz processors

It supports all iOS devices,
2.2+ Android devices, WP 7.5

Example:
  Instagram for Android 2.3
Class 2
Advantages
• Complex user interfaces are possible
• Support the majority of high-end smartphones on the
  marketplace
• Has limited backward compatibility

Disadvantages
• Use of animations are processor and battery intensive
   (Javascript-based animation needs to be used instead of
   CSS, or animations need to be omitted altogether)
• Cannot use fixed footers and headers
• Complex javascript can be required for data integration
   and is difficult to debug
Class 3

It has the highest degree of smartphone device
  compatibility,
  compatibility provides high quality user experience,
  as well as supporting higher and lower classes

It supports all iOS devices, all Android devices, WP
  BlackBerry Torch
Class 3
Advantages
• Supports the majority of devices, but not all
• Provides a quality user experience on more capable
  browsers, and degrades to lessor devices

Disadvantages
• Cannot support animations or screen transitions
• Cannot support fixed header or footer
• Limited javascript support
Class 4

It is designed with compatibility in mind, seeking to
  have the best possible user experience across the
  widest number of devices

 Any mobile web app looking to have the maximum
  cross platform support, should look no further
                   support
  than a Class 4 experience

It is more website than web app
Class 4

Advantages
• Support the largest number of handsets
• Is simple to design and develop
• Is simple to deploy

Disadvantages
• Requires significant Quality Assurance time
Universal App
It is an experience that is built for multiple device
  contexts,
  contexts but with a single source of content

Sometimes referred to as Responsive Web Design

Warning. In this case the user experience is driven
 by technological constraints, not user needs

Warning. This approach is something that has
 proven unsuccessful with most mobile platforms
 and applications
Universal App
Advantages
• Support mobile devices from a single code base
• Based in web standards
• Increases accessibility and Search Engine Optimization
  (SEO)
• Data integration is very simple

Disadvantages
• Must be designed for maximum device compatibility
  (Lower Common Denominator or LCD-based Design)
• Does not address the users context
• Most websites are not designed to be “universal” and
  need to be refactored from scratch
Browsers Classes

We can look at mobile experiences also w.r.t. the
  browsers capabilities
Roadmap

• Anatomy of a mobile web app
• Classes of Mobile web apps
• PhoneGap
PhoneGap

• Conceptual Overview
• Phonegap Development Guidelines
PhoneGap VS Cordova
Adobe/Nitobi donated the PhoneGap codebase to the
  Apache foundation
  – wider audience and contributors       Phonegap is a
  – Transparent governance               distribution of
     • Better documentation              Apache Cordova
  – Easier contributions for companies
     • Apache Licensing


  There was only one problem:
      trademark ambiguity
   CORDOVA
PhoneGap

                The UI layer is a web browser view
                   – 100% width
                   – 100% height

This is a web
  browser       Headless web browser
  instance         –   No URL bar
                   –   No chrome
                   –   No window decorations
                   –   No zooming
                   –   No text selection
PhoneGap

You develop your app using
• HTML
• CSS
• Javascript


You use the same web view of the native OS
   – iOS = UIWebView
   – Android = android.webkit.WebView
PhoneGap API
    Allows you to access native OS functionality using
      JavaScript

        you develop your app using web technologies and
       PhoneGap handles communication with the native OS




http://bit.ly/HBPPY5
PhoneGap API


                             API provider
WebView app
                             for Android


                             API provider
                               for iOS
                PhoneGap
                Javascript
                             API provider
                             for Windows
                                Phone

                             API provider
                                 for
                              Blacberry

              PhoneGap
PhoneGap API
PhoneGap API on iOS - general idea
1. the native web views have events/notifications whenever
   the url/address is changed
2. cordova.js parses messages into strings and puts them
   as the source URL inside a hidden IFrame element
3. This navigation action is intercepted on the native layer
   and converted to a native object, and the default
   navigation action is blocked
4. The string is parsed and a native code operation is
   performed
5. The native layer writes back to the web view layer by
   executing javascript strings
Recurrent App Architecture




    The app acts as a client for user interaction

    The app communicates with an application server to
      receive data

    The application server handles business logic and
      communicates with a back-end data repository
                            back-
http://bit.ly/HBPPY5
The App




It generally uses the single-page application model
                      single-
  • the application logic is inside a single HTML page
  • This page is never unloaded from memory
  • Data will be displayed by updating the HTML DOM
     • Ex. Using JQuery
  • data is retrieved from the application server using AJAX
The Application Server



It is a classical web server
   – server-side scripting language such as Java, .NET, PHP, etc…
     server-
   – communication can be based on:
      • standard HTTP requests for HTML content
      • REST-ful services (XML, JSON, etc.)
      • SOAP
   – It performs business logic and generally gets or pushes
                           logic,
     data from a separate data repository
The Back-end Repository




It may be:
   – a standard DB (usually deployed in the same machine of
     the application server)
   – an external API (see www.programmableweb.com)

   Both application server and back-end repository can be
     provided as a service   BaaS
Features Coverage
PhoneGap Plugins

 Sometimes PhoneGap is not enough as is for our purposes
 • Unsupported feature
 • heavyweight data processing is faster in native code
      – ex. images manipulation
 • background processing is better handled natively
      – ex. Files sync
 • complex business logic

      You need to develop a PhoneGap plugin
http://wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins
PhoneGap Plugins

Purpose.
Purpose. To expose a Phone native functionality to the
         browser

This is done by developing
   – a Custom Native Component
      Different for each platform
   – a Custom Javascript API
      It should be always the same
PhoneGap Plugins
PhoneGap

• Conceptual Overview
• Phonegap Development Guidelines
Project Structure
       If your app gets complex, you may
          prefer to use the structure
          presented in the Anatomy of a
          HTML5 web app part of this
          lecture
Page Structure

• Place all CSS stylesheets at the beginning
   – allows the page to render progressively
   – avoids flickering


• Place all JS scripts that do not affect page layout
  at the end
   – every script must be parsed before it can be used
   – they block parallel downloads
Images and Style

• First of all, avoid images when possible
   – you may use CSS gradiends, effects, etc.

• Try to avoid advanced CSS properties
   – for example, text-shadow and box-shadow, opacity

• Use touch events, instead of onClick
   – onClick may take up to 500ms to execute!
Text Management
• If the input is numeric, open up only the numeric keyboard
   – The same holds for email, websites, ecc.

   <input type="text" pattern="[0-9]*" value="numeric" />


• Disable user selection

   <style>
   *{
   -webkit-touch-callout: none;
   -webkit-user-select: none;
   }
   </style>
CSS Hardware Acceleration

When you use
    webkit-
   -webkit-transform
you have to use
   translate3d(x,y,z
   translate3d(x,y,z)
                 x,y,z)
instead of using
  translate(x,y)

In iOS, the last instruction is not HW-accelerated
Scrolling

I you want to scroll only a portion of your view, you
   should use this library

  http://cubiq.org/iscroll

Examples:
   – fixed header and footer, with scrollable content
   – scrollable sub-views with fixed description below
Frameworks
JQueryMobile, JQuery, Backbone, etc. are beautiful
  tools…

However they may impact the performance of your app

  Use a framework only when it is necessary
   – Don’t use JQuery only because of the $() syntax!

Solution
• build your own micro-framework
• cut out PhoneGap plugins you do not use
• use micro-frameworks (http://microjs.com)
References


http://www.tricedesigns.com/
http://pinchzoom.com/
http://hiediutley.com/




                               Chapters 11-12

More Related Content

What's hot (20)

PDF
Three WEM Dev Tricks
Gabriel Walt
 
PDF
Workshop HTML5+PhoneGap by Ivano Malavolta
Commit University
 
ODP
IBM ConnectED 2015 - AD302 - Responsive Application Development for XPages
beglee
 
PDF
Building cross platform web apps
ITEM
 
PDF
Optimizing HTML5 Sites with CQ5/WEM
Gabriel Walt
 
PDF
AD1542 Get Hands On With Bluemix
Martin Donnelly
 
PDF
Responsive Websites and Grid-Based Layouts by Gabriel Walt
AEM HUB
 
PDF
A Work Day Of A Web Developer
Edureka!
 
PDF
Crx 2.2 Deep-Dive
Gabriel Walt
 
PDF
[English version] JavaFX and Web Integration
Kazuchika Sekiya
 
PPTX
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Ryan Cuprak
 
PDF
[2015/2016] Apache Cordova
Ivano Malavolta
 
DOC
Alexander Zeng
Alex Zeng
 
PDF
Meetup. Technologies Intro for Non-Tech People
IT Arena
 
PDF
Hybrid application development
Engin Hatay
 
PPTX
Web Application Development Process presented by @Cygnismedia
Clark Davidson
 
PPT
Training on webwroks1
sumeettechno
 
PDF
A Gentle introduction to Web Development & Django
PRASANNAVENK
 
PPTX
Web programming and development - Introduction
Joel Briza
 
PDF
CQ 5.4 Deep-Dive
Gabriel Walt
 
Three WEM Dev Tricks
Gabriel Walt
 
Workshop HTML5+PhoneGap by Ivano Malavolta
Commit University
 
IBM ConnectED 2015 - AD302 - Responsive Application Development for XPages
beglee
 
Building cross platform web apps
ITEM
 
Optimizing HTML5 Sites with CQ5/WEM
Gabriel Walt
 
AD1542 Get Hands On With Bluemix
Martin Donnelly
 
Responsive Websites and Grid-Based Layouts by Gabriel Walt
AEM HUB
 
A Work Day Of A Web Developer
Edureka!
 
Crx 2.2 Deep-Dive
Gabriel Walt
 
[English version] JavaFX and Web Integration
Kazuchika Sekiya
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Ryan Cuprak
 
[2015/2016] Apache Cordova
Ivano Malavolta
 
Alexander Zeng
Alex Zeng
 
Meetup. Technologies Intro for Non-Tech People
IT Arena
 
Hybrid application development
Engin Hatay
 
Web Application Development Process presented by @Cygnismedia
Clark Davidson
 
Training on webwroks1
sumeettechno
 
A Gentle introduction to Web Development & Django
PRASANNAVENK
 
Web programming and development - Introduction
Joel Briza
 
CQ 5.4 Deep-Dive
Gabriel Walt
 

Viewers also liked (17)

PDF
Android session 1
Ahesanali Suthar
 
PPTX
Your First Adobe Flash Application for Android
Motorola Mobility - MOTODEV
 
PPTX
iOS Beginners Lesson 2
Calvin Cheng
 
PPT
Incorporating Web Services in Mobile Applications - Web 2.0 San Fran 2009
Aduci
 
PDF
OnConnectionLost: The life of an offline web application - JSUnconf 2015
Johannes Thönes
 
PDF
HTML5: friend or foe (to Flash)?
Remy Sharp
 
PPTX
Updated: NW.js - Desktop Apps with Javascript
Ralf Schwoebel
 
PDF
Offline Strategies for HTML5 Web Applications - oscon13
Stephan Hochdörfer
 
PPTX
Anatomy of mobile App development
Ralf Schwoebel
 
PPTX
From JavaEE to Android: Way in one click?
Sergii Zhuk
 
PPT
HTML5 Offline Web Application
Allan Huang
 
PDF
Offline strategies for HTML5 web applications - frOSCon8
Stephan Hochdörfer
 
PPTX
HTML5 AppCache: The Manifest
Ralf Schwoebel
 
PDF
Online / Offline
Peter Rozek
 
PDF
HTML5 Offline Web Applications (Silicon Valley User Group)
robinzimmermann
 
PPTX
20 iOS developer interview questions
Arc & Codementor
 
PPTX
Html5 Offline Applications
Sunny Sharma
 
Android session 1
Ahesanali Suthar
 
Your First Adobe Flash Application for Android
Motorola Mobility - MOTODEV
 
iOS Beginners Lesson 2
Calvin Cheng
 
Incorporating Web Services in Mobile Applications - Web 2.0 San Fran 2009
Aduci
 
OnConnectionLost: The life of an offline web application - JSUnconf 2015
Johannes Thönes
 
HTML5: friend or foe (to Flash)?
Remy Sharp
 
Updated: NW.js - Desktop Apps with Javascript
Ralf Schwoebel
 
Offline Strategies for HTML5 Web Applications - oscon13
Stephan Hochdörfer
 
Anatomy of mobile App development
Ralf Schwoebel
 
From JavaEE to Android: Way in one click?
Sergii Zhuk
 
HTML5 Offline Web Application
Allan Huang
 
Offline strategies for HTML5 web applications - frOSCon8
Stephan Hochdörfer
 
HTML5 AppCache: The Manifest
Ralf Schwoebel
 
Online / Offline
Peter Rozek
 
HTML5 Offline Web Applications (Silicon Valley User Group)
robinzimmermann
 
20 iOS developer interview questions
Arc & Codementor
 
Html5 Offline Applications
Sunny Sharma
 
Ad

Similar to Anatomy of an HTML 5 mobile web app (20)

KEY
Mobile ECM with JavaScript - JSE 2011
Nuxeo
 
PPTX
LATEST_TRENDS_IN_WEBSITE_DEVELOPMENT.pptx
chitrachauhan21
 
PPTX
Hybrid Mobile Development with Apache Cordova,AngularJs and ionic
Ermias Bayu
 
PPTX
Android quick talk
SenthilKumar Selvaraj
 
PPTX
Mobile web development
Moumie Soulemane
 
PPTX
Cross platform mobile application devlopment
Prabhat gangwar
 
PPTX
chapter2
Pon Tovave
 
PDF
Oracle and Mobile, From Design to Device; The tools that make it happen - Use...
Getting value from IoT, Integration and Data Analytics
 
PDF
AMIS UX Event 2014: Mobile ADF; From Design To Device; The Tools that make it...
Luc Bors
 
PDF
Cross Platform Mobile Development
Manesh Lad
 
PPTX
Developing Windows Phone 8 apps using PhoneGap
Amar Mesic
 
PPT
The Mobile Development Landscape
Ambert Ho
 
PDF
Building Effective and Rapid Applications with IBM MobileFirst Platform
Andrew Ferrier
 
PPTX
MobApp 01- Mobile Application Development Platform (1).pptx
MUHAMMADAHMAD173574
 
PPTX
Cross Platform Mobile Application Architecture
Derrick Bowen
 
PPTX
MobApp development 01 application platform.pptx
sanaiftikhar23
 
PPTX
Top 4 Cross Platform tools for Mobile App Development
techugo
 
PPTX
Introduction to hybrid application development
Kunjan Thakkar
 
ODP
Synapse india reviews on asp.net mobile application
saritasingh19866
 
PPTX
Cross-Platform Development using Angulr JS in Visual Studio
Mizanur Sarker
 
Mobile ECM with JavaScript - JSE 2011
Nuxeo
 
LATEST_TRENDS_IN_WEBSITE_DEVELOPMENT.pptx
chitrachauhan21
 
Hybrid Mobile Development with Apache Cordova,AngularJs and ionic
Ermias Bayu
 
Android quick talk
SenthilKumar Selvaraj
 
Mobile web development
Moumie Soulemane
 
Cross platform mobile application devlopment
Prabhat gangwar
 
chapter2
Pon Tovave
 
Oracle and Mobile, From Design to Device; The tools that make it happen - Use...
Getting value from IoT, Integration and Data Analytics
 
AMIS UX Event 2014: Mobile ADF; From Design To Device; The Tools that make it...
Luc Bors
 
Cross Platform Mobile Development
Manesh Lad
 
Developing Windows Phone 8 apps using PhoneGap
Amar Mesic
 
The Mobile Development Landscape
Ambert Ho
 
Building Effective and Rapid Applications with IBM MobileFirst Platform
Andrew Ferrier
 
MobApp 01- Mobile Application Development Platform (1).pptx
MUHAMMADAHMAD173574
 
Cross Platform Mobile Application Architecture
Derrick Bowen
 
MobApp development 01 application platform.pptx
sanaiftikhar23
 
Top 4 Cross Platform tools for Mobile App Development
techugo
 
Introduction to hybrid application development
Kunjan Thakkar
 
Synapse india reviews on asp.net mobile application
saritasingh19866
 
Cross-Platform Development using Angulr JS in Visual Studio
Mizanur Sarker
 
Ad

More from Ivano Malavolta (20)

PDF
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
PDF
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Ivano Malavolta
 
PDF
The H2020 experience
Ivano Malavolta
 
PDF
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
Ivano Malavolta
 
PDF
Software sustainability and Green IT
Ivano Malavolta
 
PDF
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Ivano Malavolta
 
PDF
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
Ivano Malavolta
 
PDF
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Ivano Malavolta
 
PDF
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Ivano Malavolta
 
PDF
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Ivano Malavolta
 
PDF
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Ivano Malavolta
 
PDF
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Ivano Malavolta
 
PDF
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Ivano Malavolta
 
PDF
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Ivano Malavolta
 
PDF
Modeling and abstraction, software development process [Software Design] [Com...
Ivano Malavolta
 
PDF
[2017/2018] Agile development
Ivano Malavolta
 
PDF
Reconstructing microservice-based architectures
Ivano Malavolta
 
PDF
[2017/2018] AADL - Architecture Analysis and Design Language
Ivano Malavolta
 
PDF
[2017/2018] Architectural languages
Ivano Malavolta
 
PDF
[2017/2018] Introduction to Software Architecture
Ivano Malavolta
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Ivano Malavolta
 
The H2020 experience
Ivano Malavolta
 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
Ivano Malavolta
 
Software sustainability and Green IT
Ivano Malavolta
 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Ivano Malavolta
 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
Ivano Malavolta
 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Ivano Malavolta
 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Ivano Malavolta
 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Ivano Malavolta
 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Ivano Malavolta
 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Ivano Malavolta
 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Ivano Malavolta
 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Ivano Malavolta
 
Modeling and abstraction, software development process [Software Design] [Com...
Ivano Malavolta
 
[2017/2018] Agile development
Ivano Malavolta
 
Reconstructing microservice-based architectures
Ivano Malavolta
 
[2017/2018] AADL - Architecture Analysis and Design Language
Ivano Malavolta
 
[2017/2018] Architectural languages
Ivano Malavolta
 
[2017/2018] Introduction to Software Architecture
Ivano Malavolta
 

Recently uploaded (20)

PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
community health nursing question paper 2.pdf
Prince kumar
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 

Anatomy of an HTML 5 mobile web app

  • 1. Mobile Web Apps Development Ivano Malavolta [email protected] http://www.di.univaq.it/malavolta
  • 2. Roadmap • Anatomy of a mobile web app • Classes of Mobile web apps • PhoneGap
  • 3. What is a Web App? An application built with web technologies that is accessible via a mobile browser and not exclusively through an app store The browser may be either the standard device browser or an embedded browser (Hybrid app)
  • 4. Anatomy of a Web App
  • 5. Anatomy of a mobile web app This is why HTML5 Mobile Apps are hard hard! In many cases you will need to create every part of this diagram If you don’t create it, you still need to test and debug each piece
  • 6. Setting up the Server As usual, it all starts with an http request Then you need: • Data • A device detection mechanism [optional] • The app itself
  • 7. Data Usually mobile apps do not talk directly with the database do not even think about JDBC, drivers, etc! They pass through an application server and communicate via: – standard HTTP requests for HTML content (eg PHP) – REST-full services (XML, JSON, etc.) – SOAP
  • 8. Data 2 • Data can be stored in any classical way: – Relational – Graph – Key-value – Document-based www.parse.com www.kinvey.com Latest trend: backend-as-a-service – Data storage, users management, security, big files storage, scalability, push notifications…
  • 9. BaaS 1. Developers build a visual model of their DB 2. The service generates APIs and client-side libraries(compatible with iOS, Android, Windows Phone 7, etc.) 3. The data produced/consumed in the app can be pushed/pulled to their DB – Communication is handled via REST or other protocols
  • 10. Server-side device detection All devices are unique you have to know on which device your app is running the app can adapt to the device capabilities Many techniques, the most used are: • Andy Moore’s browser detector – Works for PHP pages only • Javascript if (navigator.userAgent.match(/AppleWebKit/i) && navigator.userAgent.match(/Mobile/i)) { • External APIs window.location.replace('/path/to/iphone/site/'); – (DeviceAtlas, WURFL) @media screen and (max-width: 980px) { • CSS3 media queries }
  • 11. The HTML5 app Keep code very semantic Keep all the logic in Javascript Keep (most of) the presentation in CSS3 Remember that the user may go offline • Offline data storage, cache manifest Progressive Enhancement Write all your markup first without any CSS or JavascriptThe resulting markup should always be perfectly usable in its lowest form.
  • 12. Progressive Enhancement Key concept. Graceful degradation
  • 13. Progressive Enhancement Techniques • Always code your markup semantically – ensure that the page is always usable, even with no stylesheet • Have a device plan – Know which device classes you intend to support before you start to code • Have both your LCD and high-end device designs before high- you begin to code – Try to visualize a way to create both versions from one code base. • Test on different mobile devices from the beginning – your incremental work must display correctly in the intended devices • If you plan to add a desktop layer, always create the mobile version first
  • 14. Anatomy of a Web App
  • 15. Cache Manifest Problem. Problem Browsers have their own caches but they are unreliable and heterogenous The Application Cache allows a developer to specify which files the browser should cache and make available to offline users CACHE MANIFEST /main/features.js /main/settings/index.css http://files/images/scene.jpg http://files/images/world.jpg
  • 16. Cache Manifest A cache manifest gives you the following benefits: • Offline browsing – users can navigate your full site when they're offline • Speed – cached resources are local, and therefore load faster • Reduced server load – the browser will only download resources from the server that have changed This solution does not cover dynamic data caching In that case you can use javascript to get your data
  • 18. Hybrid Scripts These scripts bridge the gap between your core scripts and the device SDK – A necessary step if you plan to ship your HTML5 app in a native wrapper like a standard iOS UIWebView or Cordova – They may need to be distinct for each platform you plan to support • For example, the cordova.js file for Android is subtly different from the iOS’s one
  • 19. Core Scripts The common components of your app – they implement the internal logic that your app will require to assemble and render your HTML5 pages – they will be the same in every platform – examples of duties: • REST API access • Domain entities representation • … – they include also JS libraries like JQuery and other microframeworks
  • 20. Device Scripts They work to emulate native behaviors of the device with Javascript – these scripts may be unique to each platform you plan to support – examples: • JQueryMobile (JS part) • JQTouch (JS part) • SenchaTouch (JS part) • iui-js
  • 21. A note on Mobile Web Frameworks Frameworks like JQueryMobile, JQTouch are useful since they give you the standard visual language the user is accustom to out-of-the-box However, evaluate carefully what framework you need, you may have issues about: – performance (the UI may get slow) – stability, debuggability – customization problems (you may be forced in doing everything the framework-way) – your app may look like many others
  • 22. CSS3
  • 23. Device Themes The presentation elements that will be required to mimic the platform aesthetic – it may be unique to each platform you plan to support – examples: • Sencha Touch (CSS) • JQueryMobile (CSS) • …
  • 24. Core Themes The presentation elements you use independently from the app and platform – Keep presentation essentials as a unique stylesheet that will serve as your core theme – They are the elements that should always be the same regardless of what platform you use – Examples: • Resets • Toolbar colors • Layouts • Typography • …
  • 25. App Themes The presentation elements that are specific to your app – Basically, they are similar to a core theme, but they are specific to an app – Examples: • Logos • Toolbar colors • Layouts • Typography • …
  • 26. Roadmap • Anatomy of a mobile web app • Classes of Mobile web apps • PhoneGap
  • 27. Classes of Mobile Web Apps A mobile web app will always be limited to the capabilities of the browser and device available This environment cannot be assured at the time of development The following classes of development can help to prioritize design and development effort
  • 28. Class 1 It uses the latest innovations and capabilities present only in the iPhone (3GS and higher, iPod touch 4th Gen, iPad) and Android 4.0 Examples: Facebook for iPhone Flipboard for iPhone
  • 29. Class 1 Advantages • Best possible mobile experience • Complex user interfaces, animations is possible • Limited access to device features is possible • The user experience can be very close, and in some cases on par with native iPhone apps • Fixed headers and footers are possible with Javascript Disadvantages • They do not have backward compatibility and do not support other platforms • Complex Javascript is required for data integration and is difficult to debug
  • 30. Class 2 It supports high-end WebKit browsers with devices high- that have at least 1Ghz processors It supports all iOS devices, 2.2+ Android devices, WP 7.5 Example: Instagram for Android 2.3
  • 31. Class 2 Advantages • Complex user interfaces are possible • Support the majority of high-end smartphones on the marketplace • Has limited backward compatibility Disadvantages • Use of animations are processor and battery intensive (Javascript-based animation needs to be used instead of CSS, or animations need to be omitted altogether) • Cannot use fixed footers and headers • Complex javascript can be required for data integration and is difficult to debug
  • 32. Class 3 It has the highest degree of smartphone device compatibility, compatibility provides high quality user experience, as well as supporting higher and lower classes It supports all iOS devices, all Android devices, WP BlackBerry Torch
  • 33. Class 3 Advantages • Supports the majority of devices, but not all • Provides a quality user experience on more capable browsers, and degrades to lessor devices Disadvantages • Cannot support animations or screen transitions • Cannot support fixed header or footer • Limited javascript support
  • 34. Class 4 It is designed with compatibility in mind, seeking to have the best possible user experience across the widest number of devices Any mobile web app looking to have the maximum cross platform support, should look no further support than a Class 4 experience It is more website than web app
  • 35. Class 4 Advantages • Support the largest number of handsets • Is simple to design and develop • Is simple to deploy Disadvantages • Requires significant Quality Assurance time
  • 36. Universal App It is an experience that is built for multiple device contexts, contexts but with a single source of content Sometimes referred to as Responsive Web Design Warning. In this case the user experience is driven by technological constraints, not user needs Warning. This approach is something that has proven unsuccessful with most mobile platforms and applications
  • 37. Universal App Advantages • Support mobile devices from a single code base • Based in web standards • Increases accessibility and Search Engine Optimization (SEO) • Data integration is very simple Disadvantages • Must be designed for maximum device compatibility (Lower Common Denominator or LCD-based Design) • Does not address the users context • Most websites are not designed to be “universal” and need to be refactored from scratch
  • 38. Browsers Classes We can look at mobile experiences also w.r.t. the browsers capabilities
  • 39. Roadmap • Anatomy of a mobile web app • Classes of Mobile web apps • PhoneGap
  • 40. PhoneGap • Conceptual Overview • Phonegap Development Guidelines
  • 41. PhoneGap VS Cordova Adobe/Nitobi donated the PhoneGap codebase to the Apache foundation – wider audience and contributors Phonegap is a – Transparent governance distribution of • Better documentation Apache Cordova – Easier contributions for companies • Apache Licensing There was only one problem: trademark ambiguity CORDOVA
  • 42. PhoneGap The UI layer is a web browser view – 100% width – 100% height This is a web browser Headless web browser instance – No URL bar – No chrome – No window decorations – No zooming – No text selection
  • 43. PhoneGap You develop your app using • HTML • CSS • Javascript You use the same web view of the native OS – iOS = UIWebView – Android = android.webkit.WebView
  • 44. PhoneGap API Allows you to access native OS functionality using JavaScript you develop your app using web technologies and PhoneGap handles communication with the native OS http://bit.ly/HBPPY5
  • 45. PhoneGap API API provider WebView app for Android API provider for iOS PhoneGap Javascript API provider for Windows Phone API provider for Blacberry PhoneGap
  • 47. PhoneGap API on iOS - general idea 1. the native web views have events/notifications whenever the url/address is changed 2. cordova.js parses messages into strings and puts them as the source URL inside a hidden IFrame element 3. This navigation action is intercepted on the native layer and converted to a native object, and the default navigation action is blocked 4. The string is parsed and a native code operation is performed 5. The native layer writes back to the web view layer by executing javascript strings
  • 48. Recurrent App Architecture The app acts as a client for user interaction The app communicates with an application server to receive data The application server handles business logic and communicates with a back-end data repository back- http://bit.ly/HBPPY5
  • 49. The App It generally uses the single-page application model single- • the application logic is inside a single HTML page • This page is never unloaded from memory • Data will be displayed by updating the HTML DOM • Ex. Using JQuery • data is retrieved from the application server using AJAX
  • 50. The Application Server It is a classical web server – server-side scripting language such as Java, .NET, PHP, etc… server- – communication can be based on: • standard HTTP requests for HTML content • REST-ful services (XML, JSON, etc.) • SOAP – It performs business logic and generally gets or pushes logic, data from a separate data repository
  • 51. The Back-end Repository It may be: – a standard DB (usually deployed in the same machine of the application server) – an external API (see www.programmableweb.com) Both application server and back-end repository can be provided as a service BaaS
  • 53. PhoneGap Plugins Sometimes PhoneGap is not enough as is for our purposes • Unsupported feature • heavyweight data processing is faster in native code – ex. images manipulation • background processing is better handled natively – ex. Files sync • complex business logic You need to develop a PhoneGap plugin http://wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins
  • 54. PhoneGap Plugins Purpose. Purpose. To expose a Phone native functionality to the browser This is done by developing – a Custom Native Component Different for each platform – a Custom Javascript API It should be always the same
  • 56. PhoneGap • Conceptual Overview • Phonegap Development Guidelines
  • 57. Project Structure If your app gets complex, you may prefer to use the structure presented in the Anatomy of a HTML5 web app part of this lecture
  • 58. Page Structure • Place all CSS stylesheets at the beginning – allows the page to render progressively – avoids flickering • Place all JS scripts that do not affect page layout at the end – every script must be parsed before it can be used – they block parallel downloads
  • 59. Images and Style • First of all, avoid images when possible – you may use CSS gradiends, effects, etc. • Try to avoid advanced CSS properties – for example, text-shadow and box-shadow, opacity • Use touch events, instead of onClick – onClick may take up to 500ms to execute!
  • 60. Text Management • If the input is numeric, open up only the numeric keyboard – The same holds for email, websites, ecc. <input type="text" pattern="[0-9]*" value="numeric" /> • Disable user selection <style> *{ -webkit-touch-callout: none; -webkit-user-select: none; } </style>
  • 61. CSS Hardware Acceleration When you use webkit- -webkit-transform you have to use translate3d(x,y,z translate3d(x,y,z) x,y,z) instead of using translate(x,y) In iOS, the last instruction is not HW-accelerated
  • 62. Scrolling I you want to scroll only a portion of your view, you should use this library http://cubiq.org/iscroll Examples: – fixed header and footer, with scrollable content – scrollable sub-views with fixed description below
  • 63. Frameworks JQueryMobile, JQuery, Backbone, etc. are beautiful tools… However they may impact the performance of your app Use a framework only when it is necessary – Don’t use JQuery only because of the $() syntax! Solution • build your own micro-framework • cut out PhoneGap plugins you do not use • use micro-frameworks (http://microjs.com)