Successfully reported this slideshow.

Architecting large Node.js applications

64

Share

Upcoming SlideShare
Big app design for Node.js
Big app design for Node.js
Loading in …3
×
1 of 81
1 of 81

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Architecting large Node.js applications

  1. 1. large Architecting node.js applications Monday, October 22, 12
  2. 2. @sergimansilla Monday, October 22, 12
  3. 3. P ro g ra m ☐ C l o u d9 ID E? ☐ Grow in g pai n s ☐ I n t ro du c i n g Arc hitec t ☐ Le ss on s le arn e d Monday, October 22, 12
  4. 4. Normal developers Monday, October 22, 12
  5. 5. JavaScript Developer Monday, October 22, 12
  6. 6. Cloud9 IDE - http://c9.io Monday, October 22, 12
  7. 7. Real debugging Monday, October 22, 12
  8. 8. (Smart!) Code completion Monday, October 22, 12
  9. 9. Static analysis Monday, October 22, 12
  10. 10. Free Linux Monday, October 22, 12 VM
  11. 11. Bring your own machine Monday, October 22, 12
  12. 12. Real terminal Monday, October 22, 12
  13. 13. Collaboration Monday, October 22, 12
  14. 14. See each other type Debug together Productivity++ Monday, October 22, 12
  15. 15. Create Deploy Run/Debug Share Test Monday, October 22, 12
  16. 16. P ro g ra m ☑ C l o u d9 ID E? ☐ Grow in g pai n s ☐ I n t ro du c i n g Arc hitec t ☐ Le ss on s le arn e d Monday, October 22, 12
  17. 17. 10,000s LOC of JavaScript Monday, October 22, 12
  18. 18. dynamic, weakly typed language Monday, October 22, 12
  19. 19. one single Monday, October 22, 12 thread
  20. 20. Openshift Cloud9 datacenter Remote VM IDE server Remote VM Remote VM Monday, October 22, 12
  21. 21. Pure madness Monday, October 22, 12
  22. 22. Modularization Monday, October 22, 12
  23. 23. Black box coding Monday, October 22, 12
  24. 24. Monday, October 22, 12
  25. 25. Java/.NET import(s) Node.js require Monday, October 22, 12
  26. 26. Great for re requi abstracting Monday, October 22, 12 away
  27. 27. re requi Not Great for application modularity Monday, October 22, 12
  28. 28. re requi Relies on FS duplicated modules maps to folder names Hard to configure module Monday, October 22, 12
  29. 29. Dependency error handling coding time compile time run time ! OM - BO KA - Server crash - Unhappy customers - Developer gets fired Monday, October 22, 12
  30. 30. How to fix it? Static dependency list Resolve at startup Named services No FS required Easy configuration Pass an object Monday, October 22, 12
  31. 31. P ro g ra m ☑ C l o u d9 ID E? ☑ G row i n g pai n s ☐ I n t ro du c i n g Arc hitec t ☐ Le ss on s le arn e d Monday, October 22, 12
  32. 32. Architect github.com/c9/architect Monday, October 22, 12
  33. 33. Architect Everything is a plugin Plugins can consume plugins An application is just a set of plugins Monday, October 22, 12
  34. 34. Dependency model require runtime Architect compile time Monday, October 22, 12
  35. 35. Dependency error handling Architect coding time compile time run time - Happy customers - Fails before release - Developer keeps job Monday, October 22, 12
  36. 36. Monday, October 22, 12
  37. 37. Declare entity ‘presenter’ with behavior Use ‘presenter’ to do a presentation Monday, October 22, 12
  38. 38. Dependency model Presenter Presentation Monday, October 22, 12
  39. 39. Express our model package.json Builds dependency tree without executing code Monday, October 22, 12
  40. 40. Monday, October 22, 12
  41. 41. What’s next? Wrap in Architect plugin code Extract the code Make two plugins Monday, October 22, 12
  42. 42. Function signature Call when done Monday, October 22, 12
  43. 43. Architect plugin code Module.exports Options - we’ll get to that Imports - everything you ‘consume’ Register - invoke when done Monday, October 22, 12
  44. 44. Monday, October 22, 12
  45. 45. Monday, October 22, 12
  46. 46. Easy to test Mock dependencies Monday, October 22, 12
  47. 47. Assert ‘dance’ is called 11 times Monday, October 22, 12
  48. 48. No black magic Specify dependency model Feed architect a config file Call ‘createApp’ Monday, October 22, 12
  49. 49. Monday, October 22, 12
  50. 50. Monday, October 22, 12
  51. 51. Configuration Per-plugin options No global options object Specify in config file Monday, October 22, 12
  52. 52. Monday, October 22, 12
  53. 53. Monday, October 22, 12
  54. 54. Options Automatically passed in at startup Options are also dependencies Fail if options aren’t present Monday, October 22, 12
  55. 55. Monday, October 22, 12
  56. 56. Monday, October 22, 12
  57. 57. Architect makes you think of your app as chunks of functionality rather than sets of classes Monday, October 22, 12
  58. 58. Think ‘chunks of functionality’ Implicit type constraints Keep implementation private Swap features instead of interfaces Monday, October 22, 12
  59. 59. How does Cloud9 use it? Open source version Local version (OS + sync) Hosted version Normal FTP SSH Monday, October 22, 12
  60. 60. Monday, October 22, 12
  61. 61. Swap feature per implementation On Open source: talk local filesystem On FTP: talk FTP library On SSH: talk via a SSH bridge Monday, October 22, 12
  62. 62. Here is something your DI framework can’t do Monday, October 22, 12
  63. 63. Single node.js process IDE instance IDE instance (FTP) (SSH) Other code (dashboard etc.) IDE instance IDE instance (Normal) (Normal) Monday, October 22, 12
  64. 64. Monday, October 22, 12
  65. 65. Architect can do Multiple instances of same plugin Run independently But in the same process Monday, October 22, 12
  66. 66. Monday, October 22, 12
  67. 67. Monday, October 22, 12
  68. 68. HERE’S SOMETHING COOL Monday, October 22, 12
  69. 69. Centralized eventbus Loose coupling between plugins No hard dependencies! Can also do inter-context communication Monday, October 22, 12
  70. 70. React on event Other plugin Event bus Emit event Plugin Monday, October 22, 12
  71. 71. Monday, October 22, 12
  72. 72. Monday, October 22, 12
  73. 73. And now scale up Need something inter-server Swap it with i.e. Redis PubSub Plugins will never notice Modular awesomeness! Monday, October 22, 12
  74. 74. P ro g ra m ☑ C l o u d9 ID E? ☑ G row i n g pai n s ☑ I n t ro du c i n g Arc hitec t ☐ Le sson s learn ed Monday, October 22, 12
  75. 75. Modularize in feature blocks Don’t over engineer Don’t create too small blocks They aren’t interfaces! Monday, October 22, 12
  76. 76. Use dependency injection Architect (JavaScript) StructureMap (.NET) Spring (Java) Monday, October 22, 12
  77. 77. Avoid context switching Less code! Less errors! Less boilerplate! Monday, October 22, 12
  78. 78. Loose coupling Use an event bus Smaller dependency graph Monday, October 22, 12
  79. 79. github.com/c9/architect Monday, October 22, 12
  80. 80. Happy coding! Monday, October 22, 12
  81. 81. http://c9.io Sergi Mansilla @sergimansilla github.com/sergi Monday, October 22, 12

×