67
JOOMLA! FRAMEWORKS KUNG FU OLEG NESTEROV J and Beyond Conference The Netherlands, May 2011 www.jandbeyond.or g

Joomla Frameworks Kung Fu

Embed Size (px)

DESCRIPTION

My presentation about developing high quality code at JandBeyond 2011.

Citation preview

Page 1: Joomla Frameworks Kung Fu

JOOMLA! FRAMEWORKSKUNG FU

OLEG NESTEROV

J and Beyond ConferenceThe Netherlands, May 2011www.jandbeyond.org

Page 2: Joomla Frameworks Kung Fu
Page 3: Joomla Frameworks Kung Fu

High Quality Code

Not Repeating Yourself

Page 4: Joomla Frameworks Kung Fu
Page 5: Joomla Frameworks Kung Fu

70%

spaghetti code

Page 6: Joomla Frameworks Kung Fu

What is a framework?

Developing with Joomla 1.5 framework.

Other frameworks for Joomla.

Page 7: Joomla Frameworks Kung Fu

WHAT IS A FRAMEWORK

Page 8: Joomla Frameworks Kung Fu

A set of tools which allows you to concentrate on the business logic of your app while it takes up everything else!

Page 9: Joomla Frameworks Kung Fu

GENERALARCHITECTURE

Page 10: Joomla Frameworks Kung Fu

GENERALARCHITECTURE

Page 11: Joomla Frameworks Kung Fu

SECURITY

Page 12: Joomla Frameworks Kung Fu

SECURITY

Page 13: Joomla Frameworks Kung Fu

DATABASEMANAGEMENT

Page 14: Joomla Frameworks Kung Fu

DATABASEMANAGEMENT

Page 15: Joomla Frameworks Kung Fu

PATTERNS:MVC, Factory, etc.

Page 16: Joomla Frameworks Kung Fu

PATTERNS:MVC, Factory, etc.

Page 17: Joomla Frameworks Kung Fu

FILES & CLASSESMANAGEMENT

Page 18: Joomla Frameworks Kung Fu

FILES & CLASSESMANAGEMENT

Page 19: Joomla Frameworks Kung Fu

DISPATCHING

Page 20: Joomla Frameworks Kung Fu

DISPATCHING

Page 21: Joomla Frameworks Kung Fu

ROUTINE TASKS

Page 22: Joomla Frameworks Kung Fu

ROUTINE TASKS

Page 23: Joomla Frameworks Kung Fu

OVERRIDE IT

Page 24: Joomla Frameworks Kung Fu

OVERRIDE IT

Page 25: Joomla Frameworks Kung Fu

1. Give me a full-featured webshop,2. test it,3. and beer please.

FULLFIL 3 OF MY WISHES

Page 26: Joomla Frameworks Kung Fu

Overriding / Hooking

Routine Tasks

Dispatching

Autoloading

MVC

Database

Security

Architecture

Page 27: Joomla Frameworks Kung Fu

Overriding / Hooking

Routine Tasks

Dispatching

Autoloading

MVC

Database

Security

Architecture

Page 28: Joomla Frameworks Kung Fu

YOU CAN CREATE GOOD CODE WITH JOOMLA!

Page 29: Joomla Frameworks Kung Fu

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

Page 30: Joomla Frameworks Kung Fu

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

Page 31: Joomla Frameworks Kung Fu

JLoaderjimportrequire_once

Page 32: Joomla Frameworks Kung Fu

Loader Classregisters

System Plugin

Page 33: Joomla Frameworks Kung Fu

Joomla 1.5 way

Page 34: Joomla Frameworks Kung Fu

Joomla 1.5 way

MAIN CONTROLLER

Controller 1

Controller 2

Controller n…

Page 35: Joomla Frameworks Kung Fu

Joomla 1.5 way

MAIN CONTROLLER

In fact: 0 controllers

Page 36: Joomla Frameworks Kung Fu

Joomla 1.6 way

MASTER CONTROLLER

Controller 1

Controller 2

Controller n…

http://docs.joomla.org/JController_and_its_subclass_usage_overview

Page 37: Joomla Frameworks Kung Fu

BASE DISPATCHER

Component Dispatcher

dispatch()

Page 38: Joomla Frameworks Kung Fu

1 line of code

MyDispatcher::dispatch(array('component_name' => mycp', 'default_view' => ‘my‘ ));

Page 39: Joomla Frameworks Kung Fu

ControllerView

Model

User

Page 40: Joomla Frameworks Kung Fu

NO FRAMEWORK WILL HELP YOU IF YOU DON’T UNDERSTAND MVC!

Page 41: Joomla Frameworks Kung Fu

СONTROLLERIS THE BOSS!

Page 42: Joomla Frameworks Kung Fu

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.

Page 43: Joomla Frameworks Kung Fu

MODEL ISA HARD WORKER!

Page 44: Joomla Frameworks Kung Fu

Storing a state;

Performing database tasks;

Formatting data;

…all other data tasks.

Getting request data;

Rendering templates.

Page 45: Joomla Frameworks Kung Fu

VIEWIS A STYLIST!

Page 46: Joomla Frameworks Kung Fu

Rendering

templates

Page 47: Joomla Frameworks Kung Fu

JCONTROLLER

JMODEL

JVIEW

Page 48: Joomla Frameworks Kung Fu

A simple list with filtering

Page 49: Joomla Frameworks Kung Fu

View

Controller Modelrequest state

model with updated state

display()

Page 50: Joomla Frameworks Kung Fu

View

Controller Modelrequest state

model with updated state

display()

no state

Page 51: Joomla Frameworks Kung Fu

Make

JController::getModel

method to store a model

Page 52: Joomla Frameworks Kung Fu

1 DB TABLE = 1 MVC

Page 53: Joomla Frameworks Kung Fu
Page 54: Joomla Frameworks Kung Fu

BORING TASKS

Page 55: Joomla Frameworks Kung Fu

SEND BORING TASKSTO YOUR FRAMEWORK

Page 56: Joomla Frameworks Kung Fu

It’s all about CRUD, both

on the back-end & front-

end

Page 57: Joomla Frameworks Kung Fu

IT’s all about lists &

forms

Page 58: Joomla Frameworks Kung Fu

Base Classes

Boring tasks

code

Page 59: Joomla Frameworks Kung Fu

SYSTEM PLUGIN

LIBRARIES FOLDER

COMPONENT

Page 60: Joomla Frameworks Kung Fu

Magic methods,Interfaces,Exceptions,…

it’s high time to implement them!

Page 61: Joomla Frameworks Kung Fu

NOOKU FRAMEWORK: A MUST SEE FOR EVERY J! DEVELOPER!

Page 62: Joomla Frameworks Kung Fu

KLoader,KFactory,Mixins,HMVC,…

That is awesome!

Page 63: Joomla Frameworks Kung Fu

CMSLAYER: A DIOSCOURI’S CODEBASE FOR LOADING EXTENSIONS ON DIFFERENT SYSTEMS!

Page 64: Joomla Frameworks Kung Fu

cmsLayer base

Implementation 1

cmsLayer interface

Implementation 2

Implementation n

Page 65: Joomla Frameworks Kung Fu

cmsLayer base

Feature1 Feature 2 Feature n

Page 66: Joomla Frameworks Kung Fu

Joomla!

cmsLayer

DrupalWP

product

Page 67: Joomla Frameworks Kung Fu

http://twitter.com/onesterov

http://onesterov.com

http://www.slideshare.net/onesterov

http://mindk.com

[email protected]

WRITE GOOD CODE & BE HAPPY