Archive for September, 2006

Zend_Service_Currency Proposal

Since one of the project’s I’ll be working on in a few months requires using up to date Exchange Rates (without the benefit of having a paid-for Bloomberg/IDC/Other terminal available) I did a quick check on what PHP classes are available for the purpose. There’s really not a whole lot out there. There’s a PEAR class along the lines I need, but it’s released under the PHP License and, not to be too argumentative, I prefer non-PEAR solutions where the end-user may have no access to update PEAR.
So since the project is planned to use the Zend Framework, I shot off a mail to the Framework’s fw-general mailing list to see if it would be a worthwhile contribution. As blind luck would have it, someone else had just then finished opening a proposal for a Zend_Service_Currency addition (the text has yet to be added). André Hoffmann (the guy who jumped first) was open to collaboration, so I’ve leaped on board as a second set of hands and eyes.
For those remotely interested, the draft proposal I forwarded to the mailing list as a discussion point (mainly for André) can be viewed from: http://www.zend.com/lists/fw-general/200609/msg00549.html. The basic premise is simple – the class will be capable of fetching exchange rates between any two currencies from a selection of sources. For the moment that means the European Central Bank and US Federal Reserve. Other sources will get added eventually, and the ability to add more supported by subclassing either as part of ZF or by addition by individual developers.
Eventual functionality includes spot fx rates, currency conversion, and fx rate list fetching from the selected source. It will likely use the proposed Zend_Currency class to handle locale issues (the usual comma vs period debate between Euopean mainlanders and the UK/US folk) and ensure currency codes are ISO 4217 compliant. Zend_Cache will be used to cache fetched data for a set period of time.
All I need now if for some higher power to review the CLA I forwarded back when and clear me as a contributor!

Template Lite: A Sweeter Smarty Alternative

Use the term Template Engine in a PHP forum and the word "Smarty" will inevitably crop up. Smarty is a PHP Template Engine, a library which parses a text file containing Smarty markup and outputs the parsed content as HTML, XML or any other text content you prefer. I like Smarty but, similar to a few PHP libraries, it’s very bloated.

Now I could start throwing the "scalable" buzzword so I’ll immediately limit my post’s scope to concerns on a single server where hardware expansion is not a realistic option. This impacts shared hosts obviously as well as standalone dedicated servers.

Such resources generally have limitations – memory, CPU cycles, I/O vs Database latency, etc. For some people (me!) these are a concern. Faced with resource limits I try to keep my applications lean and mean – small, fast, and adaptable. Unfortunately, Smarty disagrees with my needs. It’s bloated design while packing a mighty punch, uses a chunk of memory and processor time I dislike. Since I also develop open source apps which end up on shared hosts, my concerns are even more justified.

Enter Mark Dickenson. Mark is the developer of a Smarty alternative: Template Lite. Template Lite is not simply another template engine. It’s objective is to maintain Smarty compliance (i.e. it parses Smarty markup) using a redesigned library for minimal memory and CPU cycle consumption. Not happy with just that, Mark has also introduced some non-standard Smarty markup which, simply enough, provides more intuitive methods for traversing arrays, looping, etc. – for example, the SWITCH, FOR and WHILE tags. The results? A Smarty drop-in replacement which is limited to approx. 50% of Smarty‘s usual memory usage and is significantly faster at compiling and displaying templates.

So why use Template Lite? Template Lite is likely not everyone’s cup of tea. It’s an excellent library which is small, readable and surprisingly simple to extend. It’s fast and has approx. 50% of Smarty’s typical memory usage. It’s extendable, and contains additional tags which are more intuitive (to me at least) since they follow programming conventions common to PHP, C++, etc. On the flipside, Template Lite excludes several Smarty features. Use of Template Lite likely depends on how much weight programmers place on these elements. The main one I’ve seen discussed is that Template Lite excludes the "Security" features of Smarty. These place limits on template content and locations which are useful if Templates are editable by untrusted third parties.  Technically, this optional behaviour is unnecessary for most purposes (it’s disabled by default in Smarty), but may be essential for some programmers who want to place limits on in-house designers or such. The include_php tag has also been omitted, and error reporting is not very in-depth.

Overall however, I found Template Lite to be a useful addition to the PHP Toolbox. In circumstances where Smarty appears too heavy handed, Template Lite offers a faster alternative. It’s cleaner design and modularity are the icing on the cake. Template Lite 1.90 was the latest version released on 1 September 2006 – if you haven’t already, check it out.

Quantum Star Status Update

Been a while since I talked shop, so here’s my overview.

During May/June 2006 I was engaged in a review and refactor of the pre-alphas that were released the previous November/December. The main aim of this process was to remove code duplication, implement a Test Driven Design approach, facilitate documentation, implement several alternate LITE libraries, and basically clean everything up. A prime focus was refactoring the Partholan Library.

The process was largely completed. The remaining tasks are:

