Upgrade to Pro — share decks privately, control downloads, hide ads and more …

It's not you, it's me - FFWD.PRO

It's not you, it's me - FFWD.PRO

General purpose Javascript frameworks are the ones that made the language popular in the past, but right now it is a risk to think about our application development and architecture just in relation to our favorite framework.

This talk highlights risks and suggest some techniques (from design patterns to snippets of code) to avoid being coupled to a specific framework.

Marco Cedaro

June 11, 2012
Tweet

More Decks by Marco Cedaro

Other Decks in Programming

Transcript

  1. About me... Frontend Cowboy Nicola Vitto Jr. Javascript Pervert Roberto

    Felter Hello, who’s speaking? Marco Cedaro @cedmax
  2. About me... Frontend Cowboy Nicola Vitto Jr. Javascript Pervert Roberto

    Felter Marco.. who? basically anyone else Hello, who’s speaking? Marco Cedaro @cedmax
  3. Actually I am: a Frontend Developer at Spreaker.com Conference organizer

    with From The Front Hello, who’s speaking? Marco Cedaro @cedmax
  4. Actually I am: a Frontend Developer at Spreaker.com Conference organizer

    with From The Front and a javascript pervert Hello, who’s speaking? Marco Cedaro @cedmax
  5. Definition frame·work n. A structure for supporting or enclosing something

    else, especially a skeletal support used as the basis for something being constructed. gen·er·al-pur·pose adj. Designed for or suitable to more than one use; broadly useful.
  6. Now

  7. Why did they get so popular? DOM access Cross browser

    implementation Shorthands Community support
  8. Long life cycle websites General purpose framework may seem the

    right solution to handle complexity http://sproutsocial.com/insights/2011/11/how-to-iphone-ipad-friendly/ - http://pressganger.blogspot.it/2012/03/blog-progress-update.html - http://news.brothersoft.com/internet-explorer-10-focuses-html5-improves-performance-16036.html
  9. Long life cycle websites General purpose framework may seem the

    right solution to handle complexity New browser, new framework version http://sproutsocial.com/insights/2011/11/how-to-iphone-ipad-friendly/ - http://pressganger.blogspot.it/2012/03/blog-progress-update.html - http://news.brothersoft.com/internet-explorer-10-focuses-html5-improves-performance-16036.html
  10. Long life cycle websites General purpose framework may seem the

    right solution to handle complexity New browser, new framework version How many patches did you make in your framework over years? http://sproutsocial.com/insights/2011/11/how-to-iphone-ipad-friendly/ - http://pressganger.blogspot.it/2012/03/blog-progress-update.html - http://news.brothersoft.com/internet-explorer-10-focuses-html5-improves-performance-16036.html
  11. Short life cycle websites Counterintuitively situation is even worse Less

    analysis and foresight http://www.cnbc.com/id/46994692/The_Worst_Jobs_for_2012 - http://indiatransportportal.com/india-transport-studies/
  12. Short life cycle websites Counterintuitively situation is even worse Less

    analysis and foresight Did you make any patch in your framework over years? http://www.cnbc.com/id/46994692/The_Worst_Jobs_for_2012 - http://indiatransportportal.com/india-transport-studies/
  13. case study Own scripts built on a known framework http://www.naba.it/newsletter_09_10/naba_n184.html

    - http://sevenspark.com/product/agility-responsive-minimal-html5-template/ - http://middleclasshell.com/republicans-ignore-catholics-when-it-comes-to-unemployment-benefits
  14. case study Own scripts built on a known framework Brand

    new website with responsive design http://www.naba.it/newsletter_09_10/naba_n184.html - http://sevenspark.com/product/agility-responsive-minimal-html5-template/ - http://middleclasshell.com/republicans-ignore-catholics-when-it-comes-to-unemployment-benefits
  15. case study Own scripts built on a known framework Brand

    new website with responsive design same old bloat code over 3g? http://www.naba.it/newsletter_09_10/naba_n184.html - http://sevenspark.com/product/agility-responsive-minimal-html5-template/ - http://middleclasshell.com/republicans-ignore-catholics-when-it-comes-to-unemployment-benefits
  16. LOVE FACT #2 What is known as a French Kiss

    in the English speaking world is called an English Kiss in France.
  17. _.each(items, function(item, i) { [...] }); Ext.each(items, function(item, i) {

    [...] }); $.each(items, function(i, item) { [...] }); items.each(function(item, i) { [...] });
  18. _.each(items, function(item, i) { [...] }); Ext.each(items, function(item, i) {

    [...] }); $.each(items, function(i, item) { [...] }); items.each(function(item, i) { [...] });
  19. _.each(items, function(item, i) { [...] }); Ext.each(items, function(item, i) {

    [...] }); $.each(items, function(i, item) { [...] }); items.each(function(item, i) { [...] });
  20. _.each(items, function(item, i) { [...] }); Ext.each(items, function(item, i) {

    [...] }); $.each(items, function(i, item) { [...] }); items.each(function(item, i) { [...] });
  21. for (var i = 0; i < items.length; i++) {

    [...] }; $.each(items, function(i, item) { [...] });
  22. for (var i = 0; i < items.length; i++) {

    [...] }; $.each(items, function(i, item) { [...] });
  23. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] };
  24. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] };
  25. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] };
  26. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] }; for (var i = -1, item;item = items[++i];) { [...] };
  27. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] }; for (var i = -1, item;item = items[++i];) { [...] };
  28. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] }; for (var i = -1, item;item = items[++i];) { [...] };
  29. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] }; for (var i = -1, item;item = items[++i];) { [...] }; var i = 0; while (i < items.length) { [...] i++; };
  30. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] }; for (var i = -1, item;item = items[++i];) { [...] }; var i = 0; while (i < items.length) { [...] i++; };
  31. for (var i = -1; ++i < items.length;) { [...]

    }; for (var i = 0; i < items.length; i++) { [...] }; for (var i = -1, item;item = items[++i];) { [...] }; var i = 0; while (i < items.length) { [...] i++; }; //and counting -> http://jsperf.com/loops/33
  32. MyNS.bind = function(func, context) { return function() { func.apply(context, arguments);

    }; } myElm.onclick = $.proxy(conf.clicked, conf); myElm.onclick = MyNS.bind(conf.clicked, conf);
  33. MyNS.bind = function(func, context) { } myElm.onclick = MyNS.bind(conf.clicked, conf);

    return function() { return func.apply(context, arguments); };
  34. var AwesomeEffect = function(id, config){ var default = { delay:

    0, duration: 500, transition: "easeOut", }; [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); //{delay: 1000, duration:100, transition: "easeOut"};
  35. var AwesomeEffect = function(id, config){ var default = { delay:

    0, duration: 500, transition: "easeOut", }; [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); //{delay: 1000, duration:100, transition: "easeOut"};
  36. var AwesomeEffect = function(id, config){ var default = { delay:

    0, duration: 500, transition: "easeOut", }; [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); //{delay: 1000, duration:100, transition: "easeOut"};
  37. var AwesomeEffect = function(id, config){ var default = { delay:

    0, duration: 500, transition: "easeOut", }; [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); //{delay: 1000, duration:100, transition: "easeOut"};
  38. var AwesomeEffect = function(id, config){ var default = { delay:

    0, duration: 500, transition: "easeOut", }; [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); //{delay: 1000, duration:100, transition: "easeOut"};
  39. var AwesomeEffect = function(id, config){ var default = { delay:

    0, duration: 500, transition: "easeOut", }; [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); //{delay: 1000, duration:100, transition: "easeOut"};
  40. MyNS.extend = function(destination, source) { return } var AwesomeEffect =

    function(id, config){ var default = { delay: 0, duration: 500, transition: "easeOut", }; var options = MyNS.extend(default, config); [...] } $.extend(default, config);
  41. MyNS.extend = function(destination, source) { return } var AwesomeEffect =

    function(id, config){ var default = { delay: 0, duration: 500, transition: "easeOut", }; var options = MyNS.extend(default, config); [...] } $.extend(default, config);
  42. MyNS.extend = function(destination, source) { return } var AwesomeEffect =

    function(id, config){ var default = { delay: 0, duration: 500, transition: "easeOut", }; var options = MyNS.extend(default, config); [...] } Ext.apply(default, config);
  43. MyNS.extend = function(destination, source) { return } var AwesomeEffect =

    function(id, config){ var default = { delay: 0, duration: 500, transition: "easeOut", }; var options = MyNS.extend(default, config); [...] } _.extend(default, config);
  44. MyNS.extend = function(destination, source) { return } var AwesomeEffect =

    function(id, config){ var default = { delay: 0, duration: 500, transition: "easeOut", }; var options = MyNS.extend(default, config); [...] } Object.extend(default, config);
  45. MyNS.extend = function(destination, source) { return } var AwesomeEffect =

    function(id, config){ var default = { delay: 0, duration: 500, transition: "easeOut", }; var options = MyNS.extend(default, config); [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); $.extend(default, config);
  46. MyNS.extend = function(destination, source) { return } var AwesomeEffect =

    function(id, config){ var default = { delay: 0, duration: 500, transition: "easeOut", }; var options = MyNS.extend(default, config); [...] } var myEff = new AwesomeEffect("myId", { duration: 100, delay: 1000 }); $.extend(default, config);
  47. MyNS.Layer = function(content, config){ config = MyNS.extend({ overlayOpacity:0.6, imageLoading: "/img/warn.gif",

    }, config); new LightBox(content, config); } MyNS.Layer("Sorry, an error occured");
  48. MyNS.Layer = function(content, config){ config = MyNS.extend({ overlayOpacity:0.6, imageLoading: "/img/warn.gif",

    }, config); new LightBox(content, config); } MyNS.Layer("Sorry, an error occured");
  49. MyNS.Layer = function(content, config){ config = MyNS.extend({ overlayOpacity:0.6, imageLoading: "/img/warn.gif",

    }, config); new LightBox(content, config); } MyNS.Layer("Sorry, an error occured");
  50. MyNS.Layer = function(content, config){ config = MyNS.extend({ overlayOpacity:0.6, imageLoading: "/img/warn.gif",

    }, config); new LightBox(content, config); } MyNS.Layer("Sorry, an error occured");
  51. MyNS.Layer = function(content, config){ config = MyNS.extend({ overlayOpacity:0.6, imageLoading: "/img/warn.gif",

    }, config); new LightBox(content, config); } MyNS.Layer("Sorry, an error occured");
  52. MyNS.Layer = function(content, config){ config = MyNS.extend({ opacity: true, modal:

    true, }, config); new FancyBox(content, config); } MyNS.Layer("Sorry, an error occured");
  53. MyNS.Layer = function(content, config){ config = MyNS.extend({ opacity: true, modal:

    true, }, config); new FancyBox(content, config); } MyNS.Layer("Sorry, an error occured");
  54. MyNS.Layer = function(content, config){ config = MyNS.extend({ opacity: true, modal:

    true, }, config); new FancyBox(content, config); } MyNS.Layer("Sorry, an error occured");
  55. MyNS.Layer = function(content, config){ config = MyNS.extend({ opacity: true, modal:

    true, }, config); new FancyBox(content, config); } MyNS.Layer("Sorry, an error occured");
  56. MyNS.Layer = function(content, config){ config = MyNS.extend({ opacity: true, modal:

    true, }, config); new FancyBox(content, config); } MyNS.Layer("Sorry, an error occured");
  57. Goals modify a single file to update menu do not

    depend on website implementation do not interfere with website implementation
  58. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  59. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  60. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  61. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  62. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  63. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  64. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  65. AJAX: MicroAjax 0.4kB DOM: TinyDOM 0.4kB DOMEvents: Vine 0.8kB OUR

    CODE: microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); }); SIZE: 1.8kB
  66. microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s

    = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  67. microAjax("static/nav.html", function (res) { $.prependBody(res); vine.bind("ftf_xsite_sel", "change", function(e){ var s

    = $.id("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  68. FTF.ajax("static/nav.html", { success: function (res) { FTF.dom.prependBody(res); FTF.evt.bind("ftf_xsite", "change", function(e){

    var s = FTF("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  69. FTF.ajax("static/nav.html", { success: function (res) { FTF.dom.prependBody(res); FTF.evt.bind("ftf_xsite", "change", function(e){

    var s = FTF("ftf_xsite"); var href = s.options[s.selectedIndex].value; if (href) { document.location.href = href; } }); });
  70. play with javascript discover your own project needs BE A

    JAVASCRIPT PERVERT let github be your playground
  71. play with javascript discover your own project needs BE A

    JAVASCRIPT PERVERT let github be your playground javascript is fun
  72. play with javascript discover your own project needs BE A

    JAVASCRIPT PERVERT let github be your playground javascript is fun javascript is lovable
  73. play with javascript discover your own project needs BE A

    JAVASCRIPT PERVERT let github be your playground javascript is fun javascript is lovable but you also need to...