Developer Team Blog

Developer Team Blog

Development Working GroupWelcome to the Joomla! Developer Blog. The Joomla! Developer Team is part of the Joomla! Development Working Group. Here, you will find blogs from those commiting code for Joomla! 1.6. The developers might sometimes seek input from the end user community for a specific task. Or, the developers might ask advice from other developers for a problem they are trying to solve. If you are interested in watching the progress for Joomla! 1.6, this is a great place to catch that action.



Testing User Interface Code PDF Print E-mail
Developer Team Blog
Written by Alan Langford   

Recently Ross Crawford asked a question on the developer list about testing User Interface code. Little did I know that I'd be putting my response to him into action the very next day.

Today I was adding a module to one of my sites, and I decided that the module list should be alphabetical by column, rather than by row as it is now. A simple change, I thought, why not take a few minutes to implement it.

Naturally my first run at this had bugs. In this case, it was an infinite loop. An infinite loop with infinite output that gave my Firebug-enabled Firefox a really hard time. A restart the browser with 20+ open tabs hard time. Not fun.

There is a simple fix for this, I thought... unit tests! After all I'm going to wind up writing tests for it before I propose it as a change, because being able to prove that a change works is (or should be) one of the best ways to get a change approved.

A couple of glitches with mocking JText and trying to get the Windows CLI version of PHP to not dump captured output to the console, and I was ready to write some tests. A short time later and the time for a revise/test cycle was down to a minute or so, eliminating the painful need to kill and restart Firefox. Shortly thereafter the bug was fixed and everyting was looking good.

Then I decided to validate the HTML with Tidy. It failed pretty badly. It seems a misplaced /> was causing a span element to become unbalanced and an input element to be malformed. I fixed this up, eliminated all of the other warnings that I could, and created a patch.

That's the power of testing. I found previously existing but undetected bugs, significantly reduced my cycle testing times, and now the project has a tool that gives every other developer the same advantage with no additional investment in time.

See the documentation wiki for a discussion of the specifics involved in this type of test.

 
48 Votes

2 Comments

New Unit Testing Status Page Available PDF Print E-mail
Developer Team Blog
Written by Alan Langford   

One of the hold ups for getting some momentum in the unit test process has been not quite knowing where to start. Part of the problem is that there has never been a easy place to see what needs to be done.

This has now been addressed with the Unit Testing Status page on the documentation wiki.

Manual attempts to get this page started haven't been all to successful, to today I wrote a program that creates it automatically. It identifies all the non-legacy classes in the "Joomla!" trunk, matches them against classes in the unit test tree, and produces a report.

There are three tables in the report. The first lists all the classes in alphabetical order, along with the number of test files for that class and the source file for the class. The second lists the same information organized by directory. The last table lists tests that aren't class-based, and tests for classes that don't exist.

The next job is to get rid of the sea of red (classes with no tests) on this report. There's a lot to do, but at least now it's easier to pick a place to start.

 
43 Votes

2 Comments

Legacy-Marker PDF Print E-mail
Developer Team Blog
Written by Mati (MtK) Kochen   

It is now a known fact, that Joomla will drop legacy support (well, sort of) in future versions. As you may figure, this was not an easy call. Dropping Legacy support is not just a matter of Joomla! Development Team stop supporting legacy frameworks, it is a process that needs to be understood by third-party developers and even more than that - be applied to third-party extensions.
Joomla! cannot move forward while leaving 3PD's floating on air...

Read more...
 
39 Votes

8 Comments

Joda: An attempt to make Joomla! a multi-database platform PDF Print E-mail
Developer Team Blog
Written by Plamen   

What is Joda?

Joda is an initiative, an attempt to make Joomla! Framework and CMS mutli-database compatible. Currently, Joomla is firmly tied to MySQL database engine (due to historical reasons). Joda, as a minimum, should add to the supported list such widely used relational, SQL database servers as PostgreSQL and Microsoft SQL Server. Joda is developed as a replacement of the current Joomla Database Layer.

Features at a glance:

* Target database engines: MySQL, PostgreSQL, MSSQL

* Using PHP PDO data access library

* Using Prepared Statements

* Implementing basic ORM

 

What Joda isn't?

Joda is not a hyper-mega-all-mighty or universal PHP Database Abstraction Layer you can download and use in your own non-Joomla projects (like you do with PEAR or Zend Framework). It is not a plugin, component, module or extension. It is not a SQL translator. And finally, Joda is not Yoda, although the name was inspired by this little, cue, wise and powerful creature :-) [Wikipedia:Yoda]

 

Why Joda?