1. Delete the older Partholan files from Subversion TRUNK
2. Complete the Controller code, possibly by using the Zend Framework controller (it’s pretty simple and easy to adapt if needed)
3. Check the accuracy of inline phpDoc comments
4. Complete any remaining Unit Tests

Once done, the next stage of development will revolve around Web Design. I would like to get some idea of the final interface. I have already put in place a simple Theme feature which operates primarily on CSS (since all pages are CSS only with no tables).

The last part is implementing the actual Domain Logic for the game. This is relatively simple, since a lot of it has existed for some time. This part is the easiest section and will result in a series of Alpha versions – the time for pre-alpha’s is over.

So my plans for the next two weeks?

- Add the Controller area (priority)
- Clean up the SVN repository TRUNK
- Complete remaining Unit Tests

I’m hoping to do it in one week starting at the weekend.

PFP II: Return of Patterns For PHP

It’s been a long Summer. If anyone’s interested in my disappearing act, catch an earlier posting in my blog.

In the meantime it’s appropriate to take stock of the projects I dropped for the Summer. Among them is the Patterns For PHP website. The project is now once again active. To facilitate some easy feedback options and let the Administrators discuss issues, planning and some maintenance tasks we’ll be performing I have added a phpBB forum to the mix.

The new forums are public, and so if anyone wishes to discuss the website, it’s future, and perhaps even to consider contributing Pattern related articles and tutorials drop in at forums.patternsforphp.com. The forums are also linked to from the main website.

For those who emailed me over the Summer (any time from June forward) and who have not yet received a comprehensive reply – I’ll get around to you all during the week.

The Longer Story ;)

Our story starts in June. At a staff meeting my employer announced that we would be starting a project for a client based in County Kerry. Unfortunately I got assigned – the result was over a month living in a hotel in rural Kerry. Hotels in Ireland charge a lot for external phone calls – including of course internet access. Net result was my leaving my online activities for the entire period except for essential email checks and such.

In July, I finally escaped the torture but was left with another dilemna. This was the year I was due to sit the Final Admitting Exam to the Institute of Chartered Accountants In Ireland. The exams cover Financial Accounting, Taxation, Business Finance, Management Accounting, Auditing and a more "big picture" Multi-Discipline case study. Before I go on, I think I definitely aced most of them – though Auditing was a pure mule and I was unable to finish the entire paper in the alloted time (a hefty 4 hours). Anyways, studying for these exams took up a huge amount of time. I organised 6 weeks of leave from work starting in late July which helped immensely and it was all consumed with study.

As a result off I vanished, leaving everyone wondering where I’d mysteriously disappeared! I originally tried just tracking emails, but eventually I threw in the towel and simply disconnected completely. The problem with hitting the internet for a "quick look" is that you can easily get stuck in for a few hours without knowing it.

Anyways, it should be worth it. My result will arrive in November and hopefully with a full pass. That will go a long way to bumping up my future career prospects (not to mention my wallet :-)).

So where from here?

Now that I am back and reconnecting with friends and foes alike, I am assessing all my various online commitments. I suppose I am a bit odd in some respects. For all my internet involvement I don’t actually spend huge chunks of time online. It’s surprising how much material I simply suck onto my hard drive, format, and print for reading material on the daily commute.

First up, the Patterns For PHP website is going to get some attention. I need to check for version updates to MediaWiki and phpBB. The PFP Forums should be online over the next 24 hours. I’ve been in contact with my main partner on the website, Edward Yang (Ambush Commander to Devnetwork junkies). He is due to get shell access to the server to help maintainance and such – besides which he knows MediaWiki far more than I do by a long shot.

With maintenance and forums completed, I’ll be returning to the publicity trail to try drum up additional articles and contributors. I’ll still be chipping on my end, but often other folk have more experience with certain key Patterns which makes their input invaluable. I’ll also be following up on several offers I received over the Summer.

In other news, yesterday I received my first Google Adsense cheque by mail. This can only be a good omen I think – hot on the heels on my return to the internet ;-). The net sum of US$116 is now winging towards my current account through Bank of Irelands bureaucracy. The whole thing will be spent on renewing the QS domain, and prepaying for hosting. Just to note – PFP will not see advertising arrive. I prefer my documentation sites ad free.

On the games front. Before I left I made a whole ton of changes to Quantum Star SE Evolved. Check the commit log on the left panel of this blog. The last piece in the puzzle was a Front Controller setup. I’m currently leaning towards bundling the Controller section of the Zend Framework with a few extensions for the specifics of the game. With this last piece slotted, and a migration to Template Lite instead of Smarty, QS is well on course on a desperately needed update. Goodbye 1999 PHP 3 code, hello shiny new PHP 5 code with Unit Tests. :-)

That’s all from me for now. Since I’m back fully – I expect the blog activity will soar as things sort themselves out in all these activities. Still need to catch up on the Protoshell project, and others. But those subjects are reserved for another day.