The Architect Way - JSCamp.asia 2012

4,011
-1

Published on

1 Comment
9 Likes
Statistics
Notes
No Downloads
Views
Total Views
4,011
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
24
Comments
1
Likes
9
Embeds 0
No embeds

No notes for slide

The Architect Way - JSCamp.asia 2012

  1. THEARCHITECT WAY Jan Jongboom JSCamp.asia November 30, 2012, Singapore
  2. @janjongboom
  3. Program• Cloud9? 5 minute intro + whats new• Problems growing your codebase• Introducing: Architect!• Lessons learned
  4. Normal developers
  5. JavaScript Developer
  6. OPPACLOUD9 STYLE
  7. Smart code completion
  8. Static analysis
  9. Free Linux machine
  10. Real terminal
  11. Program• Cloud9? 5 minute intro + whats new• Problems growing your codebase• Introducing: Architect!• Lessons learned
  12. Hundreds of thousands of lines of JavaScript (with semicolons ;-))
  13. dynamicweakly-typedlanguage
  14. one single thread
  15. Modularization
  16. Black box coding
  17. Great at abstracting away
  18. Not that good atapp level abstraction
  19. Relies on filesystem• Duplicated modules• Maps to folder / file name• Hard to configure
  20. Dependency error handlingcoding time startup time run time ! OM - BO KA - Server crash - Unhappy customers - Developer gets fired
  21. Program• Cloud9? 5 minute intro + whats new• Problems growing your codebase• Introducing: Architect!• Lessons learned
  22. Architect• Every piece of functionality is a plugin• Plugins can consume other plugins• An application is a set of plugins
  23. Require RuntimeArchitect Startup time
  24. Dependency error handling Architect stylecoding time compile time run time - Happy customers - Developer keeps - Fails before release job
  25. Here’s what we do• Code representation of this talk• Get a speaker from the database• Talk, talk, talk• And end with a dance
  26. Group functions by behavior
  27. DatalayerPresentation
  28. Dependency modelDatalayer Presentation
  29. package.jsonBuilds dependency tree withoutexecuting code
  30. data-­‐layer/package.jsonpresentation/package.json
  31. What’s next?• Extract the code• Wrap in Architect plugin code • It’s simple!• Make two plugins
  32. Function signatureCall when done
  33. Architect plugin code• Options, will get to that• Imports, everything you consume• Register, invoke when done
  34. Dependencies abstracted away• Easily unit testable• Mock dependencies• Assert ‘talk’ function is called 5 times
  35. No black magic• Architect builds dependency model• Feed architect a list of plugins • Simple array with file names• Call ‘createApp’
  36. Configuration• Per-plugin options• No global options object• Specify in config file
  37. Options• Automatically passed in at startup• Options are also dependencies• Fail if options aren’t present • Use default assertions
  38. Architect makes you think of your app as chunks of functionality rather than sets of classes
  39. Think‘chunks of functionality’ • Implicit type constraints • Keep implementation private • Swap feature implementations • Rather than interface implementations
  40. How do we use it?• Open source version• Hosted version • Normal • FTP • SSH
  41. Swap feature per implementation• On Open source: talk local filesystem• On FTP: talk FTP library• On SSH: log in and talk via a SSH bridge
  42. HERE’S SOMETHING COOL
  43. Centralized eventbus• Loose coupling between plugins• No hard dependencies!• Can also do inter-context communication
  44. React on eventOther plugin Eventbus Emit event Plugin
  45. And now scale up• Need something inter-server• Swap it with i.e. Redis PubSub• Plugins will never notice• Awesome!
  46. Program• Cloud9? 5 minute intro + whats new• Problems growing your codebase• Introducing: Architect!• Lessons learned
  47. Modularize in feature blocks• Don’t over engineer• Don’t create too small blocks • They are no interfaces!
  48. Avoid context switching • Less code! • Less errors! • Less boilerplate!
  49. Loose coupling• Eventbus• Smaller dependency graph
  50. github.com/c9/architect
  51. Happy coding!
  52. http://c9.io Jan Jongboom github.com/janjongboom @janjongboom

×