0
 
Why you can  believe me 4 years of experience
Agenda Development Design MVC Other important questions  Code optimization The most popular mistakes!
Joomla Components development
Model-View-Controller
How many times did you see this? Model View Controller User updates manipulates sees uses
An application is split by 3 departments which  collaborate with each other  to bring you the best results, but they  don’...
 
MVC Controller
The controller is the boss!
You should use  a controller for Getting request data; Getting model & view instances; Updating model states; Calling mode...
You should not use  a controller for Database task; Manipulating model data; Rendering templates. model & view tasks
A Controller in Joomla
JController
display() method revealed /libraries/joomla/application/component/controller.php Gets view instance Gets model instance In...
Bad approaches for using controllers in Joomla
Good approaches for using controllers in Joomla
Bad approaches for using controllers in Joomla
Good approaches for using controllers in Joomla
MVC Model
A model is a hard worker!
You should use  a model for Storing a state; Performing database tasks; Formatting data; All other data task.
You should not use  a model for Getting request data; Rendering templates. controller & view tasks
A Model in Joomla
JModel The most  unused  model methods & properties. Why? $this->_db $this->_state $this->getDBO(); $this->setState($prope...
Bad approaches for using models in Joomla
Good approaches for using models in Joomla
Fat Model, Skinny Controller http://blog.astrumfutura.com/archives/373-The_M_in_MVC_Why_Models_are_Misunderstood_and_Unapp...
MVC View
A view is a stylist!
You should use  a view for Rendering templates; Rendering templates; Rendering templates.
You should not use  a view for Database tasks; Database tasks; Database tasks. model tasks
A view in Joomla
JView lies between a model and a template View Data Template
You should use  a Joomla view class for Getting data from models; Rearranging data (if needed); Assigning variables to tem...
Don’t put everything you have into a view!
Keep your view methods small!
You shouldn’t use PHP in template files like this
You should use it like this
Don’t use variables in view templates other than the ones you assigned to
Keep your templates clear, assign all variables in view classes!
Add CSS and JS in the view template file …  in this case they can be overwritten in a Joomla template
Joomla MVC revealed
Joomla MVC default task as it is Main component’s file request  data calls Controller default task calls JController’s dis...
The best way to figure out the Joomla framework is to dig into the code!
No, seriously Just dig into the code
After digging JController methods you can find out /libraries/joomla/application/component/controller.php How  to insert o...
Joomla MVC structures possible variants
 
 
 
Base controller approach
Base controller approach: main component file
Code Optimization
Code Optimization Write code Go! Write a bit more code Think over
A simple optimization Edit, publish, unpublish, save order, order up, order down, cancel, save, remove Base admin model Ba...
Code Documentation
Document your code http://www.phpdoc.org/ http://code.google.com/p/jsdoc-toolkit/ Every file, class, class property and me...
 
Filter input, escape output! http://shiflett.org/blog/2005/feb/my-top-two-php-security-practices http://developer.joomla.o...
Joomla Components design
We are developers, we don’t do design!
!!!!! We  are  developers, we  don’t do  design  !!!!
Design principles for developers Set proper CSS classes & IDs, but leave design for template designers That’s all!
Thanks for coming! http://twitter.com/onesterov http://onesterov.com http://jookungfu.org http://mindk-lab.com [email_addr...
Upcoming SlideShare
Loading in...5
×

Joomla Extensions Kung Fu

10,771

Published on

My presentation at Joomla and Beyond 2010 Conference about popular mistakes made by Joomla extension developers.

Published in: Technology, Business
4 Comments
6 Likes
Statistics
Notes
  • Hi there. I really appreciate the points you made. I don't think I've actually thought about it in that way. I can really appreciate how you approached the subject matter and what you said really gave me a new perspective. Thanks for taking the time to write this all out. ternak lele
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Amit Patekar, You told my mind.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Thanks Amit, I'm glad you found it useful.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Excellent tutorial , Thank you .

    Also Tienda is awesome e-commerce component.
    Till date I have never thought any thing beyond virtuemart, but now i can :)

    Regards
    Amit Patekar
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
10,771
On Slideshare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
195
Comments
4
Likes
6
Embeds 0
No embeds

No notes for slide

