SlideShare a Scribd company logo
Pragmatics of Declarative Ajax XTech 2007 May 15-18, Paris Dave Johnson CTO, Nitobi [email_address]
Agenda Who Am I Rule of Least Power Declarative Languages Programming Basics Web User Interfaces Common Problems Summary
Who Is this Guy? Enterprise Ajax book (Addison Wesley) Nitobi Enterprise Ajax Podcast http://blogs.nitobi.com/dave
Anything Else? Nitobi CTO + Co-founder Located in Vancouver, Canada Declarative Ajax user-interface components for the enterprise
 
Nitobi Clients
Agenda Who Is this Guy? http://flickr.com/photos/jjd/24164311/ ME THUNK HTML ROCZ!!!
The Rule of Least Power Tim Berners-Lee Noah Mendelsohn  www.w3.org/2001/tag/doc/leastPower
Principle “ Powerful languages inhibit information reuse.”
Inhibiting Information Reuse Humans like complicated Pen and paper or memory stick? What does this have to do with the Web?
Good Practice “ Use the least powerful language suitable for expressing information, constraints or programs on the World Wide Web.”
http://www.flickr.com/photos/doglotion/154496890/
http://www.flickr.com/photos/dpade1337/429996161/
WS-*???
Benefits of Less Power? More robust and secure Easier for people to use Therefore, more people use them Be mindful of the success of HTML
110,000,000
http://flickr.com/photos/oceanyamaha/186146223/ DEKLARATIVE WUT???
Declarative What? It is about  what  not  how There is no sign of an algorithm We are not talking functional languages HTML – canonical declarative language
Declarative Languages HTML XForms SVG MXML XAML JSON
Ham and Cheese “ declarative” vs “imperative” “ library” vs “roll your own”
 
