Upload
oleg-nesterov
View
6.475
Download
1
Embed Size (px)
DESCRIPTION
My presentation about developing high quality code at JandBeyond 2011.
Citation preview
JOOMLA! FRAMEWORKSKUNG FU
OLEG NESTEROV
J and Beyond ConferenceThe Netherlands, May 2011www.jandbeyond.org
High Quality Code
Not Repeating Yourself
70%
spaghetti code
What is a framework?
Developing with Joomla 1.5 framework.
Other frameworks for Joomla.
WHAT IS A FRAMEWORK
A set of tools which allows you to concentrate on the business logic of your app while it takes up everything else!
GENERALARCHITECTURE
GENERALARCHITECTURE
SECURITY
SECURITY
DATABASEMANAGEMENT
DATABASEMANAGEMENT
PATTERNS:MVC, Factory, etc.
PATTERNS:MVC, Factory, etc.
FILES & CLASSESMANAGEMENT
FILES & CLASSESMANAGEMENT
DISPATCHING
DISPATCHING
ROUTINE TASKS
ROUTINE TASKS
OVERRIDE IT
OVERRIDE IT
1. Give me a full-featured webshop,2. test it,3. and beer please.
FULLFIL 3 OF MY WISHES
Overriding / Hooking
Routine Tasks
Dispatching
Autoloading
MVC
Database
Security
Architecture
Overriding / Hooking
Routine Tasks
Dispatching
Autoloading
MVC
Database
Security
Architecture
YOU CAN CREATE GOOD CODE WITH JOOMLA!
Application Base Cache Client Database
Document Environment Error Event File
system Filter HTML Installer Language Mail Plugin
Registry Session Template User Utilities and more…
… not bad
FILTER INPUT, ESCAPE OUTPUT!
JRequestJDatabase::Quote, getEscaped, int
http://shiflett.org/blog/2005/feb/my-top-two-php-security-practiceshttp://docs.joomla.org/Developers#Security
JLoaderjimportrequire_once
Loader Classregisters
System Plugin
Joomla 1.5 way
Joomla 1.5 way
MAIN CONTROLLER
Controller 1
Controller 2
Controller n…
Joomla 1.5 way
MAIN CONTROLLER
In fact: 0 controllers
Joomla 1.6 way
MASTER CONTROLLER
Controller 1
Controller 2
Controller n…
http://docs.joomla.org/JController_and_its_subclass_usage_overview
BASE DISPATCHER
Component Dispatcher
dispatch()
1 line of code
MyDispatcher::dispatch(array('component_name' => mycp', 'default_view' => ‘my‘ ));
ControllerView
Model
User
NO FRAMEWORK WILL HELP YOU IF YOU DON’T UNDERSTAND MVC!
СONTROLLERIS THE BOSS!
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.
Database tasks;
Manipulating model
data;
Rendering templates.
MODEL ISA HARD WORKER!
Storing a state;
Performing database tasks;
Formatting data;
…all other data tasks.
Getting request data;
Rendering templates.
VIEWIS A STYLIST!
Rendering
templates
JCONTROLLER
JMODEL
JVIEW
A simple list with filtering
View
Controller Modelrequest state
model with updated state
display()
View
Controller Modelrequest state
model with updated state
display()
no state
Make
JController::getModel
method to store a model
1 DB TABLE = 1 MVC
BORING TASKS
SEND BORING TASKSTO YOUR FRAMEWORK
It’s all about CRUD, both
on the back-end & front-
end
IT’s all about lists &
forms
Base Classes
Boring tasks
code
SYSTEM PLUGIN
LIBRARIES FOLDER
COMPONENT
Magic methods,Interfaces,Exceptions,…
it’s high time to implement them!
NOOKU FRAMEWORK: A MUST SEE FOR EVERY J! DEVELOPER!
KLoader,KFactory,Mixins,HMVC,…
That is awesome!
CMSLAYER: A DIOSCOURI’S CODEBASE FOR LOADING EXTENSIONS ON DIFFERENT SYSTEMS!
cmsLayer base
Implementation 1
cmsLayer interface
Implementation 2
Implementation n
cmsLayer base
Feature1 Feature 2 Feature n
Joomla!
cmsLayer
DrupalWP
product
http://twitter.com/onesterov
http://onesterov.com
http://www.slideshare.net/onesterov
http://mindk.com
WRITE GOOD CODE & BE HAPPY