March 11, 2008

progress update

Filed under: ZenMagick — DerManoMann @ 9:25 am

There’s been so much happening in the code base that it is hard to know where to start. One thing is quite clear, though: I really regret making the last release 0.9.0, as the next version is going to be much better/different/incompatible that any previous ZenMagick version.

Do not be afraid, though. Even though there are massive changes, there will be a compat/legacy mode that will allow you to use your existing code (whilst busy upgrading). That means incremental upgrades of template files will be possible.

So what is really changing? Some of the changes are inspired by my current work with CakePHP. Even thought the documentation is definitely better than the ZenMagick one (in particular more people blogging about their experience…) it’s still lacking in places.

One thing is that I already talked about is replacement of globals. This means something like:

$product = $zm_products->getProductForId($zm_request->getProductId());

will look like:

$product = ZMProducts::instance()->getProductForId(ZMRequest::getProductId());

Seems a bit longer, but has some great benefits:

  • Right now all services and a few other things are instantiated during the init of ZenMagick. That means that there is always overhead because of globals that are never used (I do not think that all services are ever going to be used in a single request).
  • Overloading of service classes is not possible (at least not in a way that fits into the ZMLoader concept)
  • Ensuring that all globals are available always and everywhere just is a pain
  • Plugins that add new services are left out of the loop (unless thy use the zm_ prefix which external plugins should not do!)

Looking more closely at the code it turns out that ZMRequest does not need the instance() method as all methods are real static methods. The general rule is that services do require the instance() method, ZMLoader, ZMRequest and ZMRuntime are just container for static methods (while using an instance internally).

I also started moving a lot of core functions into the appropriate service class where possible. Other things will follow. One thing in CakePHP I particulary like is the helper concept for HTML generation, so I coud imagine something similar, rather than having all those zm_href, zm_form, etc functions.

Moving functions into new classes making them semi-static also means it would be possible to allow to replace those by providing a custom class implementation same as with *normal* classes.

During all those style updates I also managed to strip the init code a lot more, so some speed gain is to be expected.

Last but not least, more improvements to plugins and even a new one!

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.