It is pretty straightforward: Joomla! community and user base is extremely fast  growing, thus attracting people using different database engines. At some point the community realized that Joomla, being "MySQL only" or "too much MySQL", is missing an important feature: multi-database support. It is easy to spot this mood reading Joomla Forums. Do a quick search for "postgresql", "mssql" and "multi+database" and you get reasonable number of threads on this subject.

 

When?

Not planned. No oficial decision taken yet. Joda is a proposal, an attempt to make things better. You'll be informed as soon as it happens. When it's done. Does this ring the bell? [easter egg]  :-) 

 

PHP Compatibility

Joda class hierarchy inherits PHP PDO classes (PDO and PDOStatement).  Since PDO is PHP 5.1+ feature, Joda is considered compatible with PHP version 5.1 or above. This is in perfect sync with the recent Development Team's decision to declare Joomla as PHP 5.2+ compatible starting from version 1.6 [see Joomla goes PHP5]

 

3rd party extensions and legacy issues

As a side, unavoidable effect, Joda will break backward compatibility between Joomla and existing 3rd party extensions. Some of them might be affected, others could still run error-free, but in general Joda should be considered legacy-ignorant. Nothing can be done against this. On a bright side, Joda won't happen unexpectedly and is not planned to be ready any soon :-)  At least not before Joomla v2.0!

 

Architecture

 

 Joda Class Hierarchy

 

Joda consists of two main parts: Database Abstraction and SQL Abstraction layers.

 

Database Abstraction Layer

This layer includes the following classes and their child classes:

class JConnection extends PDO

Responsible for:

  • Connecting to the underlying database source and reporting problems
  • Providing metadata - hard coded or dynamically retrieved form the data source
  • Handling transactions if required, using different isolation levels
  • Preparing (if required) and executing queries
  • Fetching data rows and piping them to its owner (a JDataset object)
  • more

  

class JDataset extends JObject

  • Orders its Connection property to make connection and report status
  • Uses its own JQueryBuilder property to build data base aware SQL queries
  • Sends queries to JConnection class for execution
  • Holds data, (the result set) in tabular format or array of objects
  • Provides API to examine and manage data in its data structure
  • more

 

class JRelation extends JDataset (Object Relational Mapping sub layer)

  • Implements basic Object Relational Mapping concept
  • Represents a single relation in the underlying data source, namely a table
  • Provides API to retrieve data from and manage its counterpart table
  • A semi-root class for all sub-classes that represent (hypothetically) all tables in the data source
  • more

 

 

SQL Abstraction Layer

Includes the following class and its child classes:

JQueryBuilder

Responsible for one single task: building database specific SQL queries through unified, simple, readable and straightforward API.

Supports a predefined, hard coded set of SQL query types (query templates)

Outputs a list of queries (an array of strings).

 

Recommended Readings:


Joomla Forum: http://forum.joomla.org/viewtopic.php?f=326&t=195747

Joomla Dev Team's Google Group: http://groups.google.com/group/joomla-devel/browse_thread/thread/c84ffbd5ba1dedca

ORM: http://en.wikipedia.org/wiki/Object_Relational_Mapping

PDO: http://bg.php.net/PDO

 
44 Votes

5 Comments

Unit Testing in 1.6 PDF Print E-mail
Developer Team Blog
Written by Alan Langford   

Unit testing is a powerful and proven method to improve and maintain the quality of any body of code. Many developers take a look at unit testing and conclude that while it may be a good thing to have a test suite, most of the time it's probably not worth the effort to write the tests. That's the way I felt too, until I was working on a complex module that was almost impossible to test without some sort of automation. I quickly realized that even for simple classes, writing good unit tests wound up saving the time spent writing tests tens, sometimes hundreds of times over!

In the 1.5 development cycle, unit testing came to the party rather late. After a false start and inactivity, the team decided to restart the effort, using PHPUnit as the testing framework. By the time we got a good idea of how to best approach unit testing, 1.5.0 was already set for release.

As a result, unit tests for 1.5 have mostly been written to verify specific problems and the changes made to fix them. This is good, but we can do a lot better. For 1.6, that's exactly what we plan to do. We may not see unit tests covering 100% of the code base by the time 1.6 is released, but our goal is to see significant coverage by then. Personally, I'd like to see coverage of at least 60%, the higher the better.

The objective of the new "Joomla!" unit test facility is to make it as easy as possible to write test code. So far a few developers have "test driven" the facility and come to the same conclusion -- that writing tests decreases development time overall.

But there is still a lot to do. Not only do we need to move quickly to 100% test coverage, but there are many improvements that can be made to make it easier to run tests, and to leaverage the many advanced features of PHPUnit.

For more information on unit testing in "Joomla!", see http://docs.joomla.org/Unit_Testing on the documentation wiki.
 

 
36 Votes

0 Comments

<< Start < Prev 1 2 Next > End >>

Page 1 of 2