SlideShare une entreprise Scribd logo
1  sur  37
Enterprise HTML5 Patterns
AKQA Anorak: June 2013
James Turner
Architect
james.turner@caplin.com
What am I talking about ?
What is “enterprise” ?
We have replaced, functionally large diverse,
desktop thick client trading systems with
with “single page” web applications.
How we did it ?
Architectural patterns and technologies used.
Good news for web-devs
http://addyosmani.com/resources/essentialjsdesignpatterns/book/
Move desktop trading to browsers (1)
Move desktop trading to browsers (2)
Business Drivers
▶  Increase trade volumes
–  Integrate pre-trade information
▶  Reduce cost of sale
▶  Direct channel to customer
–  Enhanced user experience
–  Branding
▶  Zero deployment: URL to customer
–  Reduced onboarding time + cost
–  Reduced maintenance
Reverse barrier convertibles
“10 minutes rather than up to 2 hours on phone with a sales trader”
Technology Drivers
▶  Mobile
–  Cross device support
▶  Improved browser ecosystem
–  Browser performance debugging much better
–  Fewer browser differences
–  Vibrant open source community
▶  HTML5
–  Local storage, web-sockets, CSS3 …
▶  Death of alternatives
–  Flash/Flex, Silverlight
Characterizing “enterprise”
HTML5 applications
More than
“A lot of code”
The application
▶  “A lot of code” 250k + LOC
▶  Single page “thick client” applications
–  Different assumptions
–  Runs all day, memory leaks
–  UX of lazy loading
▶  Consistency: theming/skinning/UX
▶  Internationalisation
▶  Streaming financial tradable prices
–  Screen update performance
–  Trade on “displayed price”
–  Graceful degradation
–  Throttling, scheduling
Multiple teams
▶  10-100’s of developers
▶  Multiple independent teams
–  Independent versioned deployment lifecycle
–  Share some code
–  Rest Isolated
▶  Banks are notoriously silo’d by asset class
Different cultures
▶  UX/Graphic designers
▶  Web Developers (jQuery anyone)
▶  Product Owners, Product Managers,
Business Analysts
▶  Server-side developers
–  Decouple dependencies
▶  QA’s (programming QA’s)
▶  Operations
–  Deploy artifacts
–  Same artifacts for TEST/UAT/PROD
–  Directory services
Coolness
12
Armageddon
“Monday morning: Ooops my weekend
check-in just changed the background
colour of the entire application”
How we did it:
1.  Components
2.  Code organization
3.  App structure + patterns
4.  Testing
Components
Split by feature, not technology
16
CSS
HTML
JS
config
i18n
images
tests
CSS
HTML
JS
config
tests
images
i18n
CSS
HTML
JS
config
tests
images
i18n
CSS
HTML
JS
config
tests
images
i18n
CSS
HTML
JS
config
tests
images
i18n
▶  Independent business feature
▶  No direct dependencies to other components
▶  Minimal public interface
–  Event bus (publish/subscribe)
–  Component API
▶  Code sharing mechanism
–  Libraries
–  Modules
▶  Conforms to conventions/name-spacing
▶  Can be pre-built
What is a component
Contents
Deploy
Deploy
Workbench
Instant reload imperative for developer productivity
Conways’Law
“Organizations which design systems ...
are constrained to produce designs which
are copies of the communication structures
of these organizations"
Code Structure
APPLICATION
MODULE A
COMPONENT 1
COMPONENT 2
MODULE B
COMPONENT 3
COMPONENT 4
ASPECTS
MOBILE
DESKTOP
LIBRARIES
INC THIRD-PARTY
Inheritance + Name-spacing
▶  CSS
–  App defines common “theme”
–  Components inherit theme
–  Override with more specific CSS rules
•  Need name-spacing
–  Use CSS pre-processor (e.g. LESS,SASS)
–  Define an ontology
▶  XML/HTML
–  Name-spacing for unique ID’s
JavaScript Coding
▶  Fine grained OO
–  We average about 100 LOC per class
▶  One class per file
▶  Design patterns
▶  SOLID (Uncle Bob)
▶  Coding standards
–  Inheritance
–  JsHint
▶  Common code in libraries
▶  Interpreted: so testing is more important
▶  JsLint /coverage
Bundling
dev-server
bundling
(enforcement)
APPLICATIO
N
BLADESET A
BLADE 1
BLADE 2
BLADESET B
BLADE 1
BLADE 2
ASPECTS
MOBILE
DESKTOP
ProjectsEclipse
IntelliJ
Sublime
NetBeans
Vi/Emacs
……..
IDE of choice
running app
J2EE
ServerWAR
deploy
ZIP CDN
Directory
services
App Structure
CLIENT SERVER
TraderApp
Layout
Managercomponent
component
component
component
service
service
service
service
event
bus
HTML Bundle
CSS Bundle
I18n Bundle
XML Bundle
JavaScript Bundle
Application
Server
JavaScript Interfaces
▶  Defines the contract a component should
conform to.
–  A set of method signatures
▶  Multiple classes “implement” the same interface
▶  Provides a hook for documentation
▶  Hook for IDE tooling
Service Registry
var service = new caplin.XhrXmlResourceServiceProvider(this.sXmlBundleUrl);
caplin.ServiceRegistry.register("caplin.XmlResourceService”, service);
var xmlResourceService = caplin.ServiceRegistry.getService("caplin.XmlResourceService");
var tradeModelNode = xmlResourceService.getXmlDocument("tradeModels");
Registration:
Usage:
Event Hub
▶  Publish/Subscribe inside the browser
–  Many to many (or none)
▶  Defined by an interface (contract)
▶  Methods cannot return anything
▶  Classic example: logging
▶  Nice Article:
http://blog.caplin.com/2012/12/07/event-hub-pubsub-in-the-browser/
Component Interface
▶  Used by layout managers to manage GUI
components
▶  Defines GUI lifecycle events
–  getElement(),
–  onOpen(),
–  onResize(),
–  onSerialize() etc.
MVVM Pattern
ViewRendering to screen
Domain
Model
business semantic method callslistens
Reused across many
screens
View
Model
gestureslistens
Logical representation
of the view
(an adaptor)
<button class=‘..’
data-bind=‘click:buttonClicked’>
Execute Trade
</button>
HTML template with bindings
$(button).click(function(){
vm.buttonClicked()
});
jQuery Control
Our HTML5 MVVM
Domain
Model
executeTrade()complete()
Message
Service
send()receive()
View
Model
buttonClicked()tradeButtonEnabled
No DOM Access
XmlHttpRequest
binding framework
e.g. KnockoutJs
The Testing Triangle
Functional
GUI testing
ITs
Unit Tests
manual
Acceptance
Tests
Performance
Tests
Integration Tests
- Selenium -
(automated
manual tests)
Unit Tests
manual
Performance
Tests
Test by contract
Browser
GUI
logicaluseractions
servicecalls
Given “form is opened”
When “user executes trade”
Then “trade message sent to server”
Server
Code
RESTfulAPI
Given “server is started”
When “trade message received”
Then “money is sent somewhere”
Test by contract
MVVM and services
View
Model
Domain
Model
complete()
View
execute()
Given …
When …
Then …
Fixtures
executeTrade()
tradeButtonEnabled
Message
Service
Stub
send()
receive()
Test Infrastructure
js-test-driver
Server
Bundlers
JavaScript
Dependencies
jsTestDriver.conf
plugin:
- name: "BundleInjector"
jar: …/js-jstd-plugin.jar
module: com.caplin.jstd.BundlerPlugin
load:
- bundles/i18n/en_i18n.bundle
- bundles/js/js.bundle
test:
- tests/**.js
serve:
- bundles/html.bundle
- bundles/xml.bundle
Plugin
JavaScript
Test Files
HTML/XML
Dependencies
In summary:
divide + conquer
Natural fine grained OO coding
Components
Common code in libraries
Split GUI Code into
Dom interactions
View Model
Domain Model
Services for stubbing
GWT + Test by contract
We will soon be open-sourcing
our implementation of this
architecture
www.bladerunnerjs.org

Contenu connexe

Tendances

Tendances (20)

Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk ServerUsing ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
 
Delivering big content at NBC News with RavenDB
Delivering big content at NBC News with RavenDBDelivering big content at NBC News with RavenDB
Delivering big content at NBC News with RavenDB
 
Change data capture with MongoDB and Kafka.
Change data capture with MongoDB and Kafka.Change data capture with MongoDB and Kafka.
Change data capture with MongoDB and Kafka.
 
How Kafka and MemSQL Became the Dynamic Duo (Sarung Tripathi, MemSQL) Kafka S...
How Kafka and MemSQL Became the Dynamic Duo (Sarung Tripathi, MemSQL) Kafka S...How Kafka and MemSQL Became the Dynamic Duo (Sarung Tripathi, MemSQL) Kafka S...
How Kafka and MemSQL Became the Dynamic Duo (Sarung Tripathi, MemSQL) Kafka S...
 
Real-time Data Streaming from Oracle to Apache Kafka
Real-time Data Streaming from Oracle to Apache Kafka Real-time Data Streaming from Oracle to Apache Kafka
Real-time Data Streaming from Oracle to Apache Kafka
 
Low-latency data applications with Kafka and Agg indexes | Tino Tereshko, Fir...
Low-latency data applications with Kafka and Agg indexes | Tino Tereshko, Fir...Low-latency data applications with Kafka and Agg indexes | Tino Tereshko, Fir...
Low-latency data applications with Kafka and Agg indexes | Tino Tereshko, Fir...
 
Event sourcing Live 2021: Streaming App Changes to Event Store
Event sourcing Live 2021: Streaming App Changes to Event StoreEvent sourcing Live 2021: Streaming App Changes to Event Store
Event sourcing Live 2021: Streaming App Changes to Event Store
 
In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014
 
#GeodeSummit - Redis to Geode Adaptor
#GeodeSummit - Redis to Geode Adaptor#GeodeSummit - Redis to Geode Adaptor
#GeodeSummit - Redis to Geode Adaptor
 
Bootstrap SaaS startup using Open Source Tools
Bootstrap SaaS startup using Open Source ToolsBootstrap SaaS startup using Open Source Tools
Bootstrap SaaS startup using Open Source Tools
 
12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment
 
Spark Compute as a Service at Paypal with Prabhu Kasinathan
Spark Compute as a Service at Paypal with Prabhu KasinathanSpark Compute as a Service at Paypal with Prabhu Kasinathan
Spark Compute as a Service at Paypal with Prabhu Kasinathan
 
Bitsy graph database
Bitsy graph databaseBitsy graph database
Bitsy graph database
 
Hybrid Apache Spark Architecture with YARN and Kubernetes
Hybrid Apache Spark Architecture with YARN and KubernetesHybrid Apache Spark Architecture with YARN and Kubernetes
Hybrid Apache Spark Architecture with YARN and Kubernetes
 
Introducing Kubernetes
Introducing Kubernetes Introducing Kubernetes
Introducing Kubernetes
 
Apache kafka-a distributed streaming platform
Apache kafka-a distributed streaming platformApache kafka-a distributed streaming platform
Apache kafka-a distributed streaming platform
 
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
 
Akka Streams And Kafka Streams: Where Microservices Meet Fast Data
Akka Streams And Kafka Streams: Where Microservices Meet Fast DataAkka Streams And Kafka Streams: Where Microservices Meet Fast Data
Akka Streams And Kafka Streams: Where Microservices Meet Fast Data
 
Whirlpools in the Stream with Jayesh Lalwani
 Whirlpools in the Stream with Jayesh Lalwani Whirlpools in the Stream with Jayesh Lalwani
Whirlpools in the Stream with Jayesh Lalwani
 
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
 

En vedette

En vedette (13)

Patterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPatterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 apps
 
Praise explosion/ marathon de louange
Praise explosion/ marathon de louangePraise explosion/ marathon de louange
Praise explosion/ marathon de louange
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Metodo d inferencia estadistica
Metodo d inferencia estadisticaMetodo d inferencia estadistica
Metodo d inferencia estadistica
 
Comercio internacional
Comercio internacionalComercio internacional
Comercio internacional
 
Algolia's Fury Road to a Worldwide API - Take Off Conference 2016
Algolia's Fury Road to a Worldwide API - Take Off Conference 2016Algolia's Fury Road to a Worldwide API - Take Off Conference 2016
Algolia's Fury Road to a Worldwide API - Take Off Conference 2016
 
Chronic pain: Role of tricyclic antidepressants, dolsulepin
Chronic pain: Role of tricyclic antidepressants, dolsulepinChronic pain: Role of tricyclic antidepressants, dolsulepin
Chronic pain: Role of tricyclic antidepressants, dolsulepin
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Cecilia jaya larraga investigacion
Cecilia jaya larraga investigacionCecilia jaya larraga investigacion
Cecilia jaya larraga investigacion
 
Las teorías del liderazgo
Las teorías del liderazgoLas teorías del liderazgo
Las teorías del liderazgo
 
Matemática proyecto de aula
Matemática proyecto de aulaMatemática proyecto de aula
Matemática proyecto de aula
 
Burning tongue webinar with Dr.Susan Sklar
Burning tongue webinar with Dr.Susan SklarBurning tongue webinar with Dr.Susan Sklar
Burning tongue webinar with Dr.Susan Sklar
 
WINK Calgary presents "Learn to love your money - basics of investing"
WINK Calgary presents "Learn to love your money - basics of investing"WINK Calgary presents "Learn to love your money - basics of investing"
WINK Calgary presents "Learn to love your money - basics of investing"
 

Similaire à James Turner (Caplin) - Enterprise HTML5 Patterns

Developing Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris RichardsonDeveloping Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris Richardson
JAXLondon2014
 
Azure Overview Csco
Azure Overview CscoAzure Overview Csco
Azure Overview Csco
rajramab
 
WinJS at NYC Code Camp 2012
WinJS at NYC Code Camp 2012WinJS at NYC Code Camp 2012
WinJS at NYC Code Camp 2012
Dmitri Artamonov
 
Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...
Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...
Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...
mfrancis
 
Windowsazureplatform Overviewlatest
Windowsazureplatform OverviewlatestWindowsazureplatform Overviewlatest
Windowsazureplatform Overviewlatest
rajramab
 

Similaire à James Turner (Caplin) - Enterprise HTML5 Patterns (20)

An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web Components
 
Architecting Microservices in .Net
Architecting Microservices in .NetArchitecting Microservices in .Net
Architecting Microservices in .Net
 
#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture#JaxLondon keynote: Developing applications with a microservice architecture
#JaxLondon keynote: Developing applications with a microservice architecture
 
Developing Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris RichardsonDeveloping Applications with a Micro Service Architecture - Chris Richardson
Developing Applications with a Micro Service Architecture - Chris Richardson
 
Developing applications with a microservice architecture (SVforum, microservi...
Developing applications with a microservice architecture (SVforum, microservi...Developing applications with a microservice architecture (SVforum, microservi...
Developing applications with a microservice architecture (SVforum, microservi...
 
Developing applications with a microservice architecture (svcc)
Developing applications with a microservice architecture (svcc)Developing applications with a microservice architecture (svcc)
Developing applications with a microservice architecture (svcc)
 
Power
PowerPower
Power
 
7+ Years.Net Resume
7+ Years.Net Resume7+ Years.Net Resume
7+ Years.Net Resume
 
Azure Overview Csco
Azure Overview CscoAzure Overview Csco
Azure Overview Csco
 
ASP.NET Core For The Agile Enterprise
ASP.NET Core For The Agile EnterpriseASP.NET Core For The Agile Enterprise
ASP.NET Core For The Agile Enterprise
 
cross-platform-assets-based-front-end-architecture
cross-platform-assets-based-front-end-architecturecross-platform-assets-based-front-end-architecture
cross-platform-assets-based-front-end-architecture
 
xRM - as an Evolution of CRM
xRM - as an Evolution of CRMxRM - as an Evolution of CRM
xRM - as an Evolution of CRM
 
WinJS at NYC Code Camp 2012
WinJS at NYC Code Camp 2012WinJS at NYC Code Camp 2012
WinJS at NYC Code Camp 2012
 
Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...
Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...
Keynote - The Benefits of an Open Service Oriented Architecture in the Enterpr...
 
Windows Azure Platform + PHP - Jonathan Wong
Windows Azure Platform + PHP - Jonathan WongWindows Azure Platform + PHP - Jonathan Wong
Windows Azure Platform + PHP - Jonathan Wong
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Serverless Single Page Apps with React and Redux at ItCamp 2017
Serverless Single Page Apps with React and Redux at ItCamp 2017Serverless Single Page Apps with React and Redux at ItCamp 2017
Serverless Single Page Apps with React and Redux at ItCamp 2017
 
Windowsazureplatform Overviewlatest
Windowsazureplatform OverviewlatestWindowsazureplatform Overviewlatest
Windowsazureplatform Overviewlatest
 
Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

James Turner (Caplin) - Enterprise HTML5 Patterns

  • 1. Enterprise HTML5 Patterns AKQA Anorak: June 2013 James Turner Architect james.turner@caplin.com
  • 2. What am I talking about ? What is “enterprise” ? We have replaced, functionally large diverse, desktop thick client trading systems with with “single page” web applications. How we did it ? Architectural patterns and technologies used. Good news for web-devs http://addyosmani.com/resources/essentialjsdesignpatterns/book/
  • 3. Move desktop trading to browsers (1)
  • 4. Move desktop trading to browsers (2)
  • 5. Business Drivers ▶  Increase trade volumes –  Integrate pre-trade information ▶  Reduce cost of sale ▶  Direct channel to customer –  Enhanced user experience –  Branding ▶  Zero deployment: URL to customer –  Reduced onboarding time + cost –  Reduced maintenance
  • 6. Reverse barrier convertibles “10 minutes rather than up to 2 hours on phone with a sales trader”
  • 7. Technology Drivers ▶  Mobile –  Cross device support ▶  Improved browser ecosystem –  Browser performance debugging much better –  Fewer browser differences –  Vibrant open source community ▶  HTML5 –  Local storage, web-sockets, CSS3 … ▶  Death of alternatives –  Flash/Flex, Silverlight
  • 9. The application ▶  “A lot of code” 250k + LOC ▶  Single page “thick client” applications –  Different assumptions –  Runs all day, memory leaks –  UX of lazy loading ▶  Consistency: theming/skinning/UX ▶  Internationalisation ▶  Streaming financial tradable prices –  Screen update performance –  Trade on “displayed price” –  Graceful degradation –  Throttling, scheduling
  • 10. Multiple teams ▶  10-100’s of developers ▶  Multiple independent teams –  Independent versioned deployment lifecycle –  Share some code –  Rest Isolated ▶  Banks are notoriously silo’d by asset class
  • 11. Different cultures ▶  UX/Graphic designers ▶  Web Developers (jQuery anyone) ▶  Product Owners, Product Managers, Business Analysts ▶  Server-side developers –  Decouple dependencies ▶  QA’s (programming QA’s) ▶  Operations –  Deploy artifacts –  Same artifacts for TEST/UAT/PROD –  Directory services Coolness
  • 12. 12
  • 13. Armageddon “Monday morning: Ooops my weekend check-in just changed the background colour of the entire application”
  • 14. How we did it: 1.  Components 2.  Code organization 3.  App structure + patterns 4.  Testing
  • 16. Split by feature, not technology 16 CSS HTML JS config i18n images tests CSS HTML JS config tests images i18n CSS HTML JS config tests images i18n CSS HTML JS config tests images i18n CSS HTML JS config tests images i18n
  • 17. ▶  Independent business feature ▶  No direct dependencies to other components ▶  Minimal public interface –  Event bus (publish/subscribe) –  Component API ▶  Code sharing mechanism –  Libraries –  Modules ▶  Conforms to conventions/name-spacing ▶  Can be pre-built What is a component
  • 19. Workbench Instant reload imperative for developer productivity
  • 20. Conways’Law “Organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations"
  • 21. Code Structure APPLICATION MODULE A COMPONENT 1 COMPONENT 2 MODULE B COMPONENT 3 COMPONENT 4 ASPECTS MOBILE DESKTOP LIBRARIES INC THIRD-PARTY
  • 22. Inheritance + Name-spacing ▶  CSS –  App defines common “theme” –  Components inherit theme –  Override with more specific CSS rules •  Need name-spacing –  Use CSS pre-processor (e.g. LESS,SASS) –  Define an ontology ▶  XML/HTML –  Name-spacing for unique ID’s
  • 23. JavaScript Coding ▶  Fine grained OO –  We average about 100 LOC per class ▶  One class per file ▶  Design patterns ▶  SOLID (Uncle Bob) ▶  Coding standards –  Inheritance –  JsHint ▶  Common code in libraries ▶  Interpreted: so testing is more important ▶  JsLint /coverage
  • 24. Bundling dev-server bundling (enforcement) APPLICATIO N BLADESET A BLADE 1 BLADE 2 BLADESET B BLADE 1 BLADE 2 ASPECTS MOBILE DESKTOP ProjectsEclipse IntelliJ Sublime NetBeans Vi/Emacs …….. IDE of choice running app J2EE ServerWAR deploy ZIP CDN Directory services
  • 26. JavaScript Interfaces ▶  Defines the contract a component should conform to. –  A set of method signatures ▶  Multiple classes “implement” the same interface ▶  Provides a hook for documentation ▶  Hook for IDE tooling
  • 27. Service Registry var service = new caplin.XhrXmlResourceServiceProvider(this.sXmlBundleUrl); caplin.ServiceRegistry.register("caplin.XmlResourceService”, service); var xmlResourceService = caplin.ServiceRegistry.getService("caplin.XmlResourceService"); var tradeModelNode = xmlResourceService.getXmlDocument("tradeModels"); Registration: Usage:
  • 28. Event Hub ▶  Publish/Subscribe inside the browser –  Many to many (or none) ▶  Defined by an interface (contract) ▶  Methods cannot return anything ▶  Classic example: logging ▶  Nice Article: http://blog.caplin.com/2012/12/07/event-hub-pubsub-in-the-browser/
  • 29. Component Interface ▶  Used by layout managers to manage GUI components ▶  Defines GUI lifecycle events –  getElement(), –  onOpen(), –  onResize(), –  onSerialize() etc.
  • 30. MVVM Pattern ViewRendering to screen Domain Model business semantic method callslistens Reused across many screens View Model gestureslistens Logical representation of the view (an adaptor)
  • 31. <button class=‘..’ data-bind=‘click:buttonClicked’> Execute Trade </button> HTML template with bindings $(button).click(function(){ vm.buttonClicked() }); jQuery Control Our HTML5 MVVM Domain Model executeTrade()complete() Message Service send()receive() View Model buttonClicked()tradeButtonEnabled No DOM Access XmlHttpRequest binding framework e.g. KnockoutJs
  • 32. The Testing Triangle Functional GUI testing ITs Unit Tests manual Acceptance Tests Performance Tests Integration Tests - Selenium - (automated manual tests) Unit Tests manual Performance Tests
  • 33. Test by contract Browser GUI logicaluseractions servicecalls Given “form is opened” When “user executes trade” Then “trade message sent to server” Server Code RESTfulAPI Given “server is started” When “trade message received” Then “money is sent somewhere”
  • 34. Test by contract MVVM and services View Model Domain Model complete() View execute() Given … When … Then … Fixtures executeTrade() tradeButtonEnabled Message Service Stub send() receive()
  • 35. Test Infrastructure js-test-driver Server Bundlers JavaScript Dependencies jsTestDriver.conf plugin: - name: "BundleInjector" jar: …/js-jstd-plugin.jar module: com.caplin.jstd.BundlerPlugin load: - bundles/i18n/en_i18n.bundle - bundles/js/js.bundle test: - tests/**.js serve: - bundles/html.bundle - bundles/xml.bundle Plugin JavaScript Test Files HTML/XML Dependencies
  • 36. In summary: divide + conquer Natural fine grained OO coding Components Common code in libraries Split GUI Code into Dom interactions View Model Domain Model Services for stubbing GWT + Test by contract
  • 37. We will soon be open-sourcing our implementation of this architecture www.bladerunnerjs.org