Archive | September, 2005

Modularising Workflow with an Intercepting Filter

Posted on 30 September 2005 by Demian Turner

While we’re on the subject of useful refactorings, I’d like to describe how using an Intercepting Filter helped round up and modularise software setup and initialisation tasks. Before the code could get down to business with the framework’s main task, the SGL_MainProcess, (eg booking a hotel room or editing an FAQ, whatever), a certain amount of setup was necessary.

In the previous version, a number of initialisation tasks were assigned to a single init() method in the AppController, then executed procedurally. The disadvantage of this approach was that the tasks were not testable, they were difficult to reorder, and it was prohibitive to insert custom routines into the pipeline.

Enter the Intercepting Filter, which is basically a chain of decorators. The idea is that you have your main process, then you decorate it with n filters or tasks required to get your system correctly initialised beforehand. The code makes the example clearer:

class SGL_AppController
{
function run()
{
$input = &SGL_RequestRegistry::singleton();
$input->setRequest($req = SGL_Request::singleton());

$process = new SGL_Init(
new SGL_DiscoverClientOs(
new SGL_ManagerResolver(
new SGL_InitSession(
new SGL_InitLangSupport(
new SGL_InitPerms(
new SGL_AuthenticateRequest(
new SGL_BuildHeaders(
new SGL_SetLocale(
new SGL_DetectDebug(
new SGL_DetectBlackListing(
new SGL_MainProcess()
)))))))))));

$process->process($input);
}
}

From Matt Zandstra’s book:

The model is very extensible. We can add new decorators and components very easily. With lots of decorators we can build very flexible structures at runtime. The component class [in our case SGL_MainProcess] can be significantly modified in very many ways without the need to build the totality of the modifications into the class hierarchy.

Here’s the UML:

Comments (1)

Implementing an Output Renderer Strategy

Posted on 29 September 2005 by Demian Turner

An interesting design problem became apparent when a
number of folks from the seagull ML recently complained about the lack
of support for web clients other than standard browsers. Because the code
enforces reasonable segregation between the domain modelling and the
html views, I always presumed it would be trivial to implement, ie, an
xml renderer instead of the current Flexy to handle WML output.
Two problems needed to be solved:

  1. the Flexy renderer was hard-coded in the final stage of a validate/process/display workflow
  2. worse, a number of post-processing tasks, mainly assembling of blocks and building of main navigation were also hard-coded

In short, the process was quite tied to producing HTML-only output, clearly n
blocks and involved navigation were unsuitable for PDA output.

I
identified two main refactorings necessary to decouple the view
production from the output type and specific renderer used, thereby
opening the door to running customised post-process tasks based on the current
rendering strategy.

To
allow an arbitrary renderer to be specified at runtime I chose to
compose the View object with a OutputRendererStrategy. This means
if you’re happy with Flexy you can use the standard renderer supplied
with the package, and if you can’t bear the thought of working without
Smarty, it’d be a piece of cake to write a SmartyOutputRenderStrategy
following the Flexy example. The code would look something like
this:

    //  build view
$view = new SGL_HtmlView($output, new SGL_HtmlFlexyRendererStrategy());
echo $view->render();

where the $output object is just a php data structure free of any
presentation information. The next problem was more interesting,
how does producing output for portable devices change the appliation
requirements. The basic data structure sent to the view is
similar, but the following main differences are evident:

  • any paginated lists sent to the template needed to be a lot shorter, with simpler paging
  • any superfluous info like that found in left/right column blocks had to go
  • navigation had to be dramatically simplified

Using the View type but switching implementation as runtime made it
very easy to achieve this, where WmlView implements specialised
minimalist post processing tasks, and uses an xlst renderer to output
WML. The code would look like this:

    //  build view
$view = new SGL_WmlView($output, new SGL_XmlRendererStrategy());
echo $view->render();

The code
is currently only in svn but will make it out in the 0.5.1 devel
release planned shortly. The following UML summarises the idea:

Comments (2)

PHPlondon Special Guest

Posted on 26 September 2005 by Demian Turner

If you’re in or around London early next month, or have always been meaning to come to a PHPlondon meetup but never found the time, Thursday, October 6th is the date to be there and help us welcome our very special guest, the father of PHP, Rasmus Lerdorf.

The room we meet in at the Fitzroy only has capacity for around 30 people so please sign your name up at the wiki to help us get an idea of numbers.

Comments (2)

Seagull Reviewed in PHP Solutions Magazine

Posted on 16 September 2005 by Demian Turner

The Seagull project has been fortunate enough to have a detailed
tutorial on its usage published in PHP Solutions magazine in 5
languages.

Congratulations to Werner M. Krauss for putting the article
together and liaising with the publisher, and many thanks to PHP
Solutions for allowing us to distribute the free PDF versions of the article from this
site. PHP
Solutions magazine is available all over Europe (except the UK) from your favourite magazine store or from their website. One can also buy the magazine, the current issue is titled Framework vs. CMS and also includes great articles about other frameworks like PRADO and CMSs like eZ publish and includes some free books on their CD, eg, PHP5 Power Programming.

The Seagull article, which covers all the basics of the framework, is available in English, French, German, Italian and
Polish.

Comments (2)

Seagull 0.4.6 Released

Posted on 15 September 2005 by Demian Turner

