Google SOC Proposal: Re-write Drupal in OOP

Events happening in the community are now at Drupal community events on www.drupal.org.
rpfilomeno's picture

Hi guys, I submitted a proposal for GSOC and its now approved. We have 3 mentors and 1 student but were hoping Drupal developers from PH will also join!

Please support "Re-write Drupal in OOP"

Abstract:
Adopting Object-Oriented Programming for Drupal is basically one of the oldest issue that existed between module developers; It basically a battle between simplicity and efficiency vs code management. As much as I'm convinced to support simplicity; as a module developer, its quite annoying to encounter namespace collision because of Drupal's non-OOP feture.

For example: PHP Fatal error: Cannot redeclare test_perm() (previously declared in /var/www/path/to/drupal)...

Finally as more modules are added, the chance for namespace collision increases; and since most of the short, descriptive and effective names are already taken, it forces developers to use ridiculously long function names.

For example, using forms API alone requires:

function my_module_name_this_creates_a_form() { ... }

then you must also define a function for validation:

function my_module_name_this_creates_a_form_validate() { ... }

finally you must also define a function for submission:

function my_module_name_this_creates_a_form_submit() { ... }

Proposal:
We should re-write Drupal as OOP such that a main class contains all the core while allowing developers to use the same function name on a separate module class as hooks.

For example:

Class Drupal() { ... } // is the main class while
Class MyModule() { ... } // is a module class

then
$site = new Drupal(); // will initiate a site with the configuration
$drupal.loadmodule(new MyModule()); // will load the module
$drupal.hook_cron(); // invokes both the cron related method for Drupal and MyModule.

As we can see, It's shorter and solves the problem with namespace collision effectively.

Comments

Roger, this is great! Sali

benc's picture

Roger, this is great!

Sali ako sa mentoring! To celebrate this occasion, dapat mag-meet up! Anyone for a summer meet up to kick of the summer of code din?

benc


The Power of Drupal Categories
A Podcast for Mac Switchers

Its an AFD

rpfilomeno's picture

Its an AFD to cheer everyone up, i posted it instead here coz couldnt bear to post it on soc2008 :D

Actually its this one: Views as Web Widgets that IS officially on Drupal GSOC task.

Yeah, it would be nice if we can have PH students and mentors and I think its about due too to have a gathering.

LOL i was riding on para

benc's picture

LOL i was riding on para sana masimulan ang meet up natin :)

benc


The Power of Drupal Categories
A Podcast for Mac Switchers

Good Work...

mrgoltra's picture

Keep it up guys..

Philippines

Group organizers

Group categories

Post category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: