torsdag den 13 oktober 11 torsdag den 13 oktober 11
play

torsdag den 13. oktober 11 torsdag den 13. oktober 11 torsdag den - PowerPoint PPT Presentation

torsdag den 13. oktober 11 torsdag den 13. oktober 11 torsdag den 13. oktober 11 torsdag den 13. oktober 11 torsdag den 13. oktober 11 http://www.doxdesk.com/updates/2009.html torsdag den 13. oktober 11 Design, techniques and tools for


  1. torsdag den 13. oktober 11

  2. torsdag den 13. oktober 11

  3. torsdag den 13. oktober 11

  4. torsdag den 13. oktober 11

  5. torsdag den 13. oktober 11

  6. http://www.doxdesk.com/updates/2009.html torsdag den 13. oktober 11

  7. Design, techniques and tools for larger JavaScript applications Karl Krukow (kkr@trifork.com), Goto Amsterdam, Oct. 13th, 2011 torsdag den 13. oktober 11

  8. About me PhD, University of Aarhus, Theory-stuff :) Working at Trifork for about 5 years on Web, JavaScript, Java/JEE, Ruby/Rails, Clojure, Mobile, Conferences and Training. Last two years on iOS on Trifork in the financial sector. Recently part of a start-up doing mobile automated testing: LessPainful ApS ( http:/ /www.less painful.com) torsdag den 13. oktober 11

  9. torsdag den 13. oktober 11

  10. Have you ever found yourself in a project like this... torsdag den 13. oktober 11

  11. Development Time torsdag den 13. oktober 11

  12. torsdag den 13. oktober 11

  13. torsdag den 13. oktober 11

  14. torsdag den 13. oktober 11

  15. Development Time Unstructured No clear architecture No consistency torsdag den 13. oktober 11

  16. Runtime torsdag den 13. oktober 11

  17. torsdag den 13. oktober 11

  18. torsdag den 13. oktober 11

  19. With JavaScript Unless we do something: The way we organize our source code at development time... Significantly affect its behavior at runtime ! torsdag den 13. oktober 11

  20. Server side torsdag den 13. oktober 11

  21. Server side We often have non-functional requirements Maintainability, extensibility, understandability, quality, Productivity, Performance, ... torsdag den 13. oktober 11

  22. Server side We often have non-functional requirements Maintainability, extensibility, understandability, quality, Productivity, Performance, ... We have techniques and tools to help Architecture, modularity, reuse, separation of concerns automated testing & continuous integration Tool support (static analysis, compilers, IDEs, profilers) torsdag den 13. oktober 11

  23. Why so different? torsdag den 13. oktober 11

  24. Some key properties of JavaScript as a language Linkage of different scripts/modules via global variables. Delivered as source code, as opposed to executable binaries. Compilation is done by browser: compiles scripts as it receives them Dynamically typed Dynamic Objects (general containers) Prototypal inheritance Objects inherit from objects (no classes) torsdag den 13. oktober 11

  25. JavaScript in the large torsdag den 13. oktober 11

  26. JavaScript in the large JavaScript( ECMA-262 3rd edition )is focused on flexibility and ease of use: poorly suited for writing large & complex applications. torsdag den 13. oktober 11

  27. JavaScript in the large JavaScript( ECMA-262 3rd edition )is focused on flexibility and ease of use: poorly suited for writing large & complex applications. Here are some of the problems for large-scale use language flaws (e.g., type conversion, scope rules, numbers...) global namespace / missing module system (packages) missing encapsulation everything is mutable - even methods on objects program information hard to use by tools (e.g., static typing) torsdag den 13. oktober 11

  28. “Larger” projects (whatever that means) torsdag den 13. oktober 11

  29. “Larger” projects (whatever that means) This may or may not be a problem for you, except when your app scales in one or more of: torsdag den 13. oktober 11

  30. “Larger” projects (whatever that means) This may or may not be a problem for you, except when your app scales in one or more of: size and complexity torsdag den 13. oktober 11

  31. “Larger” projects (whatever that means) This may or may not be a problem for you, except when your app scales in one or more of: size and complexity development team: size and composition (new people, different skills) torsdag den 13. oktober 11

  32. “Larger” projects (whatever that means) This may or may not be a problem for you, except when your app scales in one or more of: size and complexity development team: size and composition (new people, different skills) time: stretches over years of development and maintenance. torsdag den 13. oktober 11

  33. Theme of this talk: What can we do? torsdag den 13. oktober 11

  34. Theme of this talk: What can we do? Rationale part (“the theory”) intro: helpful technologies and techniques Practical part (“the code”): open source sample application with a strict architecture and a JavaScript tool-chain. a modular MVC architecture (using custom events) advanced tooling (compilation, type-check, lazy-loading) automated testing (unit, integration and functional) torsdag den 13. oktober 11

  35. Compiler+VM Technology torsdag den 13. oktober 11

  36. Compiler+VM Technology “JavaScript is assembly language for the web” -Eric Meijer torsdag den 13. oktober 11

  37. Compiler+VM Technology “JavaScript is assembly language for the web” -Eric Meijer Google Dart ClojureScript (Clojure -> JS) Cappuccino (Objective-J -> JS) CoffeeScript (lightweight, “local” JS compilation) Google Closure Compiler (JS -> JS), Traceur (JS.Next->JS) Google Web Toolkit (Java -> JS) JSIL (.NET/CIL -> JS) ... torsdag den 13. oktober 11

  38. Differences in compilers torsdag den 13. oktober 11

  39. Differences in compilers whole-program optimizing “whitespace” local optimization optional typing, multiple targets pretty print aka. “minification” torsdag den 13. oktober 11

  40. Differences in compilers whole-program optimizing “whitespace” local optimization optional typing, multiple targets pretty print aka. “minification” closure compiler YUICompres, jsmin advanced mode, uglifyjs closure simple mode dartc Clojure- Script torsdag den 13. oktober 11

  41. This talk assumes you are staying in JavaScript. torsdag den 13. oktober 11

  42. Google Closure Compiler torsdag den 13. oktober 11

  43. Google Closure Compiler Extensible optimizing JavaScript-to-JavaScript compiler torsdag den 13. oktober 11

  44. Google Closure Compiler Extensible optimizing JavaScript-to-JavaScript compiler Several modes - the interesting one is “ advanced mode ”. whole-program analysis (all js files + extern must be supplied). optimizations (e.g., dead-code elimination, constant folding/ propagation) optional type-checking, @private access, ... lazy-loading of modules torsdag den 13. oktober 11

  45. Google Closure Compiler Extensible optimizing JavaScript-to-JavaScript compiler Several modes - the interesting one is “ advanced mode ”. whole-program analysis (all js files + extern must be supplied). optimizations (e.g., dead-code elimination, constant folding/ propagation) optional type-checking, @private access, ... lazy-loading of modules Requires writing JavaScript code in a particular way. torsdag den 13. oktober 11

  46. Google Closure Compiler Extensible optimizing JavaScript-to-JavaScript compiler Several modes - the interesting one is “ advanced mode ”. whole-program analysis (all js files + extern must be supplied). optimizations (e.g., dead-code elimination, constant folding/ propagation) optional type-checking, @private access, ... lazy-loading of modules Requires writing JavaScript code in a particular way. Very under-appreciated! Not just yet another minifier! torsdag den 13. oktober 11

  47. Typical JS Application composition Total amount of code Code actually used at runtime torsdag den 13. oktober 11

  48. Typical JS Application composition Total amount of Your code code Code actually used at runtime torsdag den 13. oktober 11

  49. Typical JS Application composition Total amount of Your code code Libraries Code actually used at runtime torsdag den 13. oktober 11

  50. Typical JS Application composition Total amount of Your code code Libraries Code actually used at runtime ç ç torsdag den 13. oktober 11

  51. Local optimization ç ç torsdag den 13. oktober 11

  52. Local optimization ç ç ç ç torsdag den 13. oktober 11

  53. Whole program analysis & Closure Tools ç ç torsdag den 13. oktober 11

  54. Whole program analysis & Closure Tools ç ç ç App. base modules torsdag den 13. oktober 11

  55. Whole program analysis & Closure Tools Other Modules loaded by need ç ç ç ç App. base modules torsdag den 13. oktober 11

  56. Closure Library torsdag den 13. oktober 11

  57. Closure Library HUGE JavaScript library used by Google. Symbiotic with closure compiler advanced mode, which makes it SMALL when used with compiler. torsdag den 13. oktober 11

  58. Closure Library HUGE JavaScript library used by Google. Symbiotic with closure compiler advanced mode, which makes it SMALL when used with compiler. Highlights (apart from expected of a JS library) Dependency/module system goog.provide, goog.require. “Interfaces”, “Enums”, “Class”-based inheritance system. (custom) event system supporting bubbling, capture, preventDefault and cancel. extensible UI components with a well-defined lifecycle, and which support custom events. torsdag den 13. oktober 11

  59. JSDoc annotations and tooling torsdag den 13. oktober 11

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend