Her indoors wants an e-commerce web site to sell table mats <link posted + discount to journal readers when available >. Despite enthusing about Perl and using it daily, I actually prefer to write dynamic websites in PHP <hiss boo>. Its quick, simple, very easy to prototype, and if an ISP is offering PHP then you know your site will work, rather than having to negotiate module installation and/or maintaining your own mini-CPAN in your user directory.
Most of the donkey work going on behind the scenes in an e-commerce site is simply writing and retrieving data from a database, and adding things together once in a while. My object model might require a dozen classes, although the attributes of each class are very different, the methods are very similar.
I guess I could write a meta-class and identify the common functionality between each class and overload when needed. But this becomes a maintenance nightmare when you try to extend the system and have to walk through the code to find what functionality is coming from where.
So to automate the creation of my PHP I've reduced the various classes to a simple XML template. This template is parsed by a Perl script which not only spits out a fully formed PHP class from the template but also writes the common 'store', 'retrieve', 'retrieveLike' methods too. All thats left is for me to write the unique methods for the classes, about 3 or 4 per class. I dont have to worry about the simple methods, since I know they'll work (sure I'm going to test anyway), any errors I made in the template will tend to be very obvious since the class wont look like the object model or wont interface with the database. Now I have a templating system to help me rapidly create new PHP classes when I need them.
Cool or what !
are you willing to share your perl code? (Score:1)
Re:are you willing to share your perl code? (Score:1)
Re:are you willing to share your perl code? (Score:1)