http://www.flickr.com/photos/refractedmoments/399890975/
Computability But is the Jambon et Fromage Touring complete? You can’t change the recipe If there is no way to specify  what  you want to do then how can you do it? Make the sandwich yourself Bring your own mustard Why bother?
Pareto’s Principle Call it what you will 80-20 rule Law of the vital few Principle of factor sparsity 90-10 rule in software engineering Declarative gets you most of the way!
Design VS Program Declarative “design” gets us 80% Programming gets the other 20% One of two evils Easy to design Easy to program
Popular Tools HTML – how many HTML pages? JSON – relatively new compared to <XML> Microformats – hCard Twitter – how many messages? Twitter vision  L:Paris
Not Just About XML Declarative does not have to be XML Imperative languages can  look  declarative Using imperative language to encapsulate non-declarative ideas You don’t have to bake the bread for your sandwich … nor mill the grain
Layering Languages Languages get more simple as we share more information Consider a factorial function in a few different languages?
Machine Code
Assembly main: movl $5, %eax movl $1, %ebx L1: cmpl $0, %eax je L2 imull %eax, %ebx decl %eax jmp L1 L2: ret
C++ int factorial(int n) { if(n <= 1) return 1; return n * factorial(n - 1); }
Python fac = lambda n:[1,0][n>0] or fac(n-1)*n
Still All Clearly Imperative Conditional statements However, once you start using the factorial function it  appears  declarative
Agenda I CULD DO ZAT http://flickr.com/photos/stevecaddy/474542238/
Declarative User Interface Who cares about calculating factorials Power is in design
Declarative Maps?
In JavaScript <script type=“text/javascript”> gmap.init = function() { var map = new GMap2(document.getElementById(&quot;map&quot;)); map.setCenter(new GLatLng(49.290327, -123.11348), 12); var polyline = new GPolyline([ new GLatLng(49.265788, -123.069877), new GLatLng(49.276988, -123.069534), new GLatLng(49.276988, -123.099746), new GLatLng(49.278108, -123.112106), new GLatLng(49.2949043, -123.136825)],  &quot;#ff0000&quot;, 10); map.addOverlay(polyline);  } window.onload = gmap.init; </script>
In (X)HTML <g:map id=&quot;map&quot; width=&quot;370px&quot; height=&quot;380px&quot; smallmapcontrol=&quot;true&quot; maptypecontrol=&quot;true&quot;> <g:center zoom=&quot;14&quot;> <g:point lat=&quot;49.2853&quot; lng=&quot;-123.11348&quot;></g:point> </g:center> <g:polyline color=&quot;#FF0000&quot; size=&quot;10&quot;> <g:point lat=&quot;49.265788&quot; lng=&quot;-123.069877&quot;></g:point> <g:point lat=&quot;49.276988&quot; lng=&quot;-123.069534&quot;></g:point> <g:point lat=&quot;49.276988&quot; lng=&quot;-123.099746&quot;></g:point> <g:point lat=&quot;49.278108&quot; lng=&quot;-123.112106&quot;></g:point> <g:point lat=&quot;49.294904&quot; lng=&quot;-123.136825&quot;></g:point> </g:polyline> </g:map>
Same but Different new GLatLng(49.265788, -123.069877) <g:point lat=&quot;49.265788&quot; lng=&quot;-123.069877&quot; /> new GLatLng( -123.069877 ,  49.265788 ) <g:point lng=&quot; -123.069877 &quot; lat=&quot; 49.265788 &quot; />
Practical Differences Both could have auto-complete support Designability and IDE support HTML writer support on servers Order matters … to a less degree in XML Declarative  can  be less code People don’t like JavaScript Remember, HTML is a success for a reason
The Bugaboo Imperative can be  nearly  as good as declaration “ JavaScript objects need more than just setting properties”
var input = new Input(); input.hint = “Please enter a number”; <input> <hint>Please enter a number</hint> </input>
var input = new Input(); input. setHint (“Please enter a number”); Input.prototype.setHint = function() { // setup any event hooks etc… }
Benefits? Designable easy IDE tooling Declarative patterns succinct, reproducible solutions Rich semantics frameworks can easily read and interpret server or client side interpretation
Write Once, Deploy Anywhere
http://flickr.com/photos/elmyra/9335163/ WUT IZ ISNIDE?
Problems Firefox – served as HTML DOM traversal Self closing tags Internet Explorer – can’t be served as XHTML DOM methods Namespace Namespaces XHTML CSS Validation
Firefox HTML DOM Traversal <div id=&quot;div1&quot;> <ntb:button id=&quot;button1&quot;>button</ntb:button> <ntb:button id=&quot;button2&quot;>button 2</ntb:button> <ntb:panel id=&quot;panel1&quot;> <ntb:title id=&quot;title1&quot;> <div id=&quot;div2&quot;>panel title 1</div> </ntb:title> <ntb:contents id=&quot;contents1&quot;> <div id=&quot;div3&quot;>Contents div3</div> <div id=&quot;div4&quot;>Contents div4</div> </ntb:contents> </ntb:panel> </div>
getElementsByTagNameNS ns.getElementsByTagNameNS = function(tag, np, context) { context = context || document; var qname = np + &quot;:&quot; + tag; if (ns.IE) qname = tag; var elems = context.getElementsByTagName(qname); if (ns.IE) { realElems = []; for (var i=0; i<elems.length; i++) { if (elems[i].scopeName == ns) realElems.push(elems[i]); } elems = realElems; } return elems; }
Styling Namespaced Elements Internet Explorer ntb\:* { display:none; } W3C @namespace ntb &quot;http://www.nitobi.com&quot;; ntb|* { display:none; }
Other Approaches Custom attribute <div oatype=&quot;ntb:grid&quot; ... /> Microformats <div class=“ntb_grid” … /> XBL / HTC JSON <div oatype=“{widget:’grid’,colums:[‘Col1’,Col2’]}” /> Many, many more
Standards Approach Use HTML  role  attribute Accessibility of Rich Internet Applications (ARIA) as part of Web Accessibility Initiative
W3C Accessibility tabindex=&quot;-1&quot; role=&quot;wairole:checkbox&quot; property:checked=&quot;true“ <div tabindex=“-1” role=“wairole:checkbox” property:checked=“true”> </div>
What are Others Doing? XML-Script Dojo Toolkit XForms
XML-Script <script type=&quot;text/xml-script&quot;> <page xmlns=&quot;http://schemas.microsoft.com/xml-script/2005&quot;> <components> <textbox id=&quot;searchText&quot; /> <button id=&quot;searchButton&quot;> <bindings> <binding property=&quot;enabled&quot; dataContext=&quot;searchText&quot; dataPath=&quot;text.length&quot; transform=&quot;NumberToBoolean&quot; /> </bindings> <click> <invokeMethod target=&quot;searchMethod&quot; method=&quot;invoke&quot; /> </click> </button> <serviceMethod id=&quot;searchMethod&quot;> <bindings> <binding property=&quot;parameters&quot; propertyKey=&quot;query&quot; dataContext=&quot;searchText&quot; dataPath=&quot;text&quot; /> </bindings> </serviceMethod> </components> </page> </script>
Dojo Toolkit <BUTTON widgetId=&quot;helloButton&quot; dojoType=&quot;Button&quot;>Hello World!</BUTTON> <?xml:namespace prefix=dojo/> <dojo:widget></dojo:widget> <DIV dojoType=&quot;widget&quot;> <DIV class=dojo-widget></DIV> </DIV>
XForms <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:f=&quot;http://www.w3.org/2002/xforms&quot;> <head> <title>Search</title> <f:model> <f:submission action=&quot;http://example.com/search“ method=&quot;get&quot; id=&quot;s&quot;/> </f:model> </head> <body> <p> <f:input ref=&quot;q&quot;><f:label>Find</f:label></f:input> <f:submit submission=&quot;s&quot;><f:label>Go</f:label></f:submit> </p> </body> </html>
Summary Declarative is “least power” approach Facilitates sharing of information User interface designability and skinnability are paramount
Q&A? Dave Johnson [email_address] http://blogs.nitobi.com/dave

More Related Content

What's hot (20)

PPT
Lecture 3 Javascript1
Sur College of Applied Sciences
 
PDF
Ditching jQuery Madison
Hao Luo
 
PPT
Php
Mindtree
 
PPTX
All of Javascript
Togakangaroo
 
PPTX
Peter lubbers-html5-overview-sf-dev-conf-2011
Peter Lubbers
 
PPT
HTML5 Overview
reybango
 
PPTX
Node.JS error handling best practices
Yoni Goldberg
 
PDF
Intro to mobile web application development
zonathen
 
PPT
Html5 Overview
Owen Williams
 
PPT
WordPress Standardized Loop API
Chris Jean
 
PDF
Seven Reasons for Code Bloat
Christian Heilmann
 
PPT
Flash Security, OWASP Chennai
lavakumark
 
PDF
plumbing for the next web
Ian Forrester
 
PPTX
Behat - Drupal South 2018
Berend de Boer
 
PPT
Joomla security nuggets
guestbd1cdca
 
PPTX
Getting Started with HTML5 in Tech Com (STC 2012)
Peter Lubbers
 
PDF
HTML5 for PHP Developers - IPC
Mayflower GmbH
 
PDF
Building Realtime Apps with Ember.js and WebSockets
Ben Limmer
 
PDF
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
Joshua Warren
 
PPT
Rey Bango - HTML5: polyfills and shims
StarTech Conference
 
Lecture 3 Javascript1
Sur College of Applied Sciences
 
Ditching jQuery Madison
Hao Luo
 
All of Javascript
Togakangaroo
 
Peter lubbers-html5-overview-sf-dev-conf-2011
Peter Lubbers
 
HTML5 Overview
reybango
 
Node.JS error handling best practices
Yoni Goldberg
 
Intro to mobile web application development
zonathen
 
Html5 Overview
Owen Williams
 
WordPress Standardized Loop API
Chris Jean
 
Seven Reasons for Code Bloat
Christian Heilmann
 
Flash Security, OWASP Chennai
lavakumark
 
plumbing for the next web
Ian Forrester
 
Behat - Drupal South 2018
Berend de Boer
 
Joomla security nuggets
guestbd1cdca
 
Getting Started with HTML5 in Tech Com (STC 2012)
Peter Lubbers
 
HTML5 for PHP Developers - IPC
Mayflower GmbH
 
Building Realtime Apps with Ember.js and WebSockets
Ben Limmer
 
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
Joshua Warren
 
Rey Bango - HTML5: polyfills and shims
StarTech Conference
 

Viewers also liked (20)

PDF
Speech Acts And Speech Events, By Dr.Shadia Yousef Banjar.Pptx
Dr. Shadia Banjar
 
PPTX
Speech acts
Carolina Celis
 
PPT
Evolution - Η Εξέλιξη της Ζωής
neutrinoteam
 
PPT
Adam & Jamie Videos on the 'Net
Ken Kaplan
 
PPT
Aivazovskii
viktoriya71
 
PDF
台北捷運中和線東門段貫通說明 by [email protected]
Yi-Chi Tang
 
PPTX
Time management: Taking Control of your email inbox
Josue Sierra
 
PDF
Mobile card game service
Latte Media
 
PPT
Induction talk year 4 2014
Tony McNeill
 
PPT
Any Colour As Long As It’s Blackboard
Tony McNeill
 
KEY
Kontaktpäev ii
terje1
 
PDF
Sosiale medier og journalistikk - hva er sosiale medier?
Oyvind Solstad
 
PPT
Structuring OpenBadges with InLOC
Simon Grant
 
PPTX
When the Best is Free: Images
Katie Christo
 
PPT
Nghiệp vụ Mitraco Securities
Pham Ngoc Quang
 
PPT
Pres Blog Oct
Manuela Repetto
 
PDF
Portfolio information: personally or institutionally managed?
Simon Grant
 
PPS
Olatuak Donostian
Emilio Gil (unjubilado)
 
PPT
Chuong 13 bai tiet
Pham Ngoc Quang
 
PDF
EDB Venue September 2009
Oyvind Solstad
 
Speech Acts And Speech Events, By Dr.Shadia Yousef Banjar.Pptx
Dr. Shadia Banjar
 
Speech acts
Carolina Celis
 
Evolution - Η Εξέλιξη της Ζωής
neutrinoteam
 
Adam & Jamie Videos on the 'Net
Ken Kaplan
 
Aivazovskii
viktoriya71
 
台北捷運中和線東門段貫通說明 by [email protected]
Yi-Chi Tang
 
Time management: Taking Control of your email inbox
Josue Sierra
 
Mobile card game service
Latte Media
 
Induction talk year 4 2014
Tony McNeill
 
Any Colour As Long As It’s Blackboard
Tony McNeill
 
Kontaktpäev ii
terje1
 
Sosiale medier og journalistikk - hva er sosiale medier?
Oyvind Solstad
 
Structuring OpenBadges with InLOC
Simon Grant
 
When the Best is Free: Images
Katie Christo
 
Nghiệp vụ Mitraco Securities
Pham Ngoc Quang
 
Pres Blog Oct
Manuela Repetto
 
Portfolio information: personally or institutionally managed?
Simon Grant
 
Olatuak Donostian
Emilio Gil (unjubilado)
 
Chuong 13 bai tiet
Pham Ngoc Quang
 
EDB Venue September 2009
Oyvind Solstad
 
Ad

Similar to Pragmatics of Declarative Ajax (20)

PPT
CTS Conference Web 2.0 Tutorial Part 2
Geoffrey Fox
 
PPT
Sergey Ilinsky Presentation Ample Sdk
Ajax Experience 2009
 
PPT
Mappetizer Web mapping software
RuthLang
 
PPTX
Beholding the giant pyramid of application development; why Ajax applications...
Javeline B.V.
 
ODP
Ample SDK: A tour de force
Sergey Ilinsky
 
PPT
Atlas Php
Gregory Renard
 
PDF
Your java script library
jasfog
 
PDF
Building with JavaScript - write less by using the right tools
Christian Heilmann
 
PPTX
HTML5 Introduction
beforeach
 
PDF
JS Single-Page Web App Essentials
Sergey Bolshchikov
 
PPTX
the next web now
zulin Gu
 
PDF
Mozilla Firefox Extension Development, Course 1: Basic
littlebtc
 
PPTX
How to Make AJAX Applications Scream on the Client
goodfriday
 
PPT
Zend framework 05 - ajax, json and j query
Tricode (part of Dept)
 
PDF
mobl presentation @ IHomer
zefhemel
 
PPT
JavaScript Needn't Hurt!
Thomas Kjeldahl Nilsson
 
ODP
HTML5
Hatem Mahmoud
 
PPT
JQuery: Introduction
Amit Kumar Singh
 
PPT
Html Expression Web
Mark Frydenberg
 
ODP
Moving from Web 1.0 to Web 2.0
Estelle Weyl
 
CTS Conference Web 2.0 Tutorial Part 2
Geoffrey Fox
 
Sergey Ilinsky Presentation Ample Sdk
Ajax Experience 2009
 
Mappetizer Web mapping software
RuthLang
 
Beholding the giant pyramid of application development; why Ajax applications...
Javeline B.V.
 
Ample SDK: A tour de force
Sergey Ilinsky
 
Atlas Php
Gregory Renard
 
Your java script library
jasfog
 
Building with JavaScript - write less by using the right tools
Christian Heilmann
 
HTML5 Introduction
beforeach
 
JS Single-Page Web App Essentials
Sergey Bolshchikov
 
the next web now
zulin Gu
 
Mozilla Firefox Extension Development, Course 1: Basic
littlebtc
 
How to Make AJAX Applications Scream on the Client
goodfriday
 
Zend framework 05 - ajax, json and j query
Tricode (part of Dept)
 
mobl presentation @ IHomer
zefhemel
 
JavaScript Needn't Hurt!
Thomas Kjeldahl Nilsson
 
JQuery: Introduction
Amit Kumar Singh
 
Html Expression Web
Mark Frydenberg
 
Moving from Web 1.0 to Web 2.0
Estelle Weyl
 
Ad

Recently uploaded (20)

PDF
From Legacy to Velocity: how we rebuilt everything in 8 months.
Product-Tech Team
 
PDF
Buy Boys Long Sleeve T-shirts at Port 213
Port 213
 
PPTX
Understanding ISO 42001 Standard: AI Governance & Compliance Insights from Ad...
Adeptiv AI
 
PDF
Blind Spots in Business: Unearthing Hidden Challenges in Today's Organizations
Crimson Business Consulting
 
PDF
Agriculture Machinery PartsAgriculture Machinery Parts
mizhanw168
 
PPTX
Why-Your-BPO-Startup-Must-Track-Attrition-from-Day-One.pptx.pptx
Orage technologies
 
PPTX
Top Oil and Gas Companies in India Fuelling the Nation’s Growth.pptx
Essar Group
 
PDF
Azumah Resources reaffirms commitment to Ghana amid dispute with Engineers & ...
Kweku Zurek
 
PDF
Gabino Barbosa - A Master Of Efficiency
Gabino Barbosa
 
PPTX
25 Future Mega Trends Reshaping the World in 2025 and Beyond
presentifyai
 
PDF
Maksym Vyshnivetskyi: Управління закупівлями (UA)
Lviv Startup Club
 
PDF
SUMMER SAFETY FLYER SPECIAL Q3 - 16 Pages
One Source Industrial Supplies
 
PDF
BeMetals_Presentation_July_2025 .pdf
DerekIwanaka2
 
PDF
Flexible Metal Hose & Custom Hose Assemblies
McGill Hose & Coupling Inc
 
PPTX
Washington University of Health and Science A Choice You Can Trust
Washington University of Health and Science
 
PDF
LEWIONICS SCO Company Profile UAE JULY 2025
Natalie Lewes
 
DOCX
How to Choose the Best Dildo for Men A Complete Buying Guide.docx
Glas Toy
 
PDF
NewBase 07 July 2025 Energy News issue - 1800 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
PDF
15 Essential Cloud Podcasts Every Tech Professional Should Know in 2025
Amnic
 
PPTX
Key Neurology Coding Changes Every Physician Should Know (1).pptx
alicecarlos1
 
From Legacy to Velocity: how we rebuilt everything in 8 months.
Product-Tech Team
 
Buy Boys Long Sleeve T-shirts at Port 213
Port 213
 
Understanding ISO 42001 Standard: AI Governance & Compliance Insights from Ad...
Adeptiv AI
 
Blind Spots in Business: Unearthing Hidden Challenges in Today's Organizations
Crimson Business Consulting
 
Agriculture Machinery PartsAgriculture Machinery Parts
mizhanw168
 
Why-Your-BPO-Startup-Must-Track-Attrition-from-Day-One.pptx.pptx
Orage technologies
 
Top Oil and Gas Companies in India Fuelling the Nation’s Growth.pptx
Essar Group
 
Azumah Resources reaffirms commitment to Ghana amid dispute with Engineers & ...
Kweku Zurek
 
Gabino Barbosa - A Master Of Efficiency
Gabino Barbosa
 
25 Future Mega Trends Reshaping the World in 2025 and Beyond
presentifyai
 
Maksym Vyshnivetskyi: Управління закупівлями (UA)
Lviv Startup Club
 
SUMMER SAFETY FLYER SPECIAL Q3 - 16 Pages
One Source Industrial Supplies
 
BeMetals_Presentation_July_2025 .pdf
DerekIwanaka2
 
Flexible Metal Hose & Custom Hose Assemblies
McGill Hose & Coupling Inc
 
Washington University of Health and Science A Choice You Can Trust
Washington University of Health and Science
 
LEWIONICS SCO Company Profile UAE JULY 2025
Natalie Lewes
 
How to Choose the Best Dildo for Men A Complete Buying Guide.docx
Glas Toy
 
NewBase 07 July 2025 Energy News issue - 1800 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
15 Essential Cloud Podcasts Every Tech Professional Should Know in 2025
Amnic
 
Key Neurology Coding Changes Every Physician Should Know (1).pptx
alicecarlos1
 

Pragmatics of Declarative Ajax

  • 1. Pragmatics of Declarative Ajax XTech 2007 May 15-18, Paris Dave Johnson CTO, Nitobi [email_address]
  • 2. Agenda Who Am I Rule of Least Power Declarative Languages Programming Basics Web User Interfaces Common Problems Summary
  • 3. Who Is this Guy? Enterprise Ajax book (Addison Wesley) Nitobi Enterprise Ajax Podcast http://blogs.nitobi.com/dave
  • 4. Anything Else? Nitobi CTO + Co-founder Located in Vancouver, Canada Declarative Ajax user-interface components for the enterprise
  • 5.  
  • 7. Agenda Who Is this Guy? http://flickr.com/photos/jjd/24164311/ ME THUNK HTML ROCZ!!!
  • 8. The Rule of Least Power Tim Berners-Lee Noah Mendelsohn www.w3.org/2001/tag/doc/leastPower
  • 9. Principle “ Powerful languages inhibit information reuse.”
  • 10. Inhibiting Information Reuse Humans like complicated Pen and paper or memory stick? What does this have to do with the Web?
  • 11. Good Practice “ Use the least powerful language suitable for expressing information, constraints or programs on the World Wide Web.”
  • 15. Benefits of Less Power? More robust and secure Easier for people to use Therefore, more people use them Be mindful of the success of HTML
  • 18. Declarative What? It is about what not how There is no sign of an algorithm We are not talking functional languages HTML – canonical declarative language
  • 19. Declarative Languages HTML XForms SVG MXML XAML JSON
  • 20. Ham and Cheese “ declarative” vs “imperative” “ library” vs “roll your own”
  • 21.  
  • 23. Computability But is the Jambon et Fromage Touring complete? You can’t change the recipe If there is no way to specify what you want to do then how can you do it? Make the sandwich yourself Bring your own mustard Why bother?
  • 24. Pareto’s Principle Call it what you will 80-20 rule Law of the vital few Principle of factor sparsity 90-10 rule in software engineering Declarative gets you most of the way!
  • 25. Design VS Program Declarative “design” gets us 80% Programming gets the other 20% One of two evils Easy to design Easy to program
  • 26. Popular Tools HTML – how many HTML pages? JSON – relatively new compared to <XML> Microformats – hCard Twitter – how many messages? Twitter vision L:Paris
  • 27. Not Just About XML Declarative does not have to be XML Imperative languages can look declarative Using imperative language to encapsulate non-declarative ideas You don’t have to bake the bread for your sandwich … nor mill the grain
  • 28. Layering Languages Languages get more simple as we share more information Consider a factorial function in a few different languages?
  • 30. Assembly main: movl $5, %eax movl $1, %ebx L1: cmpl $0, %eax je L2 imull %eax, %ebx decl %eax jmp L1 L2: ret
  • 31. C++ int factorial(int n) { if(n <= 1) return 1; return n * factorial(n - 1); }
  • 32. Python fac = lambda n:[1,0][n>0] or fac(n-1)*n
  • 33. Still All Clearly Imperative Conditional statements However, once you start using the factorial function it appears declarative
  • 34. Agenda I CULD DO ZAT http://flickr.com/photos/stevecaddy/474542238/
  • 35. Declarative User Interface Who cares about calculating factorials Power is in design
  • 37. In JavaScript <script type=“text/javascript”> gmap.init = function() { var map = new GMap2(document.getElementById(&quot;map&quot;)); map.setCenter(new GLatLng(49.290327, -123.11348), 12); var polyline = new GPolyline([ new GLatLng(49.265788, -123.069877), new GLatLng(49.276988, -123.069534), new GLatLng(49.276988, -123.099746), new GLatLng(49.278108, -123.112106), new GLatLng(49.2949043, -123.136825)], &quot;#ff0000&quot;, 10); map.addOverlay(polyline); } window.onload = gmap.init; </script>
  • 38. In (X)HTML <g:map id=&quot;map&quot; width=&quot;370px&quot; height=&quot;380px&quot; smallmapcontrol=&quot;true&quot; maptypecontrol=&quot;true&quot;> <g:center zoom=&quot;14&quot;> <g:point lat=&quot;49.2853&quot; lng=&quot;-123.11348&quot;></g:point> </g:center> <g:polyline color=&quot;#FF0000&quot; size=&quot;10&quot;> <g:point lat=&quot;49.265788&quot; lng=&quot;-123.069877&quot;></g:point> <g:point lat=&quot;49.276988&quot; lng=&quot;-123.069534&quot;></g:point> <g:point lat=&quot;49.276988&quot; lng=&quot;-123.099746&quot;></g:point> <g:point lat=&quot;49.278108&quot; lng=&quot;-123.112106&quot;></g:point> <g:point lat=&quot;49.294904&quot; lng=&quot;-123.136825&quot;></g:point> </g:polyline> </g:map>
  • 39. Same but Different new GLatLng(49.265788, -123.069877) <g:point lat=&quot;49.265788&quot; lng=&quot;-123.069877&quot; /> new GLatLng( -123.069877 , 49.265788 ) <g:point lng=&quot; -123.069877 &quot; lat=&quot; 49.265788 &quot; />
  • 40. Practical Differences Both could have auto-complete support Designability and IDE support HTML writer support on servers Order matters … to a less degree in XML Declarative can be less code People don’t like JavaScript Remember, HTML is a success for a reason
  • 41. The Bugaboo Imperative can be nearly as good as declaration “ JavaScript objects need more than just setting properties”
  • 42. var input = new Input(); input.hint = “Please enter a number”; <input> <hint>Please enter a number</hint> </input>
  • 43. var input = new Input(); input. setHint (“Please enter a number”); Input.prototype.setHint = function() { // setup any event hooks etc… }
  • 44. Benefits? Designable easy IDE tooling Declarative patterns succinct, reproducible solutions Rich semantics frameworks can easily read and interpret server or client side interpretation
  • 45. Write Once, Deploy Anywhere
  • 47. Problems Firefox – served as HTML DOM traversal Self closing tags Internet Explorer – can’t be served as XHTML DOM methods Namespace Namespaces XHTML CSS Validation
  • 48. Firefox HTML DOM Traversal <div id=&quot;div1&quot;> <ntb:button id=&quot;button1&quot;>button</ntb:button> <ntb:button id=&quot;button2&quot;>button 2</ntb:button> <ntb:panel id=&quot;panel1&quot;> <ntb:title id=&quot;title1&quot;> <div id=&quot;div2&quot;>panel title 1</div> </ntb:title> <ntb:contents id=&quot;contents1&quot;> <div id=&quot;div3&quot;>Contents div3</div> <div id=&quot;div4&quot;>Contents div4</div> </ntb:contents> </ntb:panel> </div>
  • 49. getElementsByTagNameNS ns.getElementsByTagNameNS = function(tag, np, context) { context = context || document; var qname = np + &quot;:&quot; + tag; if (ns.IE) qname = tag; var elems = context.getElementsByTagName(qname); if (ns.IE) { realElems = []; for (var i=0; i<elems.length; i++) { if (elems[i].scopeName == ns) realElems.push(elems[i]); } elems = realElems; } return elems; }
  • 50. Styling Namespaced Elements Internet Explorer ntb\:* { display:none; } W3C @namespace ntb &quot;http://www.nitobi.com&quot;; ntb|* { display:none; }
  • 51. Other Approaches Custom attribute <div oatype=&quot;ntb:grid&quot; ... /> Microformats <div class=“ntb_grid” … /> XBL / HTC JSON <div oatype=“{widget:’grid’,colums:[‘Col1’,Col2’]}” /> Many, many more
  • 52. Standards Approach Use HTML role attribute Accessibility of Rich Internet Applications (ARIA) as part of Web Accessibility Initiative
  • 53. W3C Accessibility tabindex=&quot;-1&quot; role=&quot;wairole:checkbox&quot; property:checked=&quot;true“ <div tabindex=“-1” role=“wairole:checkbox” property:checked=“true”> </div>
  • 54. What are Others Doing? XML-Script Dojo Toolkit XForms
  • 55. XML-Script <script type=&quot;text/xml-script&quot;> <page xmlns=&quot;http://schemas.microsoft.com/xml-script/2005&quot;> <components> <textbox id=&quot;searchText&quot; /> <button id=&quot;searchButton&quot;> <bindings> <binding property=&quot;enabled&quot; dataContext=&quot;searchText&quot; dataPath=&quot;text.length&quot; transform=&quot;NumberToBoolean&quot; /> </bindings> <click> <invokeMethod target=&quot;searchMethod&quot; method=&quot;invoke&quot; /> </click> </button> <serviceMethod id=&quot;searchMethod&quot;> <bindings> <binding property=&quot;parameters&quot; propertyKey=&quot;query&quot; dataContext=&quot;searchText&quot; dataPath=&quot;text&quot; /> </bindings> </serviceMethod> </components> </page> </script>
  • 56. Dojo Toolkit <BUTTON widgetId=&quot;helloButton&quot; dojoType=&quot;Button&quot;>Hello World!</BUTTON> <?xml:namespace prefix=dojo/> <dojo:widget></dojo:widget> <DIV dojoType=&quot;widget&quot;> <DIV class=dojo-widget></DIV> </DIV>
  • 57. XForms <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:f=&quot;http://www.w3.org/2002/xforms&quot;> <head> <title>Search</title> <f:model> <f:submission action=&quot;http://example.com/search“ method=&quot;get&quot; id=&quot;s&quot;/> </f:model> </head> <body> <p> <f:input ref=&quot;q&quot;><f:label>Find</f:label></f:input> <f:submit submission=&quot;s&quot;><f:label>Go</f:label></f:submit> </p> </body> </html>
  • 58. Summary Declarative is “least power” approach Facilitates sharing of information User interface designability and skinnability are paramount
  • 59. Q&A? Dave Johnson [email_address] http://blogs.nitobi.com/dave