Posted By

marcio on 01/25/10


Tagged

javascript pattern Development


Versions (?)

Javascript pattern development


 / Published in: JavaScript
 

comparativa de diferentes patrones: http://www.klauskomenda.com/code/javascript-programming-patterns/

  1. var myAPP = function() {
  2. var private_var;
  3. var private_method = function(){
  4. // do stuff here
  5. }
  6. return {
  7. public_method_1 : function() {
  8. // do stuff here
  9. },
  10. public_method_2 : function() {
  11. // do stuff here
  12. }
  13. };
  14. }();
  15.  
  16. // initialize the function
  17. myAPP.init();
  18.  
  19.  
  20. //otra version
  21. var myAPP = function () {
  22. // set some configuation
  23. var config = {};
  24.  
  25. var init = function () {
  26. // set up the foundations
  27. };
  28.  
  29. // private function
  30. var anotherFuntion = function () {
  31.  
  32. };
  33.  
  34. return {
  35. // set up which functions should be public
  36. init: init
  37. };
  38. }();
  39.  
  40. // initialize the function
  41. myAPP.init();

Report this snippet  

You need to login to post a comment.