Transcript of "Joomla Extensions Kung Fu"

  1. 2. Why you can believe me 4 years of experience
  2. 3. Agenda Development Design MVC Other important questions Code optimization The most popular mistakes!
  3. 4. Joomla Components development
  4. 5. Model-View-Controller
  5. 6. How many times did you see this? Model View Controller User updates manipulates sees uses
  6. 7. An application is split by 3 departments which collaborate with each other to bring you the best results, but they don’t “disturb each other” at the same time!
  7. 9. MVC Controller
  8. 10. The controller is the boss!
  9. 11. You should use a controller for Getting request data; Getting model & view instances; Updating model states; Calling model action methods (e.g. delete, save, remove); Calling view methods to render a template.
  10. 12. You should not use a controller for Database task; Manipulating model data; Rendering templates. model & view tasks
  11. 13. A Controller in Joomla
  12. 14. JController
  13. 15. display() method revealed /libraries/joomla/application/component/controller.php Gets view instance Gets model instance Injects model into view Calls view’s display() method
  14. 16. Bad approaches for using controllers in Joomla
  15. 17. Good approaches for using controllers in Joomla
  16. 18. Bad approaches for using controllers in Joomla
  17. 19. Good approaches for using controllers in Joomla
  18. 20. MVC Model
  19. 21. A model is a hard worker!
  20. 22. You should use a model for Storing a state; Performing database tasks; Formatting data; All other data task.
  21. 23. You should not use a model for Getting request data; Rendering templates. controller & view tasks
  22. 24. A Model in Joomla
  23. 25. JModel The most unused model methods & properties. Why? $this->_db $this->_state $this->getDBO(); $this->setState($property, $value); $this->getState($property);
  24. 26. Bad approaches for using models in Joomla
  25. 27. Good approaches for using models in Joomla
  26. 28. Fat Model, Skinny Controller http://blog.astrumfutura.com/archives/373-The_M_in_MVC_Why_Models_are_Misunderstood_and_Unappreciated.html
  27. 29. MVC View
  28. 30. A view is a stylist!
  29. 31. You should use a view for Rendering templates; Rendering templates; Rendering templates.
  30. 32. You should not use a view for Database tasks; Database tasks; Database tasks. model tasks
  31. 33. A view in Joomla
  32. 34. JView lies between a model and a template View Data Template
  33. 35. You should use a Joomla view class for Getting data from models; Rearranging data (if needed); Assigning variables to templates; Rendering templates.
  34. 36. Don’t put everything you have into a view!
  35. 37. Keep your view methods small!
  36. 38. You shouldn’t use PHP in template files like this
  37. 39. You should use it like this
  38. 40. Don’t use variables in view templates other than the ones you assigned to
  39. 41. Keep your templates clear, assign all variables in view classes!
  40. 42. Add CSS and JS in the view template file … in this case they can be overwritten in a Joomla template
  41. 43. Joomla MVC revealed
  42. 44. Joomla MVC default task as it is Main component’s file request data calls Controller default task calls JController’s display() Model & view objects gets inserts Model into view calls JView’s display() gets Model data renders Template
  43. 45. The best way to figure out the Joomla framework is to dig into the code!
  44. 46. No, seriously Just dig into the code
  45. 47. After digging JController methods you can find out /libraries/joomla/application/component/controller.php How to insert other than the default model into your view class How to add another location for your model & view files How to set a default model state … and many more
  46. 48. Joomla MVC structures possible variants
  47. 52. Base controller approach
  48. 53. Base controller approach: main component file
  49. 54. Code Optimization
  50. 55. Code Optimization Write code Go! Write a bit more code Think over
  51. 56. A simple optimization Edit, publish, unpublish, save order, order up, order down, cancel, save, remove Base admin model Base admin controller Base admin view Helper classes Get ordering, save order, move, check out, check in, publish, remove The most used variables: option, document, view, controller, layout, etc. Everything that can be reused in templates
  52. 57. Code Documentation
  53. 58. Document your code http://www.phpdoc.org/ http://code.google.com/p/jsdoc-toolkit/ Every file, class, class property and method
  54. 60. Filter input, escape output! http://shiflett.org/blog/2005/feb/my-top-two-php-security-practices http://developer.joomla.org/security.html http://developer.joomla.org/security/articles-tutorials/258-preventing-sql-injections.html
  55. 61. Joomla Components design
  56. 62. We are developers, we don’t do design!
  57. 63. !!!!! We are developers, we don’t do design !!!!
  58. 64. Design principles for developers Set proper CSS classes & IDs, but leave design for template designers That’s all!
  59. 65. Thanks for coming! http://twitter.com/onesterov http://onesterov.com http://jookungfu.org http://mindk-lab.com [email_address]
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×