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.

JWC - Rapid application development with FOF

2,164 views

Published on

My Framework on Framework presentation from the inaugural Joomla! World Conference

Published in: Technology

JWC - Rapid application development with FOF

  1. 1. Rapid Application Developmentwith Framework on Framework (FOF)November 18th, 2012 – Joomla! World Conference
  2. 2. So, what is FOF anyway?November 18th, 2012 – Joomla! World Conference
  3. 3. I know what you’re thinking“Oh, no, not yet another framework!”November 18th, 2012 – Joomla! World Conference
  4. 4. FOF extends the Joomla! frameworkIt does not replace or undermine itNovember 18th, 2012 – Joomla! World Conference
  5. 5. DRY - Don’t Repeat YourselfI detest copying and pasting the same code, over and over and over and over and over and over and over...November 18th, 2012 – Joomla! World Conference
  6. 6. Less is moreConvention over configuration – less dev time, less code, less bugs, less maintenanceNovember 18th, 2012 – Joomla! World Conference
  7. 7. Doesn’t impose its way of thinkingNo black-box methods, multiple customizable triggers, plugin events, ...November 18th, 2012 – Joomla! World Conference
  8. 8. Plays along nicelyCompatible with Joomla! 1.5, 1.7, 2.5 and 3.0.November 18th, 2012 – Joomla! World Conference
  9. 9. Backwards compatibleNo sudden, quantum changes from one day to the nextNovember 18th, 2012 – Joomla! World Conference
  10. 10. Some historyHow it all came to beNovember 18th, 2012 – Joomla! World Conference
  11. 11. July 2009 – Base MVC classesCustom classes, extending JModel and friends, reducing copy & pasted codeNovember 18th, 2012 – Joomla! World Conference
  12. 12. September 2011 – Transformed into a frameworkBasically, I was pissed with another framework which kept on screwing me overNovember 18th, 2012 – Joomla! World Conference
  13. 13. Be the change you want to see!September 2011 – Transformed into a frameworkBasically, I was pissed with another framework which kept on screwing me overNovember 18th, 2012 – Joomla! World Conference
  14. 14. September 2012 – HMVCwhile stuck on the ground, inside a plane, for four freakin’ hours!November 18th, 2012 – Joomla! World Conference
  15. 15. May 2012 – Public releaseat the J and Beyond 2012 conferenceNovember 18th, 2012 – Joomla! World Conference
  16. 16. June 2012 – Bootstrap & jQueryIn optional Akeeba Strapper packageNovember 18th, 2012 – Joomla! World Conference
  17. 17. Being a FOF ComponentInside its mind, without visiting the 71/2 floor of a Manhattan office buildingNovember 18th, 2012 – Joomla! World Conference
  18. 18. AUDIENCEADVISORY BORING SLIDESNovember 18th, 2012 – Joomla! World Conference
  19. 19. Structure Dispatcher “triad” Controller Model View Table Helpers Toolbar
  20. 20. Structure Dispatcher The“triad” Dispatcher is the entry point (a.k.a. “router”). It will setup, Controller run and render the MVC triad. Model View Table Helpers Toolbar
  21. 21. Structure The Controller is a thin interface to push data to the model state Dispatcher and instantiate views “triad” Controller Model View Table Helpers Toolbar
  22. 22. Structure Dispatcher “triad” Controller Model View Table The Model is the workhorse. Business logic goes here. Helpers Toolbar
  23. 23. Structure Dispatcher “triad” Controller Model View Table The Table class is a hybrid data adapter, controller and model Helpers Toolbar (following J!s convention)
  24. 24. Structure Dispatcher “triad” Controller Model View Table The View fetches model state data and renders them in a meaningful way Helpers Toolbar
  25. 25. Structure Dispatcher “triad” Controller Model View The Toolbar handles Table rendering of titles, buttons and so on the Helpers Toolbar
  26. 26. Structure Dispatcher “triad” Controller Model View Non-OOP stuff.Table Basically, a nice way to say “cruft” Helpers Toolbar
  27. 27. Some general thoughts✤ Almost RESTful, but not quite✤ “Services first” approach. Built-in JSON and transparent authentication, opens the door to data provisioning for rich JS, Android, iOS etc apps✤ OAuth not supported (yet?). A custom, secure, TOTP-based transparent authentication scheme and HTTP Basic Authentication are supported, though.✤ We offer HMVC today. Actually, since October 2011.
  28. 28. Convention over Configuration
  29. 29. Convention over configuration inthe Dispatcher✤ The Dispatcher is your component’s router. It routes the request to the appropriate Controller based on conventions: ✤ A POST request gets routed to the save task ✤ A GET request to a plural view name gets routed to the browse task ✤ A front-end GET request with an ID gets routed to the read task ✤ A back-end GET request with an ID gets routed to the edit task
  30. 30. Convention over configuration inModels✤ Tables are named as #__component_view, e.g. #__todo_items✤ Auto increment field is named component_view_id, e.g. todo_item_id✤ Magic fields: enabled, created_by, created_on, modified_by, modified_on, locked_by, locked_on, hits✤ You can override defaults without copying & pasting code, ever. Copy & paste is the devil!
  31. 31. Convention over configuration inControllers✤ Default tasks (not RESTful!): browse, read, edit, add, delete, save, apply, ...✤ Customize with onBeforeMethod and onAfterMethod methods, e.g. onBeforeSave. Dont copy & paste code.✤ All MVC objects can be passed a $config array to customize them. It "flows" from dispatcher to component to model and view.✤ FOF guesses the task if its missing based on plural/singular view name and existence of ID in the query
  32. 32. Convention over configuration inViews✤ Views inherit from FOFView and its specialized children, e.g. FOFViewHtml✤ Customize using the onTask methods, e.g. onBrowse✤ The toolbar is handled outside the view, in a FOFToolbar descendant class. Override it with a toolbar.php file in the components root.✤ Magic toolbar methods, e.g. onItemsBrowse allow you to customize the toolbar without copying & pasting code.
  33. 33. Epic features
  34. 34. HMVC – Hierarchical MVC✤ Include the results of component views anywhere (other views, other component, modules, ...)✤ FOFDispatcher::getTmpInstance(‘com_foobar’, ‘items’, array(‘layout’ => ‘fancy’))->dispatch();
  35. 35. Reuse view templates✤ Load a view template from another view, component, ...✤ echo $this->loadAnyTemplate(site:com_foobar/item/form);
  36. 36. Language loading and overrides✤ Automatically loads component language files (frontend and backend)✤ Hierarchical language overriding ✤ English loads first ✤ Current site/user language loads next and overrides English
  37. 37. Media files overrides✤ Load media files like this: FOFTemplateUtils::addCSS(media://com_foobar/css/frontend.css);✤ Media overrides are inside the template folder, e.g. templates/tpl_example/media/com_foobar/css/frontend.css
  38. 38. Services first – automatic JSONand CSV views✤ Just add format=json or format=csv✤ JSON: You have an instant JSON-based remote API for your components✤ CSV: You can quickly export whatever you see in the backend to Excel, Numbers, LibreOffice, Google Docs, etc.✤ Transparent authentication support using URL parameters or HTTP Basic Authentication
  39. 39. A peek in my crystal ball
  40. 40. Are you pondering what I’mpondering?
  41. 41. Are you pondering what I’mpondering?✤ Input as an object, not as an array (yes, static methods suck)
  42. 42. Are you pondering what I’mpondering?✤ Input as an object, not as an array (yes, static methods suck)✤ Remove dependence on JModelLegacy and friends
  43. 43. Are you pondering what I’mpondering?✤ Input as an object, not as an array (yes, static methods suck)✤ Remove dependence on JModelLegacy and friends✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions
  44. 44. Are you pondering what I’mpondering?✤ Input as an object, not as an array (yes, static methods suck)✤ Remove dependence on JModelLegacy and friends✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions✤ Platform abstraction, allow use with JApplicationWeb and friends
  45. 45. Are you pondering what I’mpondering?✤ Input as an object, not as an array (yes, static methods suck)✤ Remove dependence on JModelLegacy and friends✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions✤ Platform abstraction, allow use with JApplicationWeb and friends✤ RFC 2324 implementation (client)
  46. 46. Are you pondering what I’mpondering?✤ Input as an object, not as an array (yes, static methods suck)✤ Remove dependence on JModelLegacy and friends✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions✤ Platform abstraction, allow use with JApplicationWeb and friends✤ RFC 2324 implementation (client)✤ A plan to take over the world!
  47. 47. Resources and communityhttp://akeeba.info/fof
  48. 48. CAN I HAZ SOME CODEZ?
  49. 49. Over and out.

×