Bridging the gap between
mobile platforms
Discover the new framework ‘Calatrava’ for building Hybrid apps

Anand Agrawal
About me
▪ ThoughtWorks, Singapore

▪ Full stack engineer
▪ Co-founder of ideaboardz

anandagrawal84
@anand_agrawal
Tech
And I …
What’s in it for you?
▪ Native v/s Web v/s Cross platform

▪ How to get the best out of cross platform
▪ How Calatrava helps to get the best of both worlds
▪ When (not) to go hybrid
Where mobile app market is going?
▪ Opens up a new channel

▪ Mobile first strategy to tap into the segment
Where to start?
Devices
Challenges
▪ Native?

▪ Mobile web?
Trade offs
Web App

Affordability
Native apps

User Experience
How about off the shelf cross platform?

Lots of promises
▪ Code reusability
▪ Faster and easier development
▪ Easy to test
How about off the shelf cross platform?

BUT…
▪ May just mimic the native control’s look
▪ May limit the control on the native controls
▪ Dependency on 3rd party for new features

Hence, Sub-optimal User Experience.
What are typical app components?
▪ UI

▪ Application Logic (Presentation/Business logic/Navigation)
▪ Local Storage
▪ Web services
What are typical app components?

Local Store

UI

Application
Logic
Web services
What are the reusable components?

UI

iPhone
Android

Web

Client logic

Back-end
Calatrava

Available at: http://calatrava.github.com/
Credits: Giles Alexander
Overview of calatrava
SHELL (haml, css, javascript,
native where necessary)
[page objects, layouts]

N
A
T
I
V
E
C
O
D
E

B
R
I
D
G
E

S
H
A
R
E
D

KERNEL (javascript)
[Controllers, models,
repositories]

L
O
G
I
C
BRIDGE (javascript)
[shared native objects]
Native where required
Shared everywhere
else

Trade offs

Hybrid App

Web App

Affordability
Native apps

User Experience
Basic structure of a calatrava project
 kernel
 app
 plugins
 spec
 shell
 pages
 assets
 lib
 droid
 ios
 web
Handpicking native where required
Sample flow
Lookup for
convention based
controller

Click
Trigger
event
Page Object

Bridge

Invoke render
with data
Results shown

JS evaluator
Kernel

Page render called with
appropriate data
Sample flow
Click

Page Object

JS evaluator

Bridge

Trigger
event

Lookup for
convention based
controller

Kernel

Ajax call to fetch results
fetch
results

Bridge

Response

Invoke render
with data
Page Object

Results shown

Bridge

Page render called with
appropriate data

Kernel

JS evaluator
DEMO
Code at
https://github.com/priyaaank/bloodtorrent
Plugins
▪ Mechanism to use native features cross platform.

▪ Registered with calatrava
▪ Used based on convention based
How is it different from cross platform?
▪ No restriction to APIs / features exposed by framework

▪ Easier extensibility
▪ Easy to plugin native components wherever required
Tech stack
▪ Coffee-script

▪ Haml
▪ Sass
▪ Java

▪ Objective C
▪ Jasmine
▪ Cucumber

▪ Rake

}
}
}
}

Kernel + Shared HTML UI

Native UI, plugin implementations

Testing
Build
Strengths
Developer’s perspective:

Business perspective:

 Structure to quickly build
features, share code
 Testability
 Needs stronger javascript
skills rather than objective c /
java etc

 Hook into existing native app
 Free mobile web app
 Ease of adding new feature
 Mobile as a channel, less feature
parity
 Time to market same for all
platforms
Platforms supported
When not to use calatrava

UI

AL
Services

UI

AL
Shared
logic
Roadmap…
▪ Calatrava is evolving

▪ Plugins are being developed
▪ Generating controllers, pages for new features (like rails generator)
▪ Anything that you could think of? 
Frameworks implementing Hybrid approach
▪ Kirinjs

▪ Cordova
References
▪ http://martinfowler.com/articles/multiMobile/

▪ http://martinfowler.com/articles/mobileImplStrategy.html
▪ https://github.com/calatrava/calatrava/wiki
▪ https://github.com/priyaaank/bloodtorrent

▪ http://overwatering.org/blog/2012/10/announcing-calatrava/
▪ https://speakerdeck.com/priyaaank/cross-platform-development-bridgingthe-gap
Questions??

Bridging the gap between mobile platforms - jsconf asia

Editor's Notes

  • #8 Cross platform issues: In certain cases the access to hardware components and platform features is dependent on the support from the toolkit. Additionally, fragmentation can be a beast to tackle in these cases as a developer may have only limited access to underlying native platform. PureMobile web issues:impedance to navigate an app in browser. Additionally, having an app in an app store adds a lot of branding to a business, which is sorely missed in this case. However mobile web is emerging as a great add-on for a business with apps; since it is handy for tactical queries while app can serve as a rich engagement point for a customer.
  • #11 Cross platform issues: In certain cases the access to hardware components and platform features is dependent on the support from the toolkit. Additionally, fragmentation can be a beast to tackle in these cases as a developer may have only limited access to underlying native platform. PureMobile web issues:impedance to navigate an app in browser. Additionally, having an app in an app store adds a lot of branding to a business, which is sorely missed in this case. However mobile web is emerging as a great add-on for a business with apps; since it is handy for tactical queries while app can serve as a rich engagement point for a customer.
  • #18 Calatrava is one such implementation of the hybrid approach that we just spoke about. It was developed by a few ThoughtWorkers and then used for multiple client projects.
  • #19 an opinionated architecture, which drives how code should be organized and howlayers should be loosely coupledA Calatrava app is broken down into features. These features are driven by one or more controllers. Each feature has a start function and a set of pages.From your Calatrava app you can build an iOS app, an Android app and a Mobile Web app. The shared controlling logic is called thekernel. If you are building a shared HTML UI, that is called the shell.Connecting your kernel code to the UI of your app and any native device features you are using is the bridge. This is the main piece that the Calatrava framework provides.
  • #20 Cross platform issues: In certain cases the access to hardware components and platform features is dependent on the support from the toolkit. Additionally, fragmentation can be a beast to tackle in these cases as a developer may have only limited access to underlying native platform. PureMobile web issues:impedance to navigate an app in browser. Additionally, having an app in an app store adds a lot of branding to a business, which is sorely missed in this case. However mobile web is emerging as a great add-on for a business with apps; since it is handy for tactical queries while app can serve as a rich engagement point for a customer.
  • #24 Any event by the end user of the app is first received by the page objects. They in turn have functions bound to them which get triggered.
  • #30 Cover your bases strategy: In this case, since the customer is the focus and not the platform, it is imperative to have a presence on multiple platforms, to widen the outreach to customersDeveloper’s perspective:No additional Framework Density
  • #32   product vs channel  Simple core logic  Needs heavy UI and almost all native components