Transcript

Joomla ArchitectureRevealed!

Ofer Cohen@oc666

[email protected]

About me, Joomla and Arch

● Open source volunteer since 2005.

● Joomla volunteer since 2007.

● CMS & Framework code contributor

● JBS team member

● GSoC mentor of Joomla

● Extensions Developer (TP2 at JomLand)

nie wystarczy?

● Joomla Hebrew translation coordinator

● Joomla Israeli community leader

● Joomla!Day Israel organiser

● OSM board member

● Daily job: R&D manager in the Start-Up

nation.

Joomla!

● 3.2% of all websites, worldwide

● Object Oriented since 1.5

● Components based on MVC design pattern

● What else?

Architecture?

● Architecture the process and product of planning, designing and construction...

● Software architecture description of the system that support in the understanding of how the system will behave

● Website architectureapproach to the design and planning of websites...

Revealed?

● Who cares? It Just Works! (TM)

Revealed!

● Why is my Joomla! site slow? hacked?..

● Want to build a complicated website?

● What are the abilities of Joomla?

● What can't I do with Joomla?

● I just love to research and learn!

Object Oriented

● Data structures consisting of data fields and

methods together with their interactions

● Programming techniques include features such

as data abstraction, encapsulation, messaging,

modularity, polymorphism, and inheritance.

● This approach make your program more easy to

build and implement tricks.

Tricks?

The tricks are design patterns - reusable

solutions to commonly occurring problems

within a given context in software design.

(wikipedia)

Step back.... J! index.php

1. constants and defines declared

2. configuration loaded

3. application init triggered (lang, editor)

4. routing parsed the request (url, arguments)

5. dispatch the component

6. render the template

7. echo the response output

Looks simple, but what's inside?

1. Component is first dispatched and then

buffered.

2. Template render with their modules and

then set output into response (object).

3. Events trigger between each step.

Template Walk... --> How is a template rendered?

1. The index.php of the template is rendered.

2. Parsing jdoc statements.

3. Each jdoc statement rendered separately,

iteratively, according to its type.

4. Component & head are parts of the

iteration, but have different rendering.

VMC... MCV... WTF? Prefer BMW?

● MVC - Model-View-Controller

Divide the software into 3 layers:○ M=>Logic

○ V=>User interface

○ C=>Request handler

MVC - advantages

● Easier to extend.

● Less spaghetti code.

● Great approach on upgrades and new features.

● Easier collaboration between multiple

developers.

● Events handling

● Simple dispatcher can be called

● It fires events to Joomla plugins on basic

triggers.

● For example, after content creation, before

user delete, etc.

Plugin=Observer

● Supplier of the main entities of Joomla:○ Session

○ User

○ Cache

○ Database

○ and more...

● Each entity is singleton

Factory

● Only one instance of an object is kept.

● Saves system memory usage & cpu

Singleton

Adapter

● Adapter translates one interface for a

class into a compatible interface.

● For example DB adapter for DB such as

MySQL, MSSQL, Postgresql.

● Another example would be Renderer

object for rendering output of module,

component, header, etc.

● Decouple an abstraction from its

implementation.

● Useful for implementation encapsulation.

● Especially when the program decides how

to implement on run time.

Bridge

● J!Database instance built by its

instantiator method input.

● The method will return its nested

inheritance object

● The object type would be unknown, only the methods we can call would be known.

Bridge - example

abstract class JDatabase {

public static function getInstance($options) {

$class = 'JDatabase' . ucfirst($options['driver']);

$instance = new $class($options);

self::$instances[$signature] = $instance;

return self::$instances[$signature];

}

}

Bridge - code example from J!DB

● HMVC - reuse of each part of the MVC

pattern.

● Traits - the long tail story

● UCM - want to select from articles content

and virtuemart products at the same

query. ORM-Like methods (NOSQL).

Future

● The only complicated thing is the problem.

● The solution must be simple.

● If you have a complicated solution, you

probably chose the wrong solution (KISS)

Conclusion

Ofer Cohen

Open Source Matters

[email protected]

@oc666

Thank you

Coupon: jdpl13

Discount: 50%

TP2 - drag & drop your modules


Recommended