0
large                           Architecting                         node.js                           applicationsMonday,...
@sergimansillaMonday, October 22, 12
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 a...
Normal developersMonday, October 22, 12
JavaScript DeveloperMonday, October 22, 12
Cloud9 IDE - http://c9.ioMonday, October 22, 12
Real                         debuggingMonday, October 22, 12
(Smart!)                         Code completionMonday, October 22, 12
Static                         analysisMonday, October 22, 12
Free                         LinuxMonday, October 22, 12                         VM
Bring your own machineMonday, October 22, 12
Real terminalMonday, October 22, 12
CollaborationMonday, October 22, 12
See each other type              Debug together              Productivity++Monday, October 22, 12
Create                         Deploy                      Run/Debug                             Share            TestMond...
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 a...
10,000s                         LOC                         of JavaScriptMonday, October 22, 12
dynamic,                           weakly                         typed                           languageMonday, October ...
one                         singleMonday, October 22, 12                         thread
Openshift       Cloud9 datacenter                                      Remote VM                         IDE server   Remo...
Pure madnessMonday, October 22, 12
ModularizationMonday, October 22, 12
Black                         box                           codingMonday, October 22, 12
Monday, October 22, 12
Java/.NET      import(s)            Node.js      requireMonday, October 22, 12
Great for      re requi                         abstractingMonday, October 22, 12                         away
re requi                         Not Great for                         application                         modularityMonda...
re requi                         Relies on FS                           duplicated modules                          maps t...
Dependency error handling     coding time           compile time   run time                                               ...
How to fix it?       Static dependency list         Resolve at startup       Named services                 No FS required...
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...
Architect                         github.com/c9/architectMonday, October 22, 12
Architect             Everything is a plugin             Plugins can consume plugins             An application is just a ...
Dependency model                     require          runtime                   Architect      compile timeMonday, October...
Dependency error handling                               Architect  coding time             compile time              run t...
Monday, October 22, 12
Declare entity ‘presenter’ with behavior       Use ‘presenter’ to do a presentationMonday, October 22, 12
Dependency model                         Presenter             PresentationMonday, October 22, 12
Express our model                             package.json                           Builds dependency tree               ...
Monday, October 22, 12
What’s next?      Wrap in Architect plugin code      Extract the code      Make two pluginsMonday, October 22, 12
Function                                signature                         Call when doneMonday, October 22, 12
Architect plugin codeModule.exports               Options - we’ll get to that               Imports - everything you ‘cons...
Monday, October 22, 12
Monday, October 22, 12
Easy to test                              Mock dependenciesMonday, October 22, 12
Assert ‘dance’ is called 11 timesMonday, October 22, 12
No black magic                Specify dependency model      Feed architect a config file                 Call ‘createApp’M...
Monday, October 22, 12
Monday, October 22, 12
Configuration                Per-plugin options                No global options object                Specify in config f...
Monday, October 22, 12
Monday, October 22, 12
Options                         Automatically passed in at startup      Options are also dependencies                     ...
Monday, October 22, 12
Monday, October 22, 12
Architect makes you think of your app as          chunks of functionality        rather than sets of classesMonday, Octobe...
Think ‘chunks of functionality’           Implicit type constraints                                Keep implementation pri...
How does Cloud9 use it?                Open source version                Local version (OS + sync)                Hosted ...
Monday, October 22, 12
Swap feature per                               implementation                         On Open source: talk local filesyste...
Here is something your                          DI framework can’t doMonday, October 22, 12
Single node.js process                                        IDE instance   IDE instance                                 ...
Monday, October 22, 12
Architect can do             Multiple instances of same plugin                             Run independently             B...
Monday, October 22, 12
Monday, October 22, 12
HERE’S SOMETHING COOLMonday, October 22, 12
Centralized eventbus       Loose coupling between plugins       No hard dependencies!       Can also do inter-context comm...
React on event                Other plugin                                                Event                           ...
Monday, October 22, 12
Monday, October 22, 12
And now scale up       Need something inter-server       Swap it with i.e. Redis PubSub       Plugins will never notice   ...
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 lea...
Modularize in feature blocks                Don’t over engineer                Don’t create too small blocks              ...
Use dependency injection                Architect (JavaScript)                StructureMap (.NET)                Spring (J...
Avoid context switching                Less code!                Less errors!                Less boilerplate!Monday, Octo...
Loose coupling                         Use an event bus                         Smaller dependency graphMonday, October 22...
github.com/c9/architectMonday, October 22, 12
Happy coding!Monday, October 22, 12
http://c9.io                                            Sergi Mansilla                                         @sergimansi...
Upcoming SlideShare
Loading in...5
×

Architecting large Node.js applications

26,379

Published on

Sergi Mansilla introduces one of the main components to hold Cloud9's architecture together: Architect.

Published in: Technology
1 Comment
42 Likes
Statistics
Notes
  • Hi Sergi,

    I just came across your presentation and thought it is a very interesting approach to organize NodeJs applications.

    I am evaluating the Architect module to use on a project and have a question about how (if possible) to share the Architect plugins with applications that don't use Architect. I don't think it is possible without some work to clean the plugins to make it useable in other applications.

    Also, how would we package these plugins in npm to distribute them?

    Thanks a lot in advance for taking the time to answer my question Sergi.

    Quan
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
26,379
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
401
Comments
1
Likes
42
Embeds 0
No embeds

No notes for slide

Transcript of "Architecting large Node.js applications"

  1. 1. large Architecting node.js applicationsMonday, October 22, 12
  2. 2. @sergimansillaMonday, 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 dMonday, October 22, 12
  4. 4. Normal developersMonday, October 22, 12
  5. 5. JavaScript DeveloperMonday, October 22, 12
  6. 6. Cloud9 IDE - http://c9.ioMonday, October 22, 12
  7. 7. Real debuggingMonday, October 22, 12
  8. 8. (Smart!) Code completionMonday, October 22, 12
  9. 9. Static analysisMonday, October 22, 12
  10. 10. Free LinuxMonday, October 22, 12 VM
  11. 11. Bring your own machineMonday, October 22, 12
  12. 12. Real terminalMonday, October 22, 12
  13. 13. CollaborationMonday, October 22, 12
  14. 14. See each other type Debug together Productivity++Monday, October 22, 12
  15. 15. Create Deploy Run/Debug Share TestMonday, 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 dMonday, October 22, 12
  17. 17. 10,000s LOC of JavaScriptMonday, October 22, 12
  18. 18. dynamic, weakly typed languageMonday, October 22, 12
  19. 19. one singleMonday, October 22, 12 thread
  20. 20. Openshift Cloud9 datacenter Remote VM IDE server Remote VM Remote VMMonday, October 22, 12
  21. 21. Pure madnessMonday, October 22, 12
  22. 22. ModularizationMonday, October 22, 12
  23. 23. Black box codingMonday, October 22, 12
  24. 24. Monday, October 22, 12
  25. 25. Java/.NET import(s) Node.js requireMonday, October 22, 12
  26. 26. Great for re requi abstractingMonday, October 22, 12 away
  27. 27. re requi Not Great for application modularityMonday, October 22, 12
  28. 28. re requi Relies on FS duplicated modules maps to folder names Hard to configure moduleMonday, October 22, 12
  29. 29. Dependency error handling coding time compile time run time ! OM - BO KA - Server crash - Unhappy customers - Developer gets firedMonday, October 22, 12
  30. 30. How to fix it? Static dependency list Resolve at startup Named services No FS required Easy configuration Pass an objectMonday, 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 dMonday, October 22, 12
  32. 32. Architect github.com/c9/architectMonday, October 22, 12
  33. 33. Architect Everything is a plugin Plugins can consume plugins An application is just a set of pluginsMonday, October 22, 12
  34. 34. Dependency model require runtime Architect compile timeMonday, October 22, 12
  35. 35. Dependency error handling Architect coding time compile time run time - Happy customers - Fails before release - Developer keeps jobMonday, October 22, 12
  36. 36. Monday, October 22, 12
  37. 37. Declare entity ‘presenter’ with behavior Use ‘presenter’ to do a presentationMonday, October 22, 12
  38. 38. Dependency model Presenter PresentationMonday, October 22, 12
  39. 39. Express our model package.json Builds dependency tree without executing codeMonday, October 22, 12
  40. 40. Monday, October 22, 12
  41. 41. What’s next? Wrap in Architect plugin code Extract the code Make two pluginsMonday, October 22, 12
  42. 42. Function signature Call when doneMonday, October 22, 12
  43. 43. Architect plugin codeModule.exports Options - we’ll get to that Imports - everything you ‘consume’ Register - invoke when doneMonday, October 22, 12
  44. 44. Monday, October 22, 12
  45. 45. Monday, October 22, 12
  46. 46. Easy to test Mock dependenciesMonday, October 22, 12
  47. 47. Assert ‘dance’ is called 11 timesMonday, 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 fileMonday, 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 presentMonday, 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 classesMonday, October 22, 12
  58. 58. Think ‘chunks of functionality’ Implicit type constraints Keep implementation private Swap features instead of interfacesMonday, October 22, 12
  59. 59. How does Cloud9 use it? Open source version Local version (OS + sync) Hosted version Normal FTP SSHMonday, 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 bridgeMonday, October 22, 12
  62. 62. Here is something your DI framework can’t doMonday, 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 processMonday, October 22, 12
  66. 66. Monday, October 22, 12
  67. 67. Monday, October 22, 12
  68. 68. HERE’S SOMETHING COOLMonday, October 22, 12
  69. 69. Centralized eventbus Loose coupling between plugins No hard dependencies! Can also do inter-context communicationMonday, October 22, 12
  70. 70. React on event Other plugin Event bus Emit event PluginMonday, 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 edMonday, 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 graphMonday, October 22, 12
  79. 79. github.com/c9/architectMonday, October 22, 12
  80. 80. Happy coding!Monday, October 22, 12
  81. 81. http://c9.io Sergi Mansilla @sergimansilla github.com/sergiMonday, October 22, 12
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×