Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ColdBox Hierarchical MVC - Transform Your Monolith

957 views

Published on

The ColdBox Platform was the first conventions based MVC framework for ColdFusion. It has evolved and become the de-facto standard for building scalable and modern ColdFusion applications. Come learn about hierarchical MVC and modularization to scale your legacy or new applications to a new modern era.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

ColdBox Hierarchical MVC - Transform Your Monolith

  1. 1. Hierarchical MVC Transform your Monolith
  2. 2. WHO AM I? • Luis Majano - Computer Engineer • El Salvador • Houston,Texas • Computer Engineer • CEO of Ortus Solutions • Creator of many boxes www.ortussolutions.com @ortussolutions @lmajano
  3. 3. AGENDA • What is the problem? • Monolithic Applications • HMVC • Modular Architecture • ColdBox Modules
  4. 4. “Software is always bound to change”
  5. 5. THE LEGACY PROBLEM
  6. 6. LEGACY PROBLEM • Gives CFML a bad name • Security Issues • Performance Issues • Employee Issues • Development Issues • Finding Developer Issues
  7. 7. LEGACY PROBLEM •>35% No MVC •>60% No DI •>55% No Testing FuseBox is NOT MVC
  8. 8. LIKE MY CFML APP? • MVC Framework or spaghetti hell? • OO or cfinclude hell? • Automated Tests? Continuous Integration? • Agile/Scrum Methodologies? • Source Control? (Zip files don’t count!) • Continuous Delivery? Container Strategy? • Developer Automation?
  9. 9. Monolithic Apps
  10. 10. What do we do?
  11. 11. BACK TO THE SCHOOL OF ARCHITECTURE
  12. 12. 1. COHESION - COUPLING
  13. 13. 2. MVC • Separates layers of concerns • Helps enforce OO • Specialized team members • but • Layers are still tightly coupled • MVC Monoliths
  14. 14. 3. N-TIER - MEXICAN CHALUPA • Add more layers for organization • Layers are still tightly coupled • Still monolithic!
  15. 15. 4. HMVC
  16. 16. 4. HMVC • Evolution of MVC • No more lasagna • Independent MVCTriads • Benefits • Higher Cohesion • Lower Coupling • Modularization • Better Organization • Reusability • Extensibility • Testability
  17. 17. 5. MICROSERVICES AN APPROACH TO DEVELOPING A SINGLE APPLICATION AS A SUITE OF SMALL SERVICES, EACH RUNNING IN ITS OWN PROCESS AND COMMUNICATING WITH LIGHTWEIGHT MECHANISMS. Martin Fowler
  18. 18. 5. MICROSERVICES M C V M C V M C V
  19. 19. • Make legacy code updates less intimidating • Fewer resources required to maintain fault tolerance • Versionable & maintainable • Short release cycles • Monolithic apps can be evolved piece by piece • Identify -> Break Out -> Scale 5. MICROSERVICES
  20. 20. HMVC Microservices + FORMULA FOR SUCCESS
  21. 21. A FUNDAMENTAL CHANGE IN APPROACH OR UNDERLYING ASSUMPTIONS. PARADIGM SHIFT: MODERNIZE…
  22. 22. Monolithic) App) App#Security# Billing# Blog# Cart# User# Admin# EVOLVETO HMVC MODULARITY
  23. 23. WHAT IS A MODULE? "In structured design and data-driven design, a module is a generic term used to describe a named and addressable group of program statements” 
 by Craig Borysowich (ChiefTechnologyTactician) “A software module is a deployable, manageable, natively reusable, composable, stateless unit of software that provides a concise interface to consumers.” 
 by Kirk Knoernschild
  24. 24. MODULAR ARCHITECTURE • Break up a monolithic application • Individual logical parts that work in unison • Separation of concerns • Reusability concerns • Manageable dependencies “As a system evolves, It’s complexity will increase unless work is done to maintain or reduce it.” 
 Lehman’s 2nd Law of software evolution
  25. 25. COLDBOX MODULES = SUPER POWERS • Apply HMVC • Module = MVCTriad (Self-Contained) • Addressable • Composed • Dependencies • Runtime Installed • Reloaded • Unloaded Available since v3.0.0 (2011)
  26. 26. COLDBOX MODULES ARE OLD Available since v3.0.0 (2011)
  27. 27. COLDBOX MODULETRIADS Host%Application% Security% News% RSS% eStore% Admin% Users% Comments% Posts% Billing%
  28. 28. WHAT DOYOU GET? • Full MVCTriad • Automatic WireBox (DI) Mappings • Automatic CFML Mappings • Automatic Interceptors • Overridable Settings • Environment Detection
  29. 29. Anatomy of a Module ModuleConfig.cfc handlers layouts models modules views Module Name
 (unique on disk) box.json
  30. 30. { "name":"cbSwagger-shell", "version":"1.1.0", "slug":"cbSwagger-shell", "private":false, "dependencies":{ "coldbox":"^4.3.0", "workbench":"git+https://github.com/Ortus-Solutions/unified-workbench.git", "cbjavaloader":">1.0.0", "swagger-sdk":">0.0.9" }, "devDependencies":{ "testbox":"^2.4.0" }, "installPaths":{ "coldbox":"coldbox/", "testbox":"testbox/", "cbjavaloader":"modules/cbjavaloader/", "swagger-sdk":"modules/swagger-sdk/", "workbench":"workbench" }, "testbox":{ "runner":"http://localhost:49616" }, "scripts":{ "postVersion":"recipe workbench/bump.boxr" } } box.json
  31. 31. MODULECONFIG.CFC • Simple CFC • Bootstraps your module • Must exist in the root of your module folder • Has public properties • configure() for configuration • 2 callback methods: onLoad(), onUnload() • Tier-detection enabled • It’s an interceptor too!
  32. 32. MODULECONFIG.CFC
  33. 33. MODULECONFIG.CFC PROPERTIES // Module Properties     this.title              = "cbswagger";     this.author             = "Jon Clausen <jon_clausen@silowebworks.com>";     this.webURL             = "https://github.com/coldbox-modules/cbSwagger";     this.description        = "Swagger API documentation from your routes";     this.version            = "@build.version@+@build.number@";     // If true, looks for views in the parent first, if not found, then in the module. Else vice-versa     this.viewParentLookup   = true;     // If true, looks for layouts in the parent first, if not found, then in module. Else vice-versa     this.layoutParentLookup = true;     // Module Entry Point     this.entryPoint         = "cbswagger";     // Model Namespace     this.modelNamespace     = "cbswagger";     // CF Mapping     this.cfmapping          = "cbswagger";     // Auto-map models     this.autoMapModels      = true;     // Module Dependencies That Must Be Loaded First, use internal names or aliases     this.dependencies       = [ "swagger-sdk" ];
  34. 34. MODULECONFIG.CFC METHODS
  35. 35. MODULECONFIG.CFCCONFIGURE function configure(){         settings = {             caching = false,             mailTo = "lmajano@ortussolutions.com"         };         layoutSettings = { defaultLayout = "relax.cfm" };         i18n = {             resourceBundles = {                 "cbcore" = "#moduleMapping#/i18n/cbcore"             },             defaultLocale = "en_US",             localeStorage = "cookie"         };         interceptorSettings = {             // ContentBox Custom Events             customInterceptionPoints = arrayToList( [                 // Code Rendering                 "cb_onContentRendering", "cb_onContentStoreRendering"             ] )         };         routes = [             //Module Root Requests             { pattern="", handler="Main", action="index" },             // Convention Route             { pattern=":handler/:action?" }         ];     }
  36. 36. Bonus: ModuleConfig is also an interceptor box install cors
  37. 37. EXECUTION FROM URL Event=[module:][package.]handler[.action]
 SES=/module/package/handler/action Internally #runEvent( ‘module:users.dashboard' )#
  38. 38. LEVERAGING WIREBOX • this.autoMapModels = true
 • Automatically maps all your models to • {modelName}@{moduleName}
 • property name=“builder” inject=“builder@qb”;
  39. 39. MODULE Module Module Module Module
  40. 40. Bundle Module Module Module Module Bundles
  41. 41. Thanks! Go Modularize!

×