156 commits and almost a month later, version 0.4.6 of Seagull is now available for download. It’s been a productive month, partly because I quit my job to work on this project fulltime, but also because an even greater volume of patches and new features is being sent in than usual. That could be partly due to the recently improved search ranking.

This release includes a generous helping of bugfixes :

  • Fixed missing bug icon in msie
  • Disabled FK constraints from MySQL as there appears to be a bug in the implementation. Same SQL works fine in PgSQL 😉
  • Fixed a bug where non-indexed arrays could be overwritten in Front Controller (Lorenzo Alberton)
  • Some SMTP servers had problems with Mail_smtp’s localhost default value, this is now catered for (Chris McKay)
  • Server vars now interpreted correctly on IIS 6.0, note: frontScriptName in config file MUST end with "?" (Miha Vrhovnik)
  • Fixed bug where FCK editor would not display correctly in msie
  • Some magic_quotes_gpc scenarios weren’t dealt with correctly, now fixed (Eric Persson)
  • Seagull is now PHP5.1 compliant, this involved some local as well as PEAR modifications.

and new features:

  • RSS import/export at last! (Fabio Bacigalupo)
  • Improved session management so now it is possible to search sessions with more meaningful results and single sessions per user can be enforced. Also new "who’s online" block added (Louay Gammo)
  • Admins now notified of new registrations, separate screen for activating/disabling accounts
  • Added shell script to symlink templates into modules
  • Turkish translation added (Metin Tinay)
  • Added ability to scrape and include wiki pages, requires php5 + tidy
  • Static articles can now be edited inline
  • Added postgres user and database creation script (Pierpaolo Toniolo)
  • Added the db function unix_timestamp for oracle and postgres (Tobias Kuckuck)
  • Added ability to view login history for a given user (Rolandas Burbulis)

One major feature was added just after the release, so you’ll have to checkout the bugfix branch to use it, and that is an integrated unit test runner, you’ll need the pear-installable SimpleTest to run it. Thanks to m3 Media Services Limited for granting us the right to distribute this under BSD.

Also looking at Wikiwyg recently, seems at least 1000 times faster than FCK, anyone using this?

Finally I would say subscribe to the project’s new RSS feed but there are some date probs that still need to be ironed out so best wait a few days. And if you’re in or around Italy for the weekend of Oct 7-9th be sure to pop by SglDay2005.

Comments (7)

Who’s Next?

Posted on 13 September 2005 by Demian Turner

Quite an entertaining read thanks to Eric S. Raymond, maybe times are changing after all?

Comments (0)

Simian Systems Reinvigorates Software Project Management with the Release of SiteForge

Posted on 13 September 2005 by Demian Turner

Winnipeg, Manitoba, Canada – September 13, 2005 – Canadian content management vendor Simian
Systems Inc. (www.simian.ca) release SiteForge – the most user-friendly open source
collaborative development platform available today. SiteForge helps open source developers
and distributed development teams centralize project development, source code access, issue
tracking, documentation, and product releases. What sets SiteForge apart from other,
comparable software project management tools such as SourceForge, or GForge is its ease-of-use and straightforward installation process.

"We aim to do for the collaborative development industry what SugarCRM is doing for customer
relationship management. That is, to reinvigorate the industry with the introduction of a modern,
high-quality open source solution," says John Luxford, President and Chief Developer of Simian
Systems. "With the growing need for open source and distributed development in more
industries, it’s time to make the tools of the trade available to everyone."

Comments (0)

VMware and FC4

Posted on 07 September 2005 by Demian Turner

UPDATE: there’s a new patch available, existing link updated (May 28, 2006)

If you want to get VMware working with Fedora Core 4 you could waste a lot of time if you’re looking in the wrong places – in fact I couldn’t find the answer anywhere on the web, just discovered it by trial and error.

The bottom line is this:

  • forget about using VMware 5
  • using VMware 4.5.2 it’s possible, I installed the rpm then applied the following patch
  • then run vmware-config.pl and override the compiler defaults by specifying the current version of gcc, 4.0.1, instead of 4.0.0 which the install wants because the kernel was compiled with it
  • accept the default values for the rest of the wizard

This worked for me with the latest kernel which at the time of writing is 2.6.12-1.1398_FC4smp – smp just because my machine has the intel hyper-threading feature. Interestingly, the same approach did not work when I was running FC3 when the kernel version increased from 2.6.11.x to 2.6.12.x.

Comments (9)

Seagull Reviewed in PHP Magazine

Posted on 01 September 2005 by Demian Turner

One of the leading PHP publications, International PHP Magazine, has a roundup of PHP frameworks by Elizabeth Naramore in its latest issue. I’m happy to say that Seagull got a glowing review, and out of the 5 projects examined, including PRADO, Cake, Mojavi and php.MVC, Seagull got the highest rating – something like 4 3/4 stars out of 5 – way to go!

Unfortunately it appears PHP Magazine does not provide PDF downloads of individual issues like all the other mags, so you’ll have to physically walk over to the newsagent if you want the full story.

Looking forward to the next Seagull release which was made fully PHP 5.1 compliant yesterday in svn, a move that unfortunately required modifying 4 or 5 PEAR libs which are not moving anytime quickly toward being 5.1 compliant themselves.

Comments (9)

Categories

Books

Demian Turner's currently-reading book recommendations, reviews, favorite quotes, book clubs, book trivia, book lists

Facebook