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

AngularJS Modular

AngularJS Modular

Orlando Romero

November 08, 2014
Tweet

Other Decks in Programming

Transcript

  1. Modular? • Aplicación organizada en módulos • Agrupación de archivos

    por features • Estructura jerárquica recursiva
  2. La estructura por defecto o con la que nos iniciamos

    no es la más ordenada y escalable
  3. Primeros pasos en AngularJS app/ images/ scripts/ controllers.js directives.js filters.js

    services.js styles/ partials/ main.html .. bower_components/ node_modules/ Estructura de proyecto
  4. Primeros pasos en AngularJS app/ images/ scripts/ controllers.js directives.js filters.js

    services.js styles/ partials/ main.html .. bower_components/ node_modules/ Estructura de proyecto
  5. Encontrando un mejor orden app/ images/ scripts/ controllers/ home.js about.js

    contactus.js services/ contactus.js directives/ filters/ styles/ partials/ home.html about.html contactus.html test/ controllers/ home.js Estructura de proyecto
  6. app/ images/ scripts/ controllers/ home.js about.js contactus.js products.js orders.js wishilist.js

    portfolio.js services.js login.js profile.js register.js messages.js notifications.js services/ contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js … styles/ home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css partials/ home.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html test/ controllers/ home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js app/ images/ scripts/ controllers/ home.js about.js contactus.js services/ contactus.js directives/ filters/ styles/ partials/ home.html about.html contactus.html test/ controllers/ home.js app/ images/ scripts/ controllers/ home.js about.js contactus.js products.js orders.js wishilist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js home.js about.js contactus.js products.js orders.js wishilist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js services/ contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js … styles/ home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css partials/ home.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html test/ controllers/ home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js app/ images/ scripts/ controllers/ home.js about.js contactus.js products.js orders.js wishilist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js home.js about.js contactus.js products.js orders.js wishilist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js about.js contactus.js products.js orders.js wishilist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js home.js about.js contactus.js products.js orders.js wishilist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js services/ contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js … styles/ home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css partials/ home.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html home.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html test/ controllers/ home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js home.js about.js contactus.js products.js orders.js wishlist.js
  7. app/ images/ scripts/ controllers/ home.js about.js contactus.js products.js orders.js wishilist.js

    portfolio.js services.js login.js profile.js register.js messages.js notifications.js services/ contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js … styles/ home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css partials/ home.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html test/ controllers/ home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js
  8. Organización por feature contactus/ contactus-controller.js contactus-controller_test.js contactus-service.js contactus-service_test.js contactus.html contactus.css

    app/ images/ scripts/ controllers/ home.js about.js contactus.js products.js orders.js wishilist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js services/ contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js … styles/ home.css about.css contactus.css products.css orders.css wishlist.css portfolio.css services.css login.css profile.css register.css messages.css notifications.css partials/ home.html about.html contactus.html products.html orders.html wishlist.html portfolio.html services.html login.html profile.html register.html messages.html notifications.html test/ controllers/ home.js about.js contactus.js products.js orders.js wishlist.js portfolio.js services.js login.js profile.js register.js messages.js notifications.js Estructura de proyecto
  9. Organización por feature Estructura de proyecto app/ images/ styles/ components/

    website/ home/ about/ contactus/ portfolio/ services/ profile/ shop/ products/ auth/ login/ messages/ register/ contactus/ contactus.js contactus-controller.js contactus-controller_test.js contactus-service.js contactus-service_test.js contactus.html contactus.css
  10. Beneficios Estructura de proyecto app/ images/ styles/ components/ website/ home/

    about/ contactus/ contactus.js contactus-controller.js contactus-controller_test.js contactus-service.js contactus-service_test.js contactus.html contactus.css portfolio/ services/ profile/ profile.js profile-controller.js profile-controller_test.js profile-service.js profile-service_test.js profile.html profile.css shop/ products/ auth/ login/ messages/ register/ Trabajo por feature mejor centralizado Menor riesgo de mover/modificar código ajeno al feature sobre el que trabajamos
  11. Beneficios Estructura de proyecto profile/ profile.js profile-controller.js profile-controller_test.js profile-service.js profile-service_test.js

    profile.html profile.css Portable Templates adyacentes Más fácil de mantener Menor riesgo de mover código de otros features Pruebas adyacentes … Más natural
  12. Consideraciones • Mayor cantidad de archivos • Más niveles de

    carpetas • Configuración adicional para crear “builds”
  13. Automatizando clean wiredep useminPrepare concurrent autoprefixer concat ngAnnotate copy cdnify

    cssmin uglify filerev usemin htmlmin Asegurar que las declaraciones de los módulos estén antes que sus referencias Procesar las hojas de estilo por módulo Procesar los templates por módulo
  14. Más opciones • ngBoilerplate by Josh Miller • https://github.com/ngbp/ngbp •

    http://joshdmiller.github.io/ng-boilerplate/#/home • Yeoman generator for Enterprise Angular projects by Chris Gross • https://github.com/cgross/generator-cg-angular