Hi folks,
I'm new to this group (and to groups.drupal.org in general), so let me give a quick introduction. I'm one of the owners and programmers at CraftySpace, a web development company creating Drupal-based solutions for our clients. We're a little over a year into our business, so we've been dealing with the hecticness that comes with a start-up business, and therefore, not getting as involved with the Drupal community as we'd like to be. But I'd like to start getting more involved, since that, of course, is the whole point of open-source software, so I appreciate the opportunity to be a part of this group.
Anyway, one of the things we're doing is trying to use more OOP syntax in the code that we write. To facilitate this, we created a module (that we're currently calling "ClassLibrary") that allows a module or a theme to be created as a class. The ClassLibrary module uses PHP 5's reflection API to create procedural wrapper functions around the public methods of the class in order to get the module or theme to integrate into Drupal the way modules and themes normally do. This approach allows us to write most of our code using OOP syntax, which we find more comfortable and intuitive than procedural syntax, it lets us have enforced encapsulation (i.e., private variables and methods), and it lets us take advantage of implementation inheritance in creating custom modules and themes in a way that I think is much more limited without using classes.
There are some drawbacks to this. One is it's all based on PHP 5 -- a business decision we made is to not work with clients who aren't willing to be hosted on a PHP 5 platform. Another is there is some performance cost; however, I think there's still room to optimize it to where the performance cost is minor.
After reading the post on drupal.org about how Drupal 7 will start taking advantage of PHP 5.2 features and drop compatibility with PHP 4, as well as reading what's been posted in this group, I started wondering whether anyone here would be interested in me sharing our ClassLibrary module and talking further about its use cases. Please let me know if you're interested, and if so, what the proper way of doing that is (attaching a file to this post, applying for a CVS account with drupal.org, something else?).
Thanks, and I'm looking forward to discussing OOP concepts with all of you.
Alex.
Comments
Adapting DRUPAL to POO PHP5.2
After an experience with PHP5 POO framework, I have made my own challenge to refactor DRUPAL with POO classes.
I first started with a class for Database abstraction with keep the same API functions names.
This modification start to work. I only get a problem with an 403 apache error but the rest works fine.
My plan is to try to get an POO oriented DRUPAL for all core includes then the modules and themes.
The new script is Drupoo and is at the moment in experimental status. It is base on v6.4 API.
As soon as I fixed the problem with this 403 error I could make the script available for tests and further developments.