So we're a month away from DrupalCon DC 2009, and although the official schedule has not been published it seems likely from the preliminary schedule that my Objectifying Drupal session will be accepted. The basic idea is to help Drupal's mainly procedural army of developers get up to speed on object-oriented development, which has been gaining popularity in contrib (most notably the Views module) and will be in many parts of Drupal 7.
Of course, given how large an army of developers we have there is no one level of existing expertise I can target. There are entire multi-course college programs on OOP design, and I have an hour. :-) So, how about some preliminary feedback? What do you want to see in a one hour session on object-oriented code in Drupal?
I don't really want to waste my time (or yours) talking about rudimentary syntax if everyone already knows it, but I also don't want to waste your time (or mine) talking about complex object interaction patterns if what the audience really needs is to understand the syntax. So let me know what your skill level is coming in and what you are hoping to get out of a one hour crash course on Drupal OOP and I'll try my best to accommodate the audience.
Please only respond if you are actually planning to attend DC DC and are planning to attend this session. There's no sense in targeting my session at people who read my blog but won't be at the session. :-)
General possibilities include:
- Classes, Interfaces, references: What are they? (Very beginner)
- Inheritance (beginner)
- Simple OOP patterns (beginner to intermediate)
- More advanced OOP patterns (intermediate to advanced)
- Exploration of where we could properly leverage OOP in Drupal but aren't yet (intermediate to advanced)
- Where are we using OOP now (Database layer, Views, hopefully Handlers)
Anything in particular you want to cover?
Patterns
While basic OOP is really basic and easy to get these patterns are what make OOP so confusing and impossible to follow at least to me. So education would be welcome.
Right now Drupal is close to
Right now Drupal is close to be the first real AOP framework. AOP is much more flexible than the OOP paradigm. All we need is more hooks as "pointcuts".
agree with chx -- more patterns please
Anyone who can read/write php code can easily pick up the syntax from online documentation. I'd like to hear more about OOP patterns, especially ones already in common usage in Drupal 7 or ones you suspect will/should become common in Drupalandia.
Patterns
I also would like to see the OOP patterns in Drupal. Learning OOP syntax is very simple, but understanding design patterns, for me at least, is much more complex. Discussing the patterns mentioned here, such as singleton, decorator, observer, bridge, and chain of responsibility, and how Drupal already uses these patterns in much more depth is valuable to me. It also would be nice to see how these patterns would look in Drupal using OOP syntax.
Thanks for the session Larry!
An example of how OOP simplifies and pays off code debt
+1 on patterns, along with chx and Tom.
The comment on AOP is interesting, but Aspect oriented programming is achieved when in the code you can concentrate on business objects and can simply inject "handler points": we have callback functions (hooks) but we don't have the first part, OOP, yet. That's the point.
What I think would make your session awesome is if you could find an example of code debt in Drupal. An example where there is increasing complexity and it is very difficult, if not impossible, to refactor without using OOP.
I think that would go a long way towards enhancing Drupal community OOP outreach.
Victor Kane
http://awebfactory.com.ar
Performance
I have seen how excessive use of objects can make PHP performance really bad. I think basic OOP knowledge (things you listed) is not enough when doing real-world PHP projects. One must also consider how to keep performance at the same level as with procedural design.
That is why I would not 'push' OOP to Drupal developers unless also prepared to provide insight on how to maintain performance.
Mapping of Drupal patterns to OOP patterns
"Currently to do X in Drupal, you do this. With OOP, you could do it this way. The advantages are... The disadvantages are ..."
my wishlist
Patterns are cool of course, but I've already had my share of those in various OOP courses - I'm more interested in how to fit traditional OOP approaches into Drupal.
+1
I second everything Jakob has said :)
Drupalism mapping to OOP
I'm thinking it would be useful to leverage developers existing knowledge of the Drupal codebase and find examples of OOP like patterns in Drupal.
For example Drupal hooks are kind of Observer/Listeners. module_invoke/module_invoke_all are kind of event dispatchers. (Those are a couple off the top of my head, but I'm sure there are plenty more - 'kind of' OO stuff in Drupal).
For each example you can talk about how its similar to OOP - and then show what it would look like if it were OO.
Another thought might be to talk about what an encapsulated and/or polymorphic node object might look like.
Like you said, its only an hour and you could spend a year architecting an object oriented DrOOple and months discussing design decisions and why one pattern was chosen over another do do things. Its a tough talk - but from reading your blog I'm sure you'll do a great job. I won't be able to get out to Drupalcon, but I look forward to watching/listening to the talk afterwards.
andre
Doh - missed RoberDouglass' comment
So yeah, what I said, and what he said. ;-)
-1 on syntax, +1 on OOP the
-1 on syntax,
+1 on OOP the Drupal way
see you in DC