Your SlideShare is downloading. ×
0
Best practices for JavaScript RIAs   Carlos Ble | www.carlosble.com | @carlosble            Thanks to MadridJS.org        ...
Know the history
Table of contents●    Is it an application or is it a website?●    Is it a library, a framework, or application code?●    ...
What kind of JavaScript are you               writing?●    For frameworks and libraries:       if (someVariable === undefi...
TDD with JavaScript●    Tddjs.com●    DirigidoPorTests.com/el-libro
Testing toolsThere are new tools every day! Some tools I use, thanks to @pasku1 & @eamodeorubio(follow these guys):      J...
Testing Rules                         &                  Test-First Rules●    Test-first is absolutely different from test...
Widgets are objects, not pictures    
Events: DOM level 0 – Traditional model        (one2one: a nice kind of dependency injection)     Events: Observer (one2ma...
Passive View    http://martinfowler.com/eaaDev/PassiveScreen.html
Factory                      Singleton                           More patterns:  http://addyosmani.com/resources/essential...
Optimal code for machines         is hard to read for humans●    Dont write code for machines, write it for humans●    Do ...
Smart client, dumb server●  Let the client side application contain all the businesslogic you can.●  Keep the server just ...
Sample app: LiveTeamApp
Conclusions● JavaScript is too big. Consider the context to makedecisions.● Retrieve best practices from the desktop devel...
Upcoming SlideShare
Loading in...5
×

Best practices for JavaScript RIAs

2,822

Published on

Published in: Technology

Transcript of "Best practices for JavaScript RIAs"

  1. 1. Best practices for JavaScript RIAs Carlos Ble | www.carlosble.com | @carlosble Thanks to MadridJS.org January 2013
  2. 2. Know the history
  3. 3. Table of contents● Is it an application or is it a website?● Is it a library, a framework, or application code?● Am I test-driving the code or not?● Testing tools● Testing techniques● Design patterns and architecture● Client-Sever?
  4. 4. What kind of JavaScript are you writing?● For frameworks and libraries:       if (someVariable === undefined)...● For applications, without automated tests:● Test-first JavaScript:   if (someVariable)...   - Duck typing is OK. - No need for lots of JavaScript patterns. - Write code for humans. Functional or Object Oriented? Just make it SOLID●
  5. 5. TDD with JavaScript● Tddjs.com● DirigidoPorTests.com/el-libro
  6. 6. Testing toolsThere are new tools every day! Some tools I use, thanks to @pasku1 & @eamodeorubio(follow these guys): Jasmine/Mocha Jasmine-node Chai – chaijs.com CasperJS / PhantomJS JsTestDriver Believe me, tools are there to support concepts,they are not important themselves!
  7. 7. Testing Rules & Test-First Rules● Test-first is absolutely different from testing.● Do not mock artifacts you dont own.● Use stubs for queries and mocks/spies for actions.● Exploratory testing is always necessary.
  8. 8. Widgets are objects, not pictures    
  9. 9. Events: DOM level 0 – Traditional model (one2one: a nice kind of dependency injection)     Events: Observer (one2many) & Pub/Sub (many2many)
  10. 10. Passive View    http://martinfowler.com/eaaDev/PassiveScreen.html
  11. 11. Factory Singleton     More patterns: http://addyosmani.com/resources/essentialjsdesignpatterns/book
  12. 12. Optimal code for machines is hard to read for humans● Dont write code for machines, write it for humans● Do you really have performance metrics?● Google Closure Compiler● CoffeeScript● Do performance testing often
  13. 13. Smart client, dumb server● Let the client side application contain all the businesslogic you can.● Keep the server just as an event bus for clients tointeract with each other.● Examples: - TeamMonitor in LiveTeamApp.com - Skype and TeamViewer clients can connect directlybetween them (OK, this is not JavaScript).● Advantages: - Ease of testing. - Ease of maintenance. - Scalability.
  14. 14. Sample app: LiveTeamApp
  15. 15. Conclusions● JavaScript is too big. Consider the context to makedecisions.● Retrieve best practices from the desktop developmentage, those days back in the 90s.● Read books, the good ones dont get old.● Try to understand the concepts, not just the tools.● You usually dont need frameworks you need libraries.● Care about your code and your tests . Test-driveyour code.
  1. A particular slide catching your eye?

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

×