Joomla Frameworks Kung Fu

7,912 views
8,070 views

Published on

My presentation about developing high quality code at JandBeyond 2011.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
7,912
On SlideShare
0
From Embeds
0
Number of Embeds
5,517
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Joomla Frameworks Kung Fu

  1. 1. J and Beyond Conference<br />The Netherlands, May 2011<br />www.jandbeyond.org<br />Joomla! <br />FrameworkS<br />kung Fu<br />Oleg nesterov<br />
  2. 2. Why you can believe me<br />
  3. 3. What is this about?<br />High Quality Code<br />Not Repeating Yourself<br />
  4. 4. WHY It’s IMportant<br />
  5. 5. WHY It’s IMportant<br />70%<br />spaghetti code<br />
  6. 6. Agenda<br />What is a framework?<br />Developing with Joomla 1.5 framework.<br />Other frameworks for Joomla.<br />
  7. 7. WHAT IS A FRAMEWORK<br />
  8. 8. A set of tools which allows you to concentrate on the business logic of your <br />app while it takes up everything else!<br />
  9. 9. GENERAL<br />ARCHITECTURE<br />
  10. 10. GENERAL<br />ARCHITECTURE<br />
  11. 11. SECURITY<br />
  12. 12. SECURITY<br />
  13. 13. DATABASE<br />MANAGEMENT<br />
  14. 14. DATABASE<br />MANAGEMENT<br />
  15. 15. PATTERNS:<br />MVC, Factory, etc.<br />
  16. 16. PATTERNS:<br />MVC, Factory, etc.<br />
  17. 17. FILES & CLASSES<br />MANAGEMENT<br />
  18. 18. FILES & CLASSES<br />MANAGEMENT<br />
  19. 19. DISPATCHING<br />
  20. 20. DISPATCHING<br />
  21. 21. ROUTINE TASKS<br />
  22. 22. ROUTINE TASKS<br />
  23. 23. OVERRIDE IT<br />
  24. 24. OVERRIDE IT<br />
  25. 25. FULLFIL 3 OF MY WISHES<br />1. Give me a full-featured webshop,<br />2. test it,<br />3. and beer please.<br />
  26. 26. Why you can believe me<br />WHAT J! FW OFFERS<br />
  27. 27. Why you can believe me<br />WHAT J! FW OFFERS<br />
  28. 28. YOU CAN CREATE GOOD CODE WITH JOOMLA!<br />
  29. 29. Why you can believe me<br />J! GENERAL ARCHITECTURE<br />Application Base Cache Client DatabaseDocumentEnvironmentError Event File system Filter HTML Installer LanguageMailPlugin Registry Session Template UserUtilities and more…<br />… not bad<br />
  30. 30. Why you can believe me<br />SECURITY<br />FILTER INPUT, ESCAPE OUTPUT!<br />JRequest<br />JDatabase::Quote, getEscaped, int<br />http://shiflett.org/blog/2005/feb/my-top-two-php-security-practices<br />http://docs.joomla.org/Developers#Security<br />
  31. 31. Why you can believe me<br />Files INCLUDING<br />JLoader<br />jimport<br />require_once<br />
  32. 32. AUTOLOADING<br />System Plugin<br />Loader Class<br />registers<br />
  33. 33. COMPONENT DISPATCHING<br />Joomla 1.5 way<br />
  34. 34. COMPONENT DISPATCHING<br />MAIN CONTROLLER<br />Controller 1<br />Controller 2<br />…<br />Controller n<br />Joomla 1.5 way<br />
  35. 35. COMPONENT DISPATCHING<br />MAIN CONTROLLER<br />In fact: <br />0 controllers<br />Joomla 1.5 way<br />
  36. 36. COMPONENT DISPATCHING<br />MASTER CONTROLLER<br />Controller 1<br />Controller 2<br />…<br />Controller n<br />http://docs.joomla.org/JController_and_its_subclass_usage_overview<br />Joomla 1.6 way<br />
  37. 37. COMPONENT DISPATCHING<br />BASE DISPATCHER<br />Component Dispatcher<br />dispatch()<br />
  38. 38. COMPONENT DISPATCHING<br />MyDispatcher::dispatch(array('component_name' => mycp', 'default_view' => ‘my‘ ));<br />1 line of code<br />
  39. 39. MVC<br />Model<br />Controller<br />View<br />User<br />
  40. 40. NO FRAMEWORK WILL HELP YOU IF YOU DON’T UNDERSTAND MVC!<br />
  41. 41. СONTROLLER<br />IS THE BOSS!<br />
  42. 42. Controller<br />Getting request data;<br />Getting model & view instances;<br />Updating model states;<br />Calling model action methods (e.g. delete, save, remove);<br />Calling view methods to render a template.<br />Database tasks;<br />Manipulating model data;<br />Rendering templates.<br />
  43. 43. MODEL IS<br />A HARD WORKER!<br />
  44. 44. MODEL<br />Storing a state;<br />Performing database tasks; <br />Formatting data;<br />…all other data tasks.<br />Getting request data; Rendering templates.<br />
  45. 45. VIEW<br />IS A STYLIST!<br />
  46. 46. VIEW<br />Rendering templates<br />
  47. 47. MVC IN JOOMLA!<br />JCONTROLLER<br />JMODEL<br />JVIEW<br />
  48. 48. REAL MVC WITH J?<br />A simple list with filtering<br />
  49. 49. REAL MVC WITH J?<br />request<br />Controller<br />Model<br />state<br />model with updated state<br />View<br />display()<br />
  50. 50. REAL MVC WITH J?<br />request<br />Controller<br />Model<br />state<br />model with updated state<br />View<br />no state<br />display()<br />
  51. 51. REAL MVC WITH J!<br />Make JController::getModel method to store a model<br />
  52. 52. 1 DB TABLE = 1 MVC<br />
  53. 53. A TYPICAL J! PAGE<br />
  54. 54. A TYPICAL J! PAGE<br />BORING TASKS <br />
  55. 55. SEND BORING TASKS<br />TO YOUR FRAMEWORK<br />
  56. 56. Boring tasks<br />It’s all about CRUD, both on the back-end & front-end<br />
  57. 57. Boring tasks<br />IT’s all about lists & forms<br />
  58. 58. Boring tasks<br />Base Classes<br />code<br />
  59. 59. WHERE TO STORE IT?<br />SYSTEM PLUGIN<br />LIBRARIES FOLDER<br />COMPONENT<br />
  60. 60. BENEFITS FROM PHP 5.x<br />Magic methods,<br />Interfaces,<br />Exceptions,<br />…<br />it’s high time to implement them!<br />
  61. 61. NOOKU FRAMEWORK: A MUST SEE FOR EVERY J! DEVELOPER!<br />
  62. 62. Why you can believe me<br />NOOKU FW<br />KLoader,<br />KFactory,<br />Mixins,<br />HMVC,<br />…<br />That is awesome!<br />
  63. 63. CMSLAYER: A DIOSCOURI’S CODEBASE FOR LOADING EXTENSIONS ON DIFFERENT SYSTEMS!<br />
  64. 64. CMSLAYER INTERFACE<br />Implementation 1<br />Implementation 2<br />Implementation n<br />cmsLayer interface<br />cmsLayer base<br />
  65. 65. CMSLAYER CODEBASE<br />Feature1<br />Feature 2<br />Feature n<br />cmsLayer base<br />
  66. 66. CMSLAYER<br />Joomla!<br />Drupal<br />WP<br />cmsLayer<br />product<br />
  67. 67. Why you can believe me<br />THANKS FOR COMING!<br />http://twitter.com/onesterov<br />http://onesterov.com<br />http://www.slideshare.net/onesterov<br />http://mindk.com<br />nesterov.oleg@gmail.com<br />WRITE GOOD CODE & BE HAPPY<